修复切到其他页面后短剧不会暂停播放的问题

修复短剧购买卷重复弹出对话框问题
This commit is contained in:
zlzw 2024-01-09 17:31:13 +08:00
parent df0d9795ed
commit d629ee3f9f
4 changed files with 44 additions and 53 deletions

View File

@ -329,15 +329,27 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
case 0:
//点击埋点
MobclickAgent.onEvent(mContext, "home_page", "首页");
if(mMainHomeCommunityViewHolder!=null) {
mMainHomeCommunityViewHolder.onPauseVideo();
}
break;
case 1:
MobclickAgent.onEvent(mContext, "community", "社区");
if(mMainHomeCommunityViewHolder!=null) {
mMainHomeCommunityViewHolder.onResumePlay();
}
break;
case 2:
MobclickAgent.onEvent(mContext, "information", "消息");
if(mMainHomeCommunityViewHolder!=null) {
mMainHomeCommunityViewHolder.onPauseVideo();
}
break;
case 3:
MobclickAgent.onEvent(mContext, "my", "我的");
if(mMainHomeCommunityViewHolder!=null) {
mMainHomeCommunityViewHolder.onPauseVideo();
}
break;
}
if (mTabButtonGroup.getCurPosition() != position) {

View File

@ -378,59 +378,6 @@ public class MainHomeCommunityFragment extends BaseFragment {
.setShareLink(CommonAppConfig.HOST + json.getString("link"))
.setAnchorAvatar(json.getString("avatar"))
.showDialog();
} else if (TextUtils.equals(event.getMethod(), "postWeakBalance")) {
LiveNetManager.get(mContext).
getCoolConfig(new com.yunbao.common.http.base.HttpCallback<CoolConfig>() {
@Override
public void onSuccess(CoolConfig data) {
new XPopup.Builder(mContext)
.enableDrag(false)
.autoOpenSoftInput(false)
.maxWidth(DeviceUtils.getScreenHeight((Activity) mContext) - DpUtil.dp2px(34))
.asCustom(new CinemaTicketPopupWindow(mContext, data.setTicketCount(event.getCoolConfig().getTicketCount()), new CinemaTicketPopupWindow.CinemaTicketPopupWindowCallBack() {
@Override
public void onCallBack(String data) {
if (TextUtils.equals(data, "2")) {
DialogUitl.showSimpleDialog(mContext, mContext.getString(com.yunbao.live.R.string.live_coin_not_enough), false,
new DialogUitl.SimpleCallback2() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
mContext.startActivity(new Intent(mContext, MyWalletActivity.class).putExtra("p", 1));
}
@Override
public void onCancelClick() {
}
});
} else if (TextUtils.equals(data, "1")) {
ToastUtil.show(WordUtil.isNewZh() ? "兑换成功" : "Successful exchange");
mWebView.post(new Runnable() {
@Override
public void run() {
NativeCallbackModel model = new NativeCallbackModel();
model.setUid(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
String nativeJson = new JsonUtil().toJson(model);
mWebView.evaluateJavascript("javascript:nativeCallback('" + nativeJson + "')", new ValueCallback<String>() {
@Override
public void onReceiveValue(String value) {
}
});
}
});
}
}
})).show();
}
@Override
public void onError(String error) {
ToastUtil.show(error);
}
});
}
}
}

View File

@ -197,4 +197,10 @@ public class MainHomeCommunityVideoFragment extends BaseFragment {
});
}
}
public void onPausePlay(){
mWebView.onPause();
}
public void onResumePlay(){
mWebView.onResume();
}
}

View File

@ -224,6 +224,32 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
public void loadNewUrl() {
}
public void onPauseVideo() {
if(fragments==null || fragments.isEmpty()){
return;
}
BaseFragment fragment = fragments.get(viewPager.getCurrentItem());
if(fragment==null){
return;
}
if (fragment instanceof MainHomeCommunityVideoFragment) {
// viewPager.setCurrentItem(0, false);
((MainHomeCommunityVideoFragment)fragment).onPausePlay();
}
}
public void onResumePlay() {
if(fragments==null || fragments.isEmpty()){
return;
}
BaseFragment fragment = fragments.get(viewPager.getCurrentItem());
if(fragment==null){
return;
}
if (fragment instanceof MainHomeCommunityVideoFragment) {
// viewPager.setCurrentItem(0, false);
((MainHomeCommunityVideoFragment)fragment).onResumePlay();
}
}
@Override
public void onItemClick(LiveBean bean, int position) {