Commit 6e69c11bfaa164b46ed7bd8bde4ad968e145f59c
Merge remote-tracking branch 'origin/master'
# Conflicts: # app/build.gradle # app/src/main/java/com/cnlive/gundam/main/ui/fragment/ConfigFragment.java
Showing
12 changed files
with
250 additions
and
104 deletions
app/build.gradle
| @@ -3,6 +3,11 @@ apply plugin: 'com.android.application' | @@ -3,6 +3,11 @@ apply plugin: 'com.android.application' | ||
| 3 | android { | 3 | android { |
| 4 | compileSdkVersion 26 | 4 | compileSdkVersion 26 |
| 5 | buildToolsVersion "26.0.0" | 5 | buildToolsVersion "26.0.0" |
| 6 | + | ||
| 7 | + dexOptions { | ||
| 8 | + javaMaxHeapSize "4g" | ||
| 9 | + } | ||
| 10 | + | ||
| 6 | defaultConfig { | 11 | defaultConfig { |
| 7 | applicationId "com.cnlive.gundam" | 12 | applicationId "com.cnlive.gundam" |
| 8 | minSdkVersion 16 | 13 | minSdkVersion 16 |
| @@ -17,25 +22,38 @@ android { | @@ -17,25 +22,38 @@ android { | ||
| 17 | } | 22 | } |
| 18 | 23 | ||
| 19 | signingConfigs { | 24 | signingConfigs { |
| 25 | + Properties props = new Properties(); | ||
| 26 | + props.load(new FileInputStream(rootProject.file('signing.properties'))) | ||
| 20 | myConfig { | 27 | myConfig { |
| 21 | - storeFile file("cnlive_app.jks") | ||
| 22 | - storePassword "000000" | ||
| 23 | - keyAlias "CNliveApp" | ||
| 24 | - keyPassword "000000" | 28 | + v2SigningEnabled false |
| 29 | + storeFile file(props['KEYSTORE_FILE']) | ||
| 30 | + storePassword props['KEYSTORE_PASSWORD'] | ||
| 31 | + keyAlias props['KEY_ALIAS'] | ||
| 32 | + keyPassword props['KEY_PASSWORD'] | ||
| 25 | } | 33 | } |
| 26 | } | 34 | } |
| 27 | 35 | ||
| 28 | buildTypes { | 36 | buildTypes { |
| 29 | debug { | 37 | debug { |
| 38 | + applicationIdSuffix ".debug" | ||
| 30 | signingConfig signingConfigs.myConfig | 39 | signingConfig signingConfigs.myConfig |
| 40 | + zipAlignEnabled true | ||
| 31 | } | 41 | } |
| 32 | release { | 42 | release { |
| 33 | minifyEnabled false | 43 | minifyEnabled false |
| 34 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | 44 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 35 | signingConfig signingConfigs.myConfig | 45 | signingConfig signingConfigs.myConfig |
| 46 | + zipAlignEnabled true | ||
| 36 | } | 47 | } |
| 37 | } | 48 | } |
| 38 | 49 | ||
| 50 | + applicationVariants.all { variant -> | ||
| 51 | + def file = variant.outputs[0].outputFile | ||
| 52 | + def name = "CNliveApp_" + defaultConfig.versionName + "_" + variant.buildType.name + ".apk"; | ||
| 53 | + variant.outputs[0].outputFile = new File(file.parent, name) | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + | ||
| 39 | useLibrary 'org.apache.http.legacy' | 57 | useLibrary 'org.apache.http.legacy' |
| 40 | } | 58 | } |
| 41 | 59 | ||
| @@ -52,8 +70,11 @@ dependencies { | @@ -52,8 +70,11 @@ dependencies { | ||
| 52 | compile 'com.android.support.constraint:constraint-layout:1.0.2' | 70 | compile 'com.android.support.constraint:constraint-layout:1.0.2' |
| 53 | compile 'com.github.bumptech.glide:glide:3.7.0' | 71 | compile 'com.github.bumptech.glide:glide:3.7.0' |
| 54 | compile 'org.greenrobot:eventbus:3.0.0' | 72 | compile 'org.greenrobot:eventbus:3.0.0' |
| 73 | + | ||
| 74 | + //Retrofit | ||
| 55 | compile 'com.squareup.retrofit2:retrofit:2.0.2' | 75 | compile 'com.squareup.retrofit2:retrofit:2.0.2' |
| 56 | compile 'com.squareup.retrofit2:converter-gson:2.0.2' | 76 | compile 'com.squareup.retrofit2:converter-gson:2.0.2' |
| 77 | + //OKhttp | ||
| 57 | compile 'com.squareup.okhttp3:okhttp:3.2.0' | 78 | compile 'com.squareup.okhttp3:okhttp:3.2.0' |
| 58 | compile 'com.squareup.okhttp3:okhttp-ws:3.2.0' | 79 | compile 'com.squareup.okhttp3:okhttp-ws:3.2.0' |
| 59 | compile 'com.squareup.okhttp3:logging-interceptor:3.2.0' | 80 | compile 'com.squareup.okhttp3:logging-interceptor:3.2.0' |
app/src/main/java/com/cnlive/gundam/main/presenter/AnchorInfoPresenter.java
| @@ -4,11 +4,10 @@ import android.content.Context; | @@ -4,11 +4,10 @@ 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 | ||
| 11 | -import java.lang.ref.WeakReference; | ||
| 12 | import java.util.HashMap; | 11 | import java.util.HashMap; |
| 13 | import java.util.Map; | 12 | import java.util.Map; |
| 14 | 13 | ||
| @@ -22,14 +21,14 @@ import retrofit2.Response; | @@ -22,14 +21,14 @@ import retrofit2.Response; | ||
| 22 | 21 | ||
| 23 | public class AnchorInfoPresenter { | 22 | public class AnchorInfoPresenter { |
| 24 | 23 | ||
| 25 | - private WeakReference<AnchorInfoView> viewRef; | 24 | + private IAnchorInfoView view; |
| 26 | 25 | ||
| 27 | - public AnchorInfoPresenter(AnchorInfoView view) { | ||
| 28 | - viewRef = new WeakReference<>(view); | 26 | + public AnchorInfoPresenter(IAnchorInfoView view) { |
| 27 | + this.view = view; | ||
| 29 | } | 28 | } |
| 30 | 29 | ||
| 31 | - private AnchorInfoView getView(){ | ||
| 32 | - return viewRef == null ? null : viewRef.get(); | 30 | + private IAnchorInfoView getView(){ |
| 31 | + return view; | ||
| 33 | } | 32 | } |
| 34 | /** | 33 | /** |
| 35 | * 查询主播信息 | 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; | 7 | +import android.util.Log; |
| 10 | 8 | ||
| 11 | import com.cnlive.gundam.R; | 9 | import com.cnlive.gundam.R; |
| 12 | import com.cnlive.gundam.databinding.ActivityMainBinding; | 10 | import com.cnlive.gundam.databinding.ActivityMainBinding; |
| @@ -18,14 +16,12 @@ import com.cnlive.gundam.main.ui.fragment.LiveFragment; | @@ -18,14 +16,12 @@ import com.cnlive.gundam.main.ui.fragment.LiveFragment; | ||
| 18 | import com.cnlive.gundam.main.ui.fragment.UGCListFragment; | 16 | import com.cnlive.gundam.main.ui.fragment.UGCListFragment; |
| 19 | import com.cnlive.gundam.main.ui.widget.FragmentTabHost; | 17 | import com.cnlive.gundam.main.ui.widget.FragmentTabHost; |
| 20 | import com.cnlive.gundam.main.utils.SharedPreferencesHelper; | 18 | 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; | 19 | import com.cnlive.gundam.stream.util.FileUtil; |
| 24 | import com.cnlive.gundam.user.activity.LoginActivity; | 20 | import com.cnlive.gundam.user.activity.LoginActivity; |
| 25 | import com.cnlive.gundam.user.auth.UserService; | 21 | import com.cnlive.gundam.user.auth.UserService; |
| 26 | import com.cnlive.gundam.user.model.User; | 22 | import com.cnlive.gundam.user.model.User; |
| 27 | import com.cnlive.gundam.video.view.VideoView; | 23 | import com.cnlive.gundam.video.view.VideoView; |
| 28 | -import com.cnlive.libs.util.Config; | 24 | +import com.cnlive.libs.util.ProbeUtil; |
| 29 | 25 | ||
| 30 | import java.util.Arrays; | 26 | import java.util.Arrays; |
| 31 | 27 | ||
| @@ -33,7 +29,7 @@ import java.util.Arrays; | @@ -33,7 +29,7 @@ import java.util.Arrays; | ||
| 33 | * Created by xiansong on 2017/6/27. | 29 | * Created by xiansong on 2017/6/27. |
| 34 | */ | 30 | */ |
| 35 | 31 | ||
| 36 | -public class MainActivity extends AppCompatActivity implements FragmentTabHost.OnSetCurrentTabListener, AnchorInfoView { | 32 | +public class MainActivity extends AppCompatActivity implements FragmentTabHost.OnSetCurrentTabListener { |
| 37 | 33 | ||
| 38 | private AnchorInfoPresenter mAnchorInfoPresenter; | 34 | private AnchorInfoPresenter mAnchorInfoPresenter; |
| 39 | 35 | ||
| @@ -51,8 +47,10 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O | @@ -51,8 +47,10 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O | ||
| 51 | FragmentTabHost.newTab("config", R.layout.indicator_main_mine, ConfigFragment.class) | 47 | FragmentTabHost.newTab("config", R.layout.indicator_main_mine, ConfigFragment.class) |
| 52 | )); | 48 | )); |
| 53 | 49 | ||
| 54 | - mAnchorInfoPresenter = new AnchorInfoPresenter(this); | 50 | + mAnchorInfoPresenter = new AnchorInfoPresenter(new AnchorInfoView(this)); |
| 51 | + ProbeUtil.probeSDK("statup"); | ||
| 55 | 52 | ||
| 53 | + Log.d("MainActivity", "onCreate:"); | ||
| 56 | //加载水印图片 | 54 | //加载水印图片 |
| 57 | FileUtil.copyFile(this, "cnlive_logo.png"); | 55 | FileUtil.copyFile(this, "cnlive_logo.png"); |
| 58 | } | 56 | } |
| @@ -79,74 +77,6 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O | @@ -79,74 +77,6 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O | ||
| 79 | } | 77 | } |
| 80 | } | 78 | } |
| 81 | 79 | ||
| 82 | - | ||
| 83 | - @Override | ||
| 84 | - public void onAnchorInfo(ChannelInfoModel info) { | ||
| 85 | - switch (info.getData().getStatus()) { | ||
| 86 | - case -1: | ||
| 87 | - Toast.makeText(this, "主播不存在", Toast.LENGTH_SHORT).show(); | ||
| 88 | - showVerifiedDialog(); | ||
| 89 | - break; | ||
| 90 | - case 1: | ||
| 91 | - Toast.makeText(this, "审核中,请耐心等待", Toast.LENGTH_SHORT).show(); | ||
| 92 | - break; | ||
| 93 | - case 2: | ||
| 94 | - Toast.makeText(this, "审核失败", Toast.LENGTH_SHORT).show(); | ||
| 95 | - break; | ||
| 96 | - case 3: | ||
| 97 | - Toast.makeText(this, "开启直播", Toast.LENGTH_SHORT).show(); | ||
| 98 | - startStreamActivity(info); | ||
| 99 | - break; | ||
| 100 | - case 4: | ||
| 101 | - Toast.makeText(this, "主播被禁用", Toast.LENGTH_SHORT).show(); | ||
| 102 | - break; | ||
| 103 | - } | ||
| 104 | - } | ||
| 105 | - | ||
| 106 | - @Override | ||
| 107 | - public void getAnchorFailure() { | ||
| 108 | - Toast.makeText(this, "主播信息认证失败", Toast.LENGTH_LONG).show(); | ||
| 109 | - } | ||
| 110 | - | ||
| 111 | - /** | ||
| 112 | - * 开启直播推流页面 | ||
| 113 | - * | ||
| 114 | - * @param info 主播信息 | ||
| 115 | - */ | ||
| 116 | - private void startStreamActivity(ChannelInfoModel info) { | ||
| 117 | - String activityId = System.currentTimeMillis() + ""; | ||
| 118 | - String channelId = info.getData().getChannelId(); | ||
| 119 | - String channelName = info.getData().getChannelName(); | ||
| 120 | - String coverImgUrl = info.getData().getCoverImgUrl(); | ||
| 121 | - StreamActivity.start(this, activityId, channelId, channelName, coverImgUrl); | ||
| 122 | - } | ||
| 123 | - | ||
| 124 | - /** | ||
| 125 | - * 显示主播申请页面 | ||
| 126 | - */ | ||
| 127 | - private void showVerifiedDialog() { | ||
| 128 | - new AlertDialog.Builder(this) | ||
| 129 | - .setMessage("亲,完成实名认证就可以开播啦,现在就去认证吧?") | ||
| 130 | - .setPositiveButton("去认证", new DialogInterface.OnClickListener() { | ||
| 131 | - @Override | ||
| 132 | - public void onClick(DialogInterface dialogInterface, int i) { | ||
| 133 | - dialogInterface.dismiss(); | ||
| 134 | - String channelId = UserService.getInstance(MainActivity.this).getActiveAccountInfo().getUid() + ""; | ||
| 135 | - String url = String.format(getString(Config.debug ? R.string.debug_verified_url : R.string.verified_url), channelId, Config.getAppId()); | ||
| 136 | - Intent intent = new Intent(MainActivity.this, WebViewActivity.class); | ||
| 137 | - intent.putExtra("url", url); | ||
| 138 | - intent.putExtra("title", "主播认证"); | ||
| 139 | - startActivity(intent); | ||
| 140 | - } | ||
| 141 | - }) | ||
| 142 | - .setNegativeButton("取消", new DialogInterface.OnClickListener() { | ||
| 143 | - @Override | ||
| 144 | - public void onClick(DialogInterface dialogInterface, int i) { | ||
| 145 | - dialogInterface.dismiss(); | ||
| 146 | - } | ||
| 147 | - }).show(); | ||
| 148 | - } | ||
| 149 | - | ||
| 150 | @Override | 80 | @Override |
| 151 | protected void onDestroy() { | 81 | protected void onDestroy() { |
| 152 | super.onDestroy(); | 82 | super.onDestroy(); |
app/src/main/java/com/cnlive/gundam/main/ui/fragment/ConfigFragment.java
| @@ -18,7 +18,10 @@ import com.cnlive.gundam.user.activity.LoginActivity; | @@ -18,7 +18,10 @@ import com.cnlive.gundam.user.activity.LoginActivity; | ||
| 18 | import com.cnlive.gundam.user.activity.UserPersonalActivity; | 18 | import com.cnlive.gundam.user.activity.UserPersonalActivity; |
| 19 | import com.cnlive.gundam.user.auth.UserService; | 19 | import com.cnlive.gundam.user.auth.UserService; |
| 20 | import com.cnlive.gundam.user.model.User; | 20 | import com.cnlive.gundam.user.model.User; |
| 21 | - | 21 | +import com.cnlive.libs.user.IUserService; |
| 22 | +import com.cnlive.libs.user.UserUtil; | ||
| 23 | +import com.cnlive.libs.user.model.UserData; | ||
| 24 | +import com.cnlive.libs.util.data.network.Callback; | ||
| 22 | 25 | ||
| 23 | /** | 26 | /** |
| 24 | * Created by xiansong on 2017/6/27. | 27 | * Created by xiansong on 2017/6/27. |
| @@ -26,6 +29,7 @@ import com.cnlive.gundam.user.model.User; | @@ -26,6 +29,7 @@ import com.cnlive.gundam.user.model.User; | ||
| 26 | 29 | ||
| 27 | public class ConfigFragment extends Fragment implements View.OnClickListener { | 30 | public class ConfigFragment extends Fragment implements View.OnClickListener { |
| 28 | private UserFragmentBinding binding; | 31 | private UserFragmentBinding binding; |
| 32 | + private User activeAccountInfo; | ||
| 29 | 33 | ||
| 30 | @Nullable | 34 | @Nullable |
| 31 | @Override | 35 | @Override |
| @@ -63,7 +67,7 @@ public class ConfigFragment extends Fragment implements View.OnClickListener { | @@ -63,7 +67,7 @@ public class ConfigFragment extends Fragment implements View.OnClickListener { | ||
| 63 | if (uid != 0) { | 67 | if (uid != 0) { |
| 64 | //进入个人中心页面 | 68 | //进入个人中心页面 |
| 65 | Intent intent = new Intent(getActivity(), UserPersonalActivity.class); | 69 | Intent intent = new Intent(getActivity(), UserPersonalActivity.class); |
| 66 | - intent.putExtra("isEdit", false); | 70 | + intent.putExtra("isEdit",false); |
| 67 | startActivity(intent); | 71 | startActivity(intent); |
| 68 | } else { | 72 | } else { |
| 69 | //进入登录页面 | 73 | //进入登录页面 |
| @@ -89,13 +93,30 @@ public class ConfigFragment extends Fragment implements View.OnClickListener { | @@ -89,13 +93,30 @@ public class ConfigFragment extends Fragment implements View.OnClickListener { | ||
| 89 | } | 93 | } |
| 90 | 94 | ||
| 91 | private void notifyUI(boolean isLogin) { | 95 | private void notifyUI(boolean isLogin) { |
| 92 | - if (isLogin) { | ||
| 93 | - User activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo(); | 96 | + if(isLogin){ |
| 97 | + activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo(); | ||
| 98 | + updateUserInfo(activeAccountInfo); | ||
| 99 | + activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo(); | ||
| 94 | Glide.with(getActivity()).load(activeAccountInfo.getFaceurl()).into(binding.headImg); | 100 | Glide.with(getActivity()).load(activeAccountInfo.getFaceurl()).into(binding.headImg); |
| 95 | binding.tvNickname.setText(activeAccountInfo.getNickname()); | 101 | binding.tvNickname.setText(activeAccountInfo.getNickname()); |
| 96 | - } else { | 102 | + }else{ |
| 97 | Glide.with(getActivity()).load(R.drawable.cnlive_user_header).into(binding.headImg); | 103 | Glide.with(getActivity()).load(R.drawable.cnlive_user_header).into(binding.headImg); |
| 98 | binding.tvNickname.setText(getString(R.string.click_login)); | 104 | binding.tvNickname.setText(getString(R.string.click_login)); |
| 99 | } | 105 | } |
| 100 | } | 106 | } |
| 107 | + | ||
| 108 | + | ||
| 109 | + | ||
| 110 | + private void updateUserInfo(User user) { | ||
| 111 | + UserUtil.queryUserInfo(String.valueOf(user.getUid()), String.valueOf(user.getUid()), new Callback() { | ||
| 112 | + @Override | ||
| 113 | + public void onState(int i, String s, Object obj) { | ||
| 114 | + if (i == IUserService.SUCCESS) { | ||
| 115 | + UserData userData = (UserData) obj; | ||
| 116 | + UserService userService = UserService.getInstance(getActivity()); | ||
| 117 | + userService.setActiveAccountInfo(userData.getData()); | ||
| 118 | + } | ||
| 119 | + } | ||
| 120 | + }); | ||
| 121 | + } | ||
| 101 | } | 122 | } |
app/src/main/java/com/cnlive/gundam/user/fragment/UserPersonalEditFragment.java
| @@ -129,6 +129,10 @@ public class UserPersonalEditFragment extends Fragment implements Callback, View | @@ -129,6 +129,10 @@ public class UserPersonalEditFragment extends Fragment implements Callback, View | ||
| 129 | if (i == IUserService.SUCCESS) { | 129 | if (i == IUserService.SUCCESS) { |
| 130 | updateUserInfo(); | 130 | updateUserInfo(); |
| 131 | Toast.makeText(getActivity(), "提交成功", Toast.LENGTH_LONG).show(); | 131 | Toast.makeText(getActivity(), "提交成功", Toast.LENGTH_LONG).show(); |
| 132 | + } else if (i == IUserService.ERROR_TOKEN_INVALID) { | ||
| 133 | + UserService userService = UserService.getInstance(getActivity()); | ||
| 134 | + userService.clearUser(); | ||
| 135 | + getActivity().finish(); | ||
| 132 | } else { | 136 | } else { |
| 133 | Toast.makeText(getActivity(), "提交失败" + s, Toast.LENGTH_LONG).show(); | 137 | Toast.makeText(getActivity(), "提交失败" + s, Toast.LENGTH_LONG).show(); |
| 134 | } | 138 | } |
| @@ -142,6 +146,10 @@ public class UserPersonalEditFragment extends Fragment implements Callback, View | @@ -142,6 +146,10 @@ public class UserPersonalEditFragment extends Fragment implements Callback, View | ||
| 142 | UserData userData = (UserData) obj; | 146 | UserData userData = (UserData) obj; |
| 143 | UserService userService = UserService.getInstance(getActivity()); | 147 | UserService userService = UserService.getInstance(getActivity()); |
| 144 | userService.setActiveAccountInfo(userData.getData()); | 148 | userService.setActiveAccountInfo(userData.getData()); |
| 149 | + } else if (i == IUserService.ERROR_TOKEN_INVALID) { | ||
| 150 | + UserService userService = UserService.getInstance(getActivity()); | ||
| 151 | + userService.clearUser(); | ||
| 152 | + getActivity().finish(); | ||
| 145 | } | 153 | } |
| 146 | } | 154 | } |
| 147 | }); | 155 | }); |
app/src/main/java/com/cnlive/gundam/user/fragment/UserPersonalFragment.java
| @@ -93,12 +93,17 @@ public class UserPersonalFragment extends Fragment implements DataBindingAdapter | @@ -93,12 +93,17 @@ public class UserPersonalFragment extends Fragment implements DataBindingAdapter | ||
| 93 | @Override | 93 | @Override |
| 94 | public void onResume() { | 94 | public void onResume() { |
| 95 | super.onResume(); | 95 | super.onResume(); |
| 96 | - initData(); | 96 | + UserService userService = UserService.getInstance(getActivity()); |
| 97 | + user = userService.getActiveAccountInfo(); | ||
| 98 | + if(user != null && user.getUid() > 0){ | ||
| 99 | + initData(); | ||
| 100 | + updateUserInfo(); | ||
| 101 | + }else{ | ||
| 102 | + getActivity().finish(); | ||
| 103 | + } | ||
| 97 | } | 104 | } |
| 98 | 105 | ||
| 99 | private void initData() { | 106 | private void initData() { |
| 100 | - UserService userService = UserService.getInstance(getActivity()); | ||
| 101 | - user = userService.getActiveAccountInfo(); | ||
| 102 | String gender = user.getGender().equals("f") ? "女" : (user.getGender().equals("m") ? "男" : "未知"); | 107 | String gender = user.getGender().equals("f") ? "女" : (user.getGender().equals("m") ? "男" : "未知"); |
| 103 | personalData = new ArrayList<>(); | 108 | personalData = new ArrayList<>(); |
| 104 | personalData.add(new PersonalData("头像", user.getFaceurl(), PersonalData.TYPE_HEADER)); | 109 | personalData.add(new PersonalData("头像", user.getFaceurl(), PersonalData.TYPE_HEADER)); |
| @@ -278,6 +283,10 @@ public class UserPersonalFragment extends Fragment implements DataBindingAdapter | @@ -278,6 +283,10 @@ public class UserPersonalFragment extends Fragment implements DataBindingAdapter | ||
| 278 | if (i == IUserService.SUCCESS) { | 283 | if (i == IUserService.SUCCESS) { |
| 279 | updateUserInfo(); | 284 | updateUserInfo(); |
| 280 | Toast.makeText(getActivity(), "提交成功", Toast.LENGTH_LONG).show(); | 285 | Toast.makeText(getActivity(), "提交成功", Toast.LENGTH_LONG).show(); |
| 286 | + } else if (i == IUserService.ERROR_TOKEN_INVALID) { | ||
| 287 | + UserService userService = UserService.getInstance(getActivity()); | ||
| 288 | + userService.clearUser(); | ||
| 289 | + getActivity().finish(); | ||
| 281 | } else { | 290 | } else { |
| 282 | Toast.makeText(getActivity(), "提交失败" + s, Toast.LENGTH_LONG).show(); | 291 | Toast.makeText(getActivity(), "提交失败" + s, Toast.LENGTH_LONG).show(); |
| 283 | } | 292 | } |
| @@ -291,7 +300,12 @@ public class UserPersonalFragment extends Fragment implements DataBindingAdapter | @@ -291,7 +300,12 @@ public class UserPersonalFragment extends Fragment implements DataBindingAdapter | ||
| 291 | UserData userData = (UserData) obj; | 300 | UserData userData = (UserData) obj; |
| 292 | UserService userService = UserService.getInstance(getActivity()); | 301 | UserService userService = UserService.getInstance(getActivity()); |
| 293 | userService.setActiveAccountInfo(userData.getData()); | 302 | userService.setActiveAccountInfo(userData.getData()); |
| 303 | + user = userService.getActiveAccountInfo(); | ||
| 294 | initData(); | 304 | initData(); |
| 305 | + } else if (i == IUserService.ERROR_TOKEN_INVALID) { | ||
| 306 | + UserService userService = UserService.getInstance(getActivity()); | ||
| 307 | + userService.clearUser(); | ||
| 308 | + getActivity().finish(); | ||
| 295 | } | 309 | } |
| 296 | } | 310 | } |
| 297 | }); | 311 | }); |
app/src/main/java/com/cnlive/gundam/video/fragment/PlayerLiveFragment.java
| @@ -18,6 +18,7 @@ import com.cnlive.gundam.video.model.VideoModel; | @@ -18,6 +18,7 @@ import com.cnlive.gundam.video.model.VideoModel; | ||
| 18 | import com.cnlive.gundam.video.utils.PlayerUtils; | 18 | import com.cnlive.gundam.video.utils.PlayerUtils; |
| 19 | import com.cnlive.gundam.video.view.PlayerAccelerometerSensor; | 19 | import com.cnlive.gundam.video.view.PlayerAccelerometerSensor; |
| 20 | import com.cnlive.gundam.video.view.PlayerControllerView; | 20 | import com.cnlive.gundam.video.view.PlayerControllerView; |
| 21 | +import com.cnlive.libs.util.ProbeUtil; | ||
| 21 | 22 | ||
| 22 | /** | 23 | /** |
| 23 | * Created by gujun on 2017/6/27. | 24 | * Created by gujun on 2017/6/27. |
| @@ -66,6 +67,7 @@ public class PlayerLiveFragment extends Fragment implements PlayerAccelerometerS | @@ -66,6 +67,7 @@ public class PlayerLiveFragment extends Fragment implements PlayerAccelerometerS | ||
| 66 | if (program == null) return; | 67 | if (program == null) return; |
| 67 | VideoModel model = new VideoModel(program.getTitle(), program.getChannelId(), program.getType(), program.getRates()); | 68 | VideoModel model = new VideoModel(program.getTitle(), program.getChannelId(), program.getType(), program.getRates()); |
| 68 | binding.videoView.setVideoInfo(model); | 69 | binding.videoView.setVideoInfo(model); |
| 70 | + ProbeUtil.probeSDK("pgcLiveCount"); | ||
| 69 | } | 71 | } |
| 70 | 72 | ||
| 71 | @Override | 73 | @Override |
| @@ -88,6 +90,8 @@ public class PlayerLiveFragment extends Fragment implements PlayerAccelerometerS | @@ -88,6 +90,8 @@ public class PlayerLiveFragment extends Fragment implements PlayerAccelerometerS | ||
| 88 | super.onPause(); | 90 | super.onPause(); |
| 89 | binding.videoView.onPause(); | 91 | binding.videoView.onPause(); |
| 90 | playerAccelerometerSensor.unregister(); | 92 | playerAccelerometerSensor.unregister(); |
| 93 | + | ||
| 94 | + | ||
| 91 | } | 95 | } |
| 92 | 96 | ||
| 93 | @Override | 97 | @Override |
app/src/main/java/com/cnlive/gundam/video/fragment/PlayerVodFragment.java
| @@ -17,6 +17,7 @@ import com.cnlive.gundam.video.fragment.chat.CommentFragment; | @@ -17,6 +17,7 @@ import com.cnlive.gundam.video.fragment.chat.CommentFragment; | ||
| 17 | import com.cnlive.gundam.video.model.VideoModel; | 17 | import com.cnlive.gundam.video.model.VideoModel; |
| 18 | import com.cnlive.gundam.video.utils.PlayerUtils; | 18 | import com.cnlive.gundam.video.utils.PlayerUtils; |
| 19 | import com.cnlive.gundam.video.view.PlayerAccelerometerSensor; | 19 | import com.cnlive.gundam.video.view.PlayerAccelerometerSensor; |
| 20 | +import com.cnlive.libs.util.ProbeUtil; | ||
| 20 | 21 | ||
| 21 | /** | 22 | /** |
| 22 | * Created by gujun on 2017/4/6. | 23 | * Created by gujun on 2017/4/6. |
| @@ -61,6 +62,7 @@ public class PlayerVodFragment extends Fragment implements PlayerAccelerometerSe | @@ -61,6 +62,7 @@ public class PlayerVodFragment extends Fragment implements PlayerAccelerometerSe | ||
| 61 | program = (VideoListProgram) getArguments().getSerializable("program"); | 62 | program = (VideoListProgram) getArguments().getSerializable("program"); |
| 62 | if (program == null) return; | 63 | if (program == null) return; |
| 63 | VideoModel videoModel = new VideoModel(program.getTitle(), program.getvId(), program.getType(), program.getRates()); | 64 | VideoModel videoModel = new VideoModel(program.getTitle(), program.getvId(), program.getType(), program.getRates()); |
| 65 | + ProbeUtil.probeSDK("pgcVodCount");//点播播放数量统计 | ||
| 64 | binding.videoView.setVideoInfo(videoModel); | 66 | binding.videoView.setVideoInfo(videoModel); |
| 65 | } | 67 | } |
| 66 | 68 |
app/src/main/java/com/cnlive/gundam/video/view/BaseVideoView.java
| @@ -16,6 +16,7 @@ import com.cnlive.gundam.databinding.LayoutVideoViewBinding; | @@ -16,6 +16,7 @@ import com.cnlive.gundam.databinding.LayoutVideoViewBinding; | ||
| 16 | import com.cnlive.gundam.video.model.DataSource; | 16 | import com.cnlive.gundam.video.model.DataSource; |
| 17 | import com.cnlive.gundam.video.model.VideoModel; | 17 | import com.cnlive.gundam.video.model.VideoModel; |
| 18 | import com.cnlive.libs.util.Config; | 18 | import com.cnlive.libs.util.Config; |
| 19 | +import com.cnlive.libs.util.ProbeUtil; | ||
| 19 | import com.cnlive.libs.util.SharedPreferencesHelper; | 20 | import com.cnlive.libs.util.SharedPreferencesHelper; |
| 20 | import com.cnlive.libs.video.video.VideoStatusUtil; | 21 | import com.cnlive.libs.video.video.VideoStatusUtil; |
| 21 | import com.cnlive.libs.video.video.base.IMediaPlayer; | 22 | import com.cnlive.libs.video.video.base.IMediaPlayer; |
| @@ -170,9 +171,13 @@ public abstract class BaseVideoView extends RelativeLayout implements | @@ -170,9 +171,13 @@ public abstract class BaseVideoView extends RelativeLayout implements | ||
| 170 | 171 | ||
| 171 | public void onDestroy() { | 172 | public void onDestroy() { |
| 172 | binding.videoView.releaseSwitchVideo(); | 173 | binding.videoView.releaseSwitchVideo(); |
| 174 | + boolean playing = binding.videoView.isPlaying(); | ||
| 175 | + if(playing){setPlayState(false);} | ||
| 173 | binding.videoView.release(); | 176 | binding.videoView.release(); |
| 174 | VideoStatusUtil.quit(); | 177 | VideoStatusUtil.quit(); |
| 175 | saveCurPlayPosition(); | 178 | saveCurPlayPosition(); |
| 179 | + | ||
| 180 | + | ||
| 176 | } | 181 | } |
| 177 | 182 | ||
| 178 | //保存当前播放视频的播放进度 | 183 | //保存当前播放视频的播放进度 |
| @@ -197,8 +202,44 @@ public abstract class BaseVideoView extends RelativeLayout implements | @@ -197,8 +202,44 @@ public abstract class BaseVideoView extends RelativeLayout implements | ||
| 197 | * @param isPlay | 202 | * @param isPlay |
| 198 | */ | 203 | */ |
| 199 | protected void setPlayState(boolean isPlay) { | 204 | protected void setPlayState(boolean isPlay) { |
| 200 | - if (isPlay) binding.videoView.start(); | ||
| 201 | - else binding.videoView.pause(); | 205 | + if (isPlay) { |
| 206 | + if (videoModel.getType().equals(VideoView.TYPE_UGC_LIVE)) { | ||
| 207 | + ProbeUtil.probeSDK("ugcLiveStart"); | ||
| 208 | + | ||
| 209 | + Log.v("TestDemo","ugcLiveStart"); | ||
| 210 | + | ||
| 211 | + } else if (videoModel.getType().equals(VideoView.TYPE_LIVE)) { | ||
| 212 | + ProbeUtil.probeSDK("pgcLiveStart"); | ||
| 213 | + | ||
| 214 | + Log.v("TestDemo","pgcLiveStart"); | ||
| 215 | + | ||
| 216 | + } else if (videoModel.getType().equals(VideoView.TYPE_UGC_VOD)) { | ||
| 217 | + ProbeUtil.probeSDK("ugcVodStart"); | ||
| 218 | + | ||
| 219 | + Log.v("TestDemo","ugcVodStart"); | ||
| 220 | + | ||
| 221 | + } | ||
| 222 | + binding.videoView.start(); | ||
| 223 | + } else { | ||
| 224 | + if (videoModel.getType().equals(VideoView.TYPE_UGC_LIVE)) { | ||
| 225 | + ProbeUtil.probeSDK("ugcLiveEnd"); | ||
| 226 | + | ||
| 227 | + Log.v("TestDemo","ugcLiveEnd"); | ||
| 228 | + | ||
| 229 | + } else if (videoModel.getType().equals(VideoView.TYPE_LIVE)) { | ||
| 230 | + ProbeUtil.probeSDK("pgcLiveEnd"); | ||
| 231 | + | ||
| 232 | + Log.v("TestDemo","pgcLiveEnd"); | ||
| 233 | + | ||
| 234 | + } else if (videoModel.getType().equals(VideoView.TYPE_UGC_VOD)) { | ||
| 235 | + ProbeUtil.probeSDK("ugcVodEnd"); | ||
| 236 | + | ||
| 237 | + Log.v("TestDemo","ugcVodEnd"); | ||
| 238 | + | ||
| 239 | + } | ||
| 240 | + binding.videoView.pause(); | ||
| 241 | + } | ||
| 242 | + | ||
| 202 | } | 243 | } |
| 203 | 244 | ||
| 204 | /** | 245 | /** |
| @@ -229,6 +270,7 @@ public abstract class BaseVideoView extends RelativeLayout implements | @@ -229,6 +270,7 @@ public abstract class BaseVideoView extends RelativeLayout implements | ||
| 229 | @Override | 270 | @Override |
| 230 | public void onCompletion(IMediaPlayer iMediaPlayer) { | 271 | public void onCompletion(IMediaPlayer iMediaPlayer) { |
| 231 | isPlay = false; | 272 | isPlay = false; |
| 273 | + setPlayState(false); | ||
| 232 | } | 274 | } |
| 233 | 275 | ||
| 234 | @Override | 276 | @Override |