Commit ecc0701522a7996f582426b83566d17e92241d52
1 parent
86217543
解决直播没有数据
Showing
4 changed files
with
48 additions
and
6 deletions
app/src/main/java/com/cnlive/gundam/main/presenter/AnchorInfoPresenter.java
| ... | ... | @@ -8,7 +8,6 @@ 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<IAnchorInfoView> viewRef; | |
| 24 | + private IAnchorInfoView view; | |
| 26 | 25 | |
| 27 | 26 | public AnchorInfoPresenter(IAnchorInfoView view) { |
| 28 | - viewRef = new WeakReference<>(view); | |
| 27 | + this.view = view; | |
| 29 | 28 | } |
| 30 | 29 | |
| 31 | 30 | private IAnchorInfoView getView(){ |
| 32 | - return viewRef == null ? null : viewRef.get(); | |
| 31 | + return view; | |
| 33 | 32 | } |
| 34 | 33 | /** |
| 35 | 34 | * 查询主播信息 | ... | ... |
app/src/main/java/com/cnlive/gundam/main/ui/activity/MainActivity.java
| ... | ... | @@ -4,6 +4,7 @@ import android.content.Intent; |
| 4 | 4 | import android.databinding.DataBindingUtil; |
| 5 | 5 | import android.os.Bundle; |
| 6 | 6 | import android.support.v7.app.AppCompatActivity; |
| 7 | +import android.util.Log; | |
| 7 | 8 | |
| 8 | 9 | import com.cnlive.gundam.R; |
| 9 | 10 | import com.cnlive.gundam.databinding.ActivityMainBinding; |
| ... | ... | @@ -20,6 +21,7 @@ import com.cnlive.gundam.user.activity.LoginActivity; |
| 20 | 21 | import com.cnlive.gundam.user.auth.UserService; |
| 21 | 22 | import com.cnlive.gundam.user.model.User; |
| 22 | 23 | import com.cnlive.gundam.video.view.VideoView; |
| 24 | +import com.cnlive.libs.util.ProbeUtil; | |
| 23 | 25 | |
| 24 | 26 | import java.util.Arrays; |
| 25 | 27 | |
| ... | ... | @@ -46,7 +48,9 @@ public class MainActivity extends AppCompatActivity implements FragmentTabHost.O |
| 46 | 48 | )); |
| 47 | 49 | |
| 48 | 50 | mAnchorInfoPresenter = new AnchorInfoPresenter(new AnchorInfoView(this)); |
| 51 | + ProbeUtil.probeSDK("statup"); | |
| 49 | 52 | |
| 53 | + Log.d("MainActivity", "onCreate:"); | |
| 50 | 54 | //加载水印图片 |
| 51 | 55 | FileUtil.copyFile(this, "cnlive_logo.png"); |
| 52 | 56 | } | ... | ... |
app/src/main/java/com/cnlive/gundam/main/ui/fragment/ConfigFragment.java
| ... | ... | @@ -17,7 +17,10 @@ import com.cnlive.gundam.user.activity.LoginActivity; |
| 17 | 17 | import com.cnlive.gundam.user.activity.UserPersonalActivity; |
| 18 | 18 | import com.cnlive.gundam.user.auth.UserService; |
| 19 | 19 | import com.cnlive.gundam.user.model.User; |
| 20 | - | |
| 20 | +import com.cnlive.libs.user.IUserService; | |
| 21 | +import com.cnlive.libs.user.UserUtil; | |
| 22 | +import com.cnlive.libs.user.model.UserData; | |
| 23 | +import com.cnlive.libs.util.data.network.Callback; | |
| 21 | 24 | |
| 22 | 25 | |
| 23 | 26 | /** |
| ... | ... | @@ -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 |
| ... | ... | @@ -86,7 +90,9 @@ public class ConfigFragment extends Fragment implements View.OnClickListener { |
| 86 | 90 | |
| 87 | 91 | private void notifyUI(boolean isLogin) { |
| 88 | 92 | if(isLogin){ |
| 89 | - User activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo(); | |
| 93 | + activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo(); | |
| 94 | + updateUserInfo(activeAccountInfo); | |
| 95 | + activeAccountInfo = UserService.getInstance(getActivity()).getActiveAccountInfo(); | |
| 90 | 96 | Glide.with(getActivity()).load(activeAccountInfo.getFaceurl()).into(binding.headImg); |
| 91 | 97 | binding.tvNickname.setText(activeAccountInfo.getNickname()); |
| 92 | 98 | }else{ |
| ... | ... | @@ -94,4 +100,19 @@ public class ConfigFragment extends Fragment implements View.OnClickListener { |
| 94 | 100 | binding.tvNickname.setText(getString(R.string.click_login)); |
| 95 | 101 | } |
| 96 | 102 | } |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + private void updateUserInfo(User user) { | |
| 107 | + UserUtil.queryUserInfo(String.valueOf(user.getUid()), String.valueOf(user.getUid()), new Callback() { | |
| 108 | + @Override | |
| 109 | + public void onState(int i, String s, Object obj) { | |
| 110 | + if (i == IUserService.SUCCESS) { | |
| 111 | + UserData userData = (UserData) obj; | |
| 112 | + UserService userService = UserService.getInstance(getActivity()); | |
| 113 | + userService.setActiveAccountInfo(userData.getData()); | |
| 114 | + } | |
| 115 | + } | |
| 116 | + }); | |
| 117 | + } | |
| 97 | 118 | } | ... | ... |
app/src/main/java/com/cnlive/gundam/video/view/BaseVideoView.java
| ... | ... | @@ -205,19 +205,37 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 205 | 205 | if (isPlay) { |
| 206 | 206 | if (videoModel.getType().equals(VideoView.TYPE_UGC_LIVE)) { |
| 207 | 207 | ProbeUtil.probeSDK("ugcLiveStart"); |
| 208 | + | |
| 209 | + Log.v("TestDemo","ugcLiveStart"); | |
| 210 | + | |
| 208 | 211 | } else if (videoModel.getType().equals(VideoView.TYPE_LIVE)) { |
| 209 | 212 | ProbeUtil.probeSDK("pgcLiveStart"); |
| 213 | + | |
| 214 | + Log.v("TestDemo","pgcLiveStart"); | |
| 215 | + | |
| 210 | 216 | } else if (videoModel.getType().equals(VideoView.TYPE_UGC_VOD)) { |
| 211 | 217 | ProbeUtil.probeSDK("ugcVodStart"); |
| 218 | + | |
| 219 | + Log.v("TestDemo","ugcVodStart"); | |
| 220 | + | |
| 212 | 221 | } |
| 213 | 222 | binding.videoView.start(); |
| 214 | 223 | } else { |
| 215 | 224 | if (videoModel.getType().equals(VideoView.TYPE_UGC_LIVE)) { |
| 216 | 225 | ProbeUtil.probeSDK("ugcLiveEnd"); |
| 226 | + | |
| 227 | + Log.v("TestDemo","ugcLiveEnd"); | |
| 228 | + | |
| 217 | 229 | } else if (videoModel.getType().equals(VideoView.TYPE_LIVE)) { |
| 218 | 230 | ProbeUtil.probeSDK("pgcLiveEnd"); |
| 231 | + | |
| 232 | + Log.v("TestDemo","pgcLiveEnd"); | |
| 233 | + | |
| 219 | 234 | } else if (videoModel.getType().equals(VideoView.TYPE_UGC_VOD)) { |
| 220 | 235 | ProbeUtil.probeSDK("ugcVodEnd"); |
| 236 | + | |
| 237 | + Log.v("TestDemo","ugcVodEnd"); | |
| 238 | + | |
| 221 | 239 | } |
| 222 | 240 | binding.videoView.pause(); |
| 223 | 241 | } | ... | ... |