diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index 5380d1a38..032e75500 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -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) { diff --git a/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityFragment.java b/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityFragment.java index 96ed6cfd6..ae5f07953 100644 --- a/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityFragment.java +++ b/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityFragment.java @@ -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() { - @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() { - @Override - public void onReceiveValue(String value) { - } - }); - - } - }); - } - - } - })).show(); - } - - @Override - public void onError(String error) { - ToastUtil.show(error); - } - }); } } } diff --git a/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityVideoFragment.java b/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityVideoFragment.java index 2730f6146..0727bf0ca 100644 --- a/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityVideoFragment.java +++ b/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityVideoFragment.java @@ -197,4 +197,10 @@ public class MainHomeCommunityVideoFragment extends BaseFragment { }); } } + public void onPausePlay(){ + mWebView.onPause(); + } + public void onResumePlay(){ + mWebView.onResume(); + } } diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java index 369a2edd9..6145f2eab 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeCommunityViewHolder.java @@ -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) {