Commit 86217543ed62c813314262c4934d40bcefa806ab

Authored by 陈硕
2 parents 7a9e45d8 915b1b18

合并冲突

app/build.gradle
@@ -22,12 +22,14 @@ android { @@ -22,12 +22,14 @@ android {
22 } 22 }
23 23
24 signingConfigs { 24 signingConfigs {
  25 + Properties props = new Properties();
  26 + props.load(new FileInputStream(rootProject.file('signing.properties')))
25 myConfig { 27 myConfig {
26 - storeFile file("cnlive_app.jks")  
27 - storePassword "000000"  
28 - keyAlias "CNliveApp"  
29 - keyPassword "000000"  
30 v2SigningEnabled false 28 v2SigningEnabled false
  29 + storeFile file(props['KEYSTORE_FILE'])
  30 + storePassword props['KEYSTORE_PASSWORD']
  31 + keyAlias props['KEY_ALIAS']
  32 + keyPassword props['KEY_PASSWORD']
31 } 33 }
32 } 34 }
33 35
app/src/main/java/com/cnlive/gundam/main/presenter/AnchorInfoPresenter.java
@@ -4,7 +4,7 @@ import android.content.Context; @@ -4,7 +4,7 @@ import android.content.Context;
4 4
5 import com.cnlive.gundam.data.network.RetrofitUtil; 5 import com.cnlive.gundam.data.network.RetrofitUtil;
6 import com.cnlive.gundam.data.network.util.SignUtil; 6 import com.cnlive.gundam.data.network.util.SignUtil;
7 -import com.cnlive.gundam.main.presenter.view.AnchorInfoView; 7 +import com.cnlive.gundam.main.presenter.view.IAnchorInfoView;
8 import com.cnlive.gundam.stream.model.ChannelInfoModel; 8 import com.cnlive.gundam.stream.model.ChannelInfoModel;
9 import com.cnlive.libs.util.Config; 9 import com.cnlive.libs.util.Config;
10 10
@@ -22,13 +22,13 @@ import retrofit2.Response; @@ -22,13 +22,13 @@ import retrofit2.Response;
22 22
23 public class AnchorInfoPresenter { 23 public class AnchorInfoPresenter {
24 24
25 - private WeakReference<AnchorInfoView> viewRef; 25 + private WeakReference<IAnchorInfoView> viewRef;
26 26
27 - public AnchorInfoPresenter(AnchorInfoView view) { 27 + public AnchorInfoPresenter(IAnchorInfoView view) {
28 viewRef = new WeakReference<>(view); 28 viewRef = new WeakReference<>(view);
29 } 29 }
30 30
31 - private AnchorInfoView getView(){ 31 + private IAnchorInfoView getView(){
32 return viewRef == null ? null : viewRef.get(); 32 return viewRef == null ? null : viewRef.get();
33 } 33 }
34 /** 34 /**
app/src/main/java/com/cnlive/gundam/main/presenter/view/AnchorInfoView.java
1 package com.cnlive.gundam.main.presenter.view; 1 package com.cnlive.gundam.main.presenter.view;
2 2
  3 +import android.app.Activity;
  4 +import android.app.AlertDialog;
  5 +import android.content.DialogInterface;
  6 +import android.content.Intent;
  7 +import android.support.v4.app.Fragment;
  8 +import android.widget.Toast;
  9 +
  10 +import com.cnlive.gundam.R;
  11 +import com.cnlive.gundam.main.ui.activity.WebViewActivity;
3 import com.cnlive.gundam.stream.model.ChannelInfoModel; 12 import com.cnlive.gundam.stream.model.ChannelInfoModel;
  13 +import com.cnlive.gundam.stream.ui.activity.StreamActivity;
  14 +import com.cnlive.gundam.user.auth.UserService;
  15 +import com.cnlive.libs.util.Config;
  16 +
  17 +/**
  18 + * Created by xiansong on 2017/7/10.
  19 + */
  20 +
  21 +public class AnchorInfoView implements IAnchorInfoView{
  22 +
  23 + private Activity activity;
  24 +
  25 + public AnchorInfoView(Activity activity){
  26 + this.activity = activity;
  27 + }
  28 +
  29 + public AnchorInfoView(Fragment fragment){
  30 + this.activity = fragment != null ? fragment.getActivity() : null;
  31 + }
  32 +
  33 + @Override
  34 + public void onAnchorInfo(ChannelInfoModel info) {
  35 + switch (info.getData().getStatus()) {
  36 + case -1:
  37 + Toast.makeText(activity, "主播不存在", Toast.LENGTH_SHORT).show();
  38 + showVerifiedDialog();
  39 + break;
  40 + case 1:
  41 + Toast.makeText(activity, "审核中,请耐心等待", Toast.LENGTH_SHORT).show();
  42 + break;
  43 + case 2:
  44 + Toast.makeText(activity, "审核失败", Toast.LENGTH_SHORT).show();
  45 + break;
  46 + case 3:
  47 + Toast.makeText(activity, "开启直播", Toast.LENGTH_SHORT).show();
  48 + startStreamActivity(info);
  49 + break;
  50 + case 4:
  51 + Toast.makeText(activity, "主播被禁用", Toast.LENGTH_SHORT).show();
  52 + break;
  53 + }
  54 + }
  55 +
  56 + @Override
  57 + public void getAnchorFailure() {
  58 + Toast.makeText(activity, "主播信息认证失败", Toast.LENGTH_LONG).show();
  59 + }
4 60
5 -public interface AnchorInfoView {  
6 /** 61 /**
7 - * 获取主播信息成功 62 + * 开启直播推流页面
8 * 63 *
9 - * @param channelInfo 主播信息 64 + * @param info 主播信息
10 */ 65 */
11 - void onAnchorInfo(ChannelInfoModel channelInfo); 66 + private void startStreamActivity(ChannelInfoModel info) {
  67 + String activityId = System.currentTimeMillis() + "";
  68 + String channelId = info.getData().getChannelId();
  69 + String channelName = info.getData().getChannelName();
  70 + String coverImgUrl = info.getData().getCoverImgUrl();
  71 + StreamActivity.start(activity, activityId, channelId, channelName, coverImgUrl);
  72 + }
12 73
13 /** 74 /**
14 - * 获取主播信息失败 75 + * 显示主播申请页面
15 */ 76 */
16 - void getAnchorFailure();  
17 -}  
18 \ No newline at end of file 77 \ No newline at end of file
  78 + private void showVerifiedDialog() {
  79 + new AlertDialog.Builder(activity)
  80 + .setMessage("亲,完成实名认证就可以开播啦,现在就去认证吧?")
  81 + .setPositiveButton("去认证", new DialogInterface.OnClickListener() {
  82 + @Override
  83 + public void onClick(DialogInterface dialogInterface, int i) {
  84 + dialogInterface.dismiss();
  85 + String channelId = UserService.getInstance(activity).getActiveAccountInfo().getUid() + "";
  86 + String base_url = activity.getString(Config.debug ? R.string.debug_verified_url : R.string.verified_url);
  87 + String url = String.format(base_url, channelId, Config.getAppId());
  88 + Intent intent = new Intent(activity, WebViewActivity.class);
  89 + intent.putExtra("url", url);
  90 + intent.putExtra("title", "主播认证");
  91 + activity.startActivity(intent);
  92 + }
  93 + })
  94 + .setNegativeButton("取消", new DialogInterface.OnClickListener() {
  95 + @Override
  96 + public void onClick(DialogInterface dialogInterface, int i) {
  97 + dialogInterface.dismiss();
  98 + }
  99 + }).show();
  100 + }
  101 +
  102 +}
app/src/main/java/com/cnlive/gundam/main/presenter/view/IAnchorInfoView.java 0 → 100644
  1 +package com.cnlive.gundam.main.presenter.view;
  2 +
  3 +import com.cnlive.gundam.stream.model.ChannelInfoModel;
  4 +
  5 +public interface IAnchorInfoView {
  6 + /**
  7 + * 获取主播信息成功
  8 + *
  9 + * @param channelInfo 主播信息
  10 + */
  11 + void onAnchorInfo(ChannelInfoModel channelInfo);
  12 +
  13 + /**
  14 + * 获取主播信息失败
  15 + */
  16 + void getAnchorFailure();
  17 +}
0 \ No newline at end of file 18 \ No newline at end of file
app/src/main/java/com/cnlive/gundam/main/ui/activity/MainActivity.java
1 package com.cnlive.gundam.main.ui.activity; 1 package com.cnlive.gundam.main.ui.activity;
2 2
3 -import android.app.AlertDialog;  
4 -import android.content.DialogInterface;  
5 import android.content.Intent; 3 import android.content.Intent;
6 import android.databinding.DataBindingUtil; 4 import android.databinding.DataBindingUtil;
7 import android.os.Bundle; 5 import android.os.Bundle;
8 import android.support.v7.app.AppCompatActivity; 6 import android.support.v7.app.AppCompatActivity;
9 -import android.widget.Toast;  
10 7
11 import com.cnlive.gundam.R; 8 import com.cnlive.gundam.R;
12 import com.cnlive.gundam.databinding.ActivityMainBinding; 9 import com.cnlive.gundam.databinding.ActivityMainBinding;
@@ -18,15 +15,11 @@ import com.cnlive.gundam.main.ui.fragment.LiveFragment; @@ -18,15 +15,11 @@ import com.cnlive.gundam.main.ui.fragment.LiveFragment;
18 import com.cnlive.gundam.main.ui.fragment.UGCListFragment; 15 import com.cnlive.gundam.main.ui.fragment.UGCListFragment;
19 import com.cnlive.gundam.main.ui.widget.FragmentTabHost; 16 import com.cnlive.gundam.main.ui.widget.FragmentTabHost;
20 import com.cnlive.gundam.main.utils.SharedPreferencesHelper; 17 import com.cnlive.gundam.main.utils.SharedPreferencesHelper;
21 -import com.cnlive.gundam.stream.model.ChannelInfoModel;  
22 -import com.cnlive.gundam.stream.ui.activity.StreamActivity;  
23 import com.cnlive.gundam.stream.util.FileUtil; 18 import com.cnlive.gundam.stream.util.FileUtil;
24 import com.cnlive.gundam.user.activity.LoginActivity; 19 import com.cnlive.gundam.user.activity.LoginActivity;
25 import com.cnlive.gundam.user.auth.UserService; 20 import com.cnlive.gundam.user.auth.UserService;
26 import com.cnlive.gundam.user.model.User; 21 import com.cnlive.gundam.user.model.User;
27 import com.cnlive.gundam.video.view.VideoView; 22 import com.cnlive.gundam.video.view.VideoView;
28 -import com.cnlive.libs.util.Config;  
29 -import com.cnlive.libs.util.ProbeUtil;  
30 23
31 import java.util.Arrays; 24 import java.util.Arrays;
32 25
@@ -34,11 +27,10 @@ import java.util.Arrays; @@ -34,11 +27,10 @@ import java.util.Arrays;
34 * Created by xiansong on 2017/6/27. 27 * Created by xiansong on 2017/6/27.
35 */ 28 */
36 29
37 -public class MainActivity extends AppCompatActivity implements FragmentTabHost.OnSetCurrentTabListener, AnchorInfoView { 30 +public class MainActivity extends AppCompatActivity implements FragmentTabHost.OnSetCurrentTabListener {
38 31
39 private AnchorInfoPresenter mAnchorInfoPresenter; 32 private AnchorInfoPresenter mAnchorInfoPresenter;
40 33
41 -  
42 @Override 34 @Override
43 protected void onCreate(Bundle savedInstanceState) { 35 protected void onCreate(Bundle savedInstanceState) {
44 super.onCreate(savedInstanceState); 36 super.onCreate(savedInstanceState);
@@ -53,13 +45,10 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O @@ -53,13 +45,10 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O
53 FragmentTabHost.newTab("config", R.layout.indicator_main_mine, ConfigFragment.class) 45 FragmentTabHost.newTab("config", R.layout.indicator_main_mine, ConfigFragment.class)
54 )); 46 ));
55 47
56 - mAnchorInfoPresenter = new AnchorInfoPresenter(this); 48 + mAnchorInfoPresenter = new AnchorInfoPresenter(new AnchorInfoView(this));
57 49
58 //加载水印图片 50 //加载水印图片
59 FileUtil.copyFile(this, "cnlive_logo.png"); 51 FileUtil.copyFile(this, "cnlive_logo.png");
60 -  
61 - ProbeUtil.probeSDK("startupCount");  
62 -  
63 } 52 }
64 53
65 @Override 54 @Override
@@ -84,74 +73,6 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O @@ -84,74 +73,6 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O
84 } 73 }
85 } 74 }
86 75
87 -  
88 - @Override  
89 - public void onAnchorInfo(ChannelInfoModel info) {  
90 - switch (info.getData().getStatus()) {  
91 - case -1:  
92 - Toast.makeText(this, "主播不存在", Toast.LENGTH_SHORT).show();  
93 - showVerifiedDialog();  
94 - break;  
95 - case 1:  
96 - Toast.makeText(this, "审核中,请耐心等待", Toast.LENGTH_SHORT).show();  
97 - break;  
98 - case 2:  
99 - Toast.makeText(this, "审核失败", Toast.LENGTH_SHORT).show();  
100 - break;  
101 - case 3:  
102 - Toast.makeText(this, "开启直播", Toast.LENGTH_SHORT).show();  
103 - startStreamActivity(info);  
104 - break;  
105 - case 4:  
106 - Toast.makeText(this, "主播被禁用", Toast.LENGTH_SHORT).show();  
107 - break;  
108 - }  
109 - }  
110 -  
111 - @Override  
112 - public void getAnchorFailure() {  
113 - Toast.makeText(this, "主播信息认证失败", Toast.LENGTH_LONG).show();  
114 - }  
115 -  
116 - /**  
117 - * 开启直播推流页面  
118 - *  
119 - * @param info 主播信息  
120 - */  
121 - private void startStreamActivity(ChannelInfoModel info) {  
122 - String activityId = System.currentTimeMillis() + "";  
123 - String channelId = info.getData().getChannelId();  
124 - String channelName = info.getData().getChannelName();  
125 - String coverImgUrl = info.getData().getCoverImgUrl();  
126 - StreamActivity.start(this, activityId, channelId, channelName, coverImgUrl);  
127 - }  
128 -  
129 - /**  
130 - * 显示主播申请页面  
131 - */  
132 - private void showVerifiedDialog() {  
133 - new AlertDialog.Builder(this)  
134 - .setMessage("亲,完成实名认证就可以开播啦,现在就去认证吧?")  
135 - .setPositiveButton("去认证", new DialogInterface.OnClickListener() {  
136 - @Override  
137 - public void onClick(DialogInterface dialogInterface, int i) {  
138 - dialogInterface.dismiss();  
139 - String channelId = UserService.getInstance(MainActivity.this).getActiveAccountInfo().getUid() + "";  
140 - String url = String.format(getString(Config.debug ? R.string.debug_verified_url : R.string.verified_url), channelId, Config.getAppId());  
141 - Intent intent = new Intent(MainActivity.this, WebViewActivity.class);  
142 - intent.putExtra("url", url);  
143 - intent.putExtra("title", "主播认证");  
144 - startActivity(intent);  
145 - }  
146 - })  
147 - .setNegativeButton("取消", new DialogInterface.OnClickListener() {  
148 - @Override  
149 - public void onClick(DialogInterface dialogInterface, int i) {  
150 - dialogInterface.dismiss();  
151 - }  
152 - }).show();  
153 - }  
154 -  
155 @Override 76 @Override
156 protected void onDestroy() { 77 protected void onDestroy() {
157 super.onDestroy(); 78 super.onDestroy();
signing.properties 0 → 100644
  1 +KEYSTORE_FILE=cnlive_app.jks
  2 +KEYSTORE_PASSWORD=000000
  3 +KEY_ALIAS=CNliveApp
  4 +KEY_PASSWORD=000000
0 \ No newline at end of file 5 \ No newline at end of file