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 | 3 | android { |
| 4 | 4 | compileSdkVersion 26 |
| 5 | 5 | buildToolsVersion "26.0.0" |
| 6 | + | |
| 7 | + dexOptions { | |
| 8 | + javaMaxHeapSize "4g" | |
| 9 | + } | |
| 10 | + | |
| 6 | 11 | defaultConfig { |
| 7 | 12 | applicationId "com.cnlive.gundam" |
| 8 | 13 | minSdkVersion 16 |
| ... | ... | @@ -17,25 +22,38 @@ android { |
| 17 | 22 | } |
| 18 | 23 | |
| 19 | 24 | signingConfigs { |
| 25 | + Properties props = new Properties(); | |
| 26 | + props.load(new FileInputStream(rootProject.file('signing.properties'))) | |
| 20 | 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 | 36 | buildTypes { |
| 29 | 37 | debug { |
| 38 | + applicationIdSuffix ".debug" | |
| 30 | 39 | signingConfig signingConfigs.myConfig |
| 40 | + zipAlignEnabled true | |
| 31 | 41 | } |
| 32 | 42 | release { |
| 33 | 43 | minifyEnabled false |
| 34 | 44 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 35 | 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 | 57 | useLibrary 'org.apache.http.legacy' |
| 40 | 58 | } |
| 41 | 59 | |
| ... | ... | @@ -52,8 +70,11 @@ dependencies { |
| 52 | 70 | compile 'com.android.support.constraint:constraint-layout:1.0.2' |
| 53 | 71 | compile 'com.github.bumptech.glide:glide:3.7.0' |
| 54 | 72 | compile 'org.greenrobot:eventbus:3.0.0' |
| 73 | + | |
| 74 | + //Retrofit | |
| 55 | 75 | compile 'com.squareup.retrofit2:retrofit:2.0.2' |
| 56 | 76 | compile 'com.squareup.retrofit2:converter-gson:2.0.2' |
| 77 | + //OKhttp | |
| 57 | 78 | compile 'com.squareup.okhttp3:okhttp:3.2.0' |
| 58 | 79 | compile 'com.squareup.okhttp3:okhttp-ws:3.2.0' |
| 59 | 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 | 4 | |
| 5 | 5 | import com.cnlive.gundam.data.network.RetrofitUtil; |
| 6 | 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 | 8 | import com.cnlive.gundam.stream.model.ChannelInfoModel; |
| 9 | 9 | import com.cnlive.libs.util.Config; |
| 10 | 10 | |
| 11 | -import java.lang.ref.WeakReference; | |
| 12 | 11 | import java.util.HashMap; |
| 13 | 12 | import java.util.Map; |
| 14 | 13 | |
| ... | ... | @@ -22,14 +21,14 @@ import retrofit2.Response; |
| 22 | 21 | |
| 23 | 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 | 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 | 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 | 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 | 18 | \ No newline at end of file | ... | ... |
app/src/main/java/com/cnlive/gundam/main/ui/activity/MainActivity.java
| 1 | 1 | package com.cnlive.gundam.main.ui.activity; |
| 2 | 2 | |
| 3 | -import android.app.AlertDialog; | |
| 4 | -import android.content.DialogInterface; | |
| 5 | 3 | import android.content.Intent; |
| 6 | 4 | import android.databinding.DataBindingUtil; |
| 7 | 5 | import android.os.Bundle; |
| 8 | 6 | import android.support.v7.app.AppCompatActivity; |
| 9 | -import android.widget.Toast; | |
| 7 | +import android.util.Log; | |
| 10 | 8 | |
| 11 | 9 | import com.cnlive.gundam.R; |
| 12 | 10 | import com.cnlive.gundam.databinding.ActivityMainBinding; |
| ... | ... | @@ -18,14 +16,12 @@ import com.cnlive.gundam.main.ui.fragment.LiveFragment; |
| 18 | 16 | import com.cnlive.gundam.main.ui.fragment.UGCListFragment; |
| 19 | 17 | import com.cnlive.gundam.main.ui.widget.FragmentTabHost; |
| 20 | 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 | 19 | import com.cnlive.gundam.stream.util.FileUtil; |
| 24 | 20 | import com.cnlive.gundam.user.activity.LoginActivity; |
| 25 | 21 | import com.cnlive.gundam.user.auth.UserService; |
| 26 | 22 | import com.cnlive.gundam.user.model.User; |
| 27 | 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 | 26 | import java.util.Arrays; |
| 31 | 27 | |
| ... | ... | @@ -33,7 +29,7 @@ import java.util.Arrays; |
| 33 | 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 | 34 | private AnchorInfoPresenter mAnchorInfoPresenter; |
| 39 | 35 | |
| ... | ... | @@ -51,8 +47,10 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O |
| 51 | 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 | 55 | FileUtil.copyFile(this, "cnlive_logo.png"); |
| 58 | 56 | } |
| ... | ... | @@ -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 | 80 | @Override |
| 151 | 81 | protected void onDestroy() { |
| 152 | 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 | 18 | import com.cnlive.gundam.user.activity.UserPersonalActivity; |
| 19 | 19 | import com.cnlive.gundam.user.auth.UserService; |
| 20 | 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 | 27 | * Created by xiansong on 2017/6/27. |
| ... | ... | @@ -26,6 +29,7 @@ import com.cnlive.gundam.user.model.User; |
| 26 | 29 | |
| 27 | 30 | public class ConfigFragment extends Fragment implements View.OnClickListener { |
| 28 | 31 | private UserFragmentBinding binding; |
| 32 | + private User activeAccountInfo; | |
| 29 | 33 | |
| 30 | 34 | @Nullable |
| 31 | 35 | @Override |
| ... | ... | @@ -63,7 +67,7 @@ public class ConfigFragment extends Fragment implements View.OnClickListener { |
| 63 | 67 | if (uid != 0) { |
| 64 | 68 | //进入个人中心页面 |
| 65 | 69 | Intent intent = new Intent(getActivity(), UserPersonalActivity.class); |
| 66 | - intent.putExtra("isEdit", false); | |
| 70 | + intent.putExtra("isEdit",false); | |
| 67 | 71 | startActivity(intent); |
| 68 | 72 | } else { |
| 69 | 73 | //进入登录页面 |
| ... | ... | @@ -89,13 +93,30 @@ public class ConfigFragment extends Fragment implements View.OnClickListener { |
| 89 | 93 | } |
| 90 | 94 | |
| 91 | 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 | 100 | Glide.with(getActivity()).load(activeAccountInfo.getFaceurl()).into(binding.headImg); |
| 95 | 101 | binding.tvNickname.setText(activeAccountInfo.getNickname()); |
| 96 | - } else { | |
| 102 | + }else{ | |
| 97 | 103 | Glide.with(getActivity()).load(R.drawable.cnlive_user_header).into(binding.headImg); |
| 98 | 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 | 129 | if (i == IUserService.SUCCESS) { |
| 130 | 130 | updateUserInfo(); |
| 131 | 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 | 136 | } else { |
| 133 | 137 | Toast.makeText(getActivity(), "提交失败" + s, Toast.LENGTH_LONG).show(); |
| 134 | 138 | } |
| ... | ... | @@ -142,6 +146,10 @@ public class UserPersonalEditFragment extends Fragment implements Callback, View |
| 142 | 146 | UserData userData = (UserData) obj; |
| 143 | 147 | UserService userService = UserService.getInstance(getActivity()); |
| 144 | 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 | 93 | @Override |
| 94 | 94 | public void onResume() { |
| 95 | 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 | 106 | private void initData() { |
| 100 | - UserService userService = UserService.getInstance(getActivity()); | |
| 101 | - user = userService.getActiveAccountInfo(); | |
| 102 | 107 | String gender = user.getGender().equals("f") ? "女" : (user.getGender().equals("m") ? "男" : "未知"); |
| 103 | 108 | personalData = new ArrayList<>(); |
| 104 | 109 | personalData.add(new PersonalData("头像", user.getFaceurl(), PersonalData.TYPE_HEADER)); |
| ... | ... | @@ -278,6 +283,10 @@ public class UserPersonalFragment extends Fragment implements DataBindingAdapter |
| 278 | 283 | if (i == IUserService.SUCCESS) { |
| 279 | 284 | updateUserInfo(); |
| 280 | 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 | 290 | } else { |
| 282 | 291 | Toast.makeText(getActivity(), "提交失败" + s, Toast.LENGTH_LONG).show(); |
| 283 | 292 | } |
| ... | ... | @@ -291,7 +300,12 @@ public class UserPersonalFragment extends Fragment implements DataBindingAdapter |
| 291 | 300 | UserData userData = (UserData) obj; |
| 292 | 301 | UserService userService = UserService.getInstance(getActivity()); |
| 293 | 302 | userService.setActiveAccountInfo(userData.getData()); |
| 303 | + user = userService.getActiveAccountInfo(); | |
| 294 | 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 | 18 | import com.cnlive.gundam.video.utils.PlayerUtils; |
| 19 | 19 | import com.cnlive.gundam.video.view.PlayerAccelerometerSensor; |
| 20 | 20 | import com.cnlive.gundam.video.view.PlayerControllerView; |
| 21 | +import com.cnlive.libs.util.ProbeUtil; | |
| 21 | 22 | |
| 22 | 23 | /** |
| 23 | 24 | * Created by gujun on 2017/6/27. |
| ... | ... | @@ -66,6 +67,7 @@ public class PlayerLiveFragment extends Fragment implements PlayerAccelerometerS |
| 66 | 67 | if (program == null) return; |
| 67 | 68 | VideoModel model = new VideoModel(program.getTitle(), program.getChannelId(), program.getType(), program.getRates()); |
| 68 | 69 | binding.videoView.setVideoInfo(model); |
| 70 | + ProbeUtil.probeSDK("pgcLiveCount"); | |
| 69 | 71 | } |
| 70 | 72 | |
| 71 | 73 | @Override |
| ... | ... | @@ -88,6 +90,8 @@ public class PlayerLiveFragment extends Fragment implements PlayerAccelerometerS |
| 88 | 90 | super.onPause(); |
| 89 | 91 | binding.videoView.onPause(); |
| 90 | 92 | playerAccelerometerSensor.unregister(); |
| 93 | + | |
| 94 | + | |
| 91 | 95 | } |
| 92 | 96 | |
| 93 | 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 | 17 | import com.cnlive.gundam.video.model.VideoModel; |
| 18 | 18 | import com.cnlive.gundam.video.utils.PlayerUtils; |
| 19 | 19 | import com.cnlive.gundam.video.view.PlayerAccelerometerSensor; |
| 20 | +import com.cnlive.libs.util.ProbeUtil; | |
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Created by gujun on 2017/4/6. |
| ... | ... | @@ -61,6 +62,7 @@ public class PlayerVodFragment extends Fragment implements PlayerAccelerometerSe |
| 61 | 62 | program = (VideoListProgram) getArguments().getSerializable("program"); |
| 62 | 63 | if (program == null) return; |
| 63 | 64 | VideoModel videoModel = new VideoModel(program.getTitle(), program.getvId(), program.getType(), program.getRates()); |
| 65 | + ProbeUtil.probeSDK("pgcVodCount");//点播播放数量统计 | |
| 64 | 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 | 16 | import com.cnlive.gundam.video.model.DataSource; |
| 17 | 17 | import com.cnlive.gundam.video.model.VideoModel; |
| 18 | 18 | import com.cnlive.libs.util.Config; |
| 19 | +import com.cnlive.libs.util.ProbeUtil; | |
| 19 | 20 | import com.cnlive.libs.util.SharedPreferencesHelper; |
| 20 | 21 | import com.cnlive.libs.video.video.VideoStatusUtil; |
| 21 | 22 | import com.cnlive.libs.video.video.base.IMediaPlayer; |
| ... | ... | @@ -170,9 +171,13 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 170 | 171 | |
| 171 | 172 | public void onDestroy() { |
| 172 | 173 | binding.videoView.releaseSwitchVideo(); |
| 174 | + boolean playing = binding.videoView.isPlaying(); | |
| 175 | + if(playing){setPlayState(false);} | |
| 173 | 176 | binding.videoView.release(); |
| 174 | 177 | VideoStatusUtil.quit(); |
| 175 | 178 | saveCurPlayPosition(); |
| 179 | + | |
| 180 | + | |
| 176 | 181 | } |
| 177 | 182 | |
| 178 | 183 | //保存当前播放视频的播放进度 |
| ... | ... | @@ -197,8 +202,44 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 197 | 202 | * @param isPlay |
| 198 | 203 | */ |
| 199 | 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 | 270 | @Override |
| 230 | 271 | public void onCompletion(IMediaPlayer iMediaPlayer) { |
| 231 | 272 | isPlay = false; |
| 273 | + setPlayState(false); | |
| 232 | 274 | } |
| 233 | 275 | |
| 234 | 276 | @Override | ... | ... |