From 92ec8a304498f41d9bd57ba269d67ffeb18abff2 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Thu, 27 Oct 2022 16:52:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B4=BB=E5=8A=A8banner?= =?UTF-8?q?=E5=BF=AB=E9=80=9F=E7=82=B9=E5=87=BB=E4=BC=9A=E5=A4=9A=E6=AC=A1?= =?UTF-8?q?=E6=89=93=E5=BC=80=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../live/dialog/LiveGameDialogFragment.java | 12 +++- .../live/dialog/LiveHDDialogFragment.java | 25 +++++--- .../yunbao/live/views/LiveRoomViewHolder.java | 61 +++++++++++-------- 3 files changed, 64 insertions(+), 34 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGameDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveGameDialogFragment.java index ba89264fd..1b9508d79 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGameDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGameDialogFragment.java @@ -4,6 +4,7 @@ import static com.yunbao.common.CommonAppContext.logger; import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics; import static com.yunbao.common.utils.RouteUtil.PATH_COIN; +import android.content.DialogInterface; import android.content.Intent; import android.graphics.Color; import android.os.Build; @@ -69,6 +70,7 @@ public class LiveGameDialogFragment extends AbsDialogFragment { private int activityId = -1; private LinearLayout layout; private boolean isFullWindow = false; + private DialogInterface.OnShowListener listener; public LiveGameDialogFragment() { @@ -89,6 +91,10 @@ public class LiveGameDialogFragment extends AbsDialogFragment { this.activityId = activityId; } + public void setShowListener(DialogInterface.OnShowListener listener) { + this.listener = listener; + } + @Override protected int getLayoutId() { return R.layout.dialog_live_game; @@ -167,6 +173,9 @@ public class LiveGameDialogFragment extends AbsDialogFragment { @Override public void onPageFinished(WebView view, String url) { // view.loadUrl("javascript:window.androidObject.setHeight(document.body.clientHeight,document.body.clientWidth)"); + if (listener != null) { + listener.onShow(LiveGameDialogFragment.this.getDialog()); + } } }); initData(); @@ -224,7 +233,7 @@ public class LiveGameDialogFragment extends AbsDialogFragment { for (int i = 0; i < count; i++) { ActiveModel model = (ActiveModel) tabLayout.getTabAt(i).getTag(); if ((activityId + "").equals(model.getActiveId())) { - tabIndex=i; + tabIndex = i; return; } } @@ -270,6 +279,7 @@ public class LiveGameDialogFragment extends AbsDialogFragment { this.roomId = roomId; } + //js调用原生 public class JsInteration { @JavascriptInterface diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java index 50b1a75e9..00144c420 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java @@ -4,6 +4,7 @@ import static com.yunbao.common.CommonAppContext.logger; import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics; import static com.yunbao.common.utils.RouteUtil.PATH_COIN; +import android.content.DialogInterface; import android.content.Intent; import android.graphics.Color; import android.os.Build; @@ -57,6 +58,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment { private int showType = 0; private boolean isFullWindow = false; private String roomId; + private DialogInterface.OnShowListener listener; public LiveHDDialogFragment() { @@ -86,6 +88,10 @@ public class LiveHDDialogFragment extends AbsDialogFragment { return true; } + public void setShowListener(DialogInterface.OnShowListener listener) { + this.listener = listener; + } + @Override protected void setWindowAttributes(Window window) { @@ -172,6 +178,9 @@ public class LiveHDDialogFragment extends AbsDialogFragment { @Override public void onPageFinished(WebView view, String url) { view.loadUrl("javascript:window.androidObject.setHeight(document.body.clientHeight,document.body.clientWidth)"); + if (listener != null) { + listener.onShow(LiveHDDialogFragment.this.getDialog()); + } } }); if (bundle.getBoolean("banScrollY", false)) { @@ -280,12 +289,12 @@ public class LiveHDDialogFragment extends AbsDialogFragment { @JavascriptInterface public void androidSignGift(String json) { - JSONObject data=JSONObject.parseObject(json); - if(data!=null) { - // 恭喜您第一天簽到成功! + JSONObject data = JSONObject.parseObject(json); + if (data != null) { + // 恭喜您第一天簽到成功! ((LiveAudienceActivity) mContext).openSignWindow(data.getString("icon"), data.getString("name"), - "恭喜您" +data.getString("desc")+"簽到成功!" + "恭喜您" + data.getString("desc") + "簽到成功!" ); } @@ -294,13 +303,13 @@ public class LiveHDDialogFragment extends AbsDialogFragment { @JavascriptInterface public void setHeight(String height, String width) { - if("0".equals(height)){ + if ("0".equals(height)) { return; } - Handler handler=new Handler(Looper.getMainLooper()); - handler.post(()->{ + Handler handler = new Handler(Looper.getMainLooper()); + handler.post(() -> { ViewGroup.LayoutParams params = mWebView.getLayoutParams(); - params.height=DpUtil.dp2px(Integer.parseInt(height)); + params.height = DpUtil.dp2px(Integer.parseInt(height)); mWebView.setLayoutParams(params); mWebView.setVisibility(View.VISIBLE); }); diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index 35a5f4552..7923e52c1 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -7,10 +7,12 @@ import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY; import android.app.Activity; import android.app.Dialog; import android.content.Context; +import android.content.DialogInterface; import android.graphics.Outline; import android.os.Bundle; import android.os.CountDownTimer; import android.os.Handler; +import android.os.Looper; import android.os.Message; import android.os.SystemClock; import android.text.TextUtils; @@ -3002,28 +3004,34 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public void onBannerClick(List datas, int p) { Log.i("debug", "onBannerClick: " + mBannerList4.get(p).toString()); BannerBean bean = mBannerList4.get(p); - loadingDialog = DialogUitl.loadingDialog(mContext); - loadingDialog.show(); - if (bean.getActivityId() == -1) {//-1写死跳活动弹窗 - Bus.get().post(new LiveAudienceEvent() - .setActivity(true) - .setType(LiveAudienceEvent.LiveAudienceType.BOTTOM_COLLECTION)); - if (loadingDialog != null && loadingDialog.isShowing()) { - loadingDialog.dismiss(); - loadingDialog = null; - } - } else if (bean.getActivityId() == 0) { - openWebDialog(bean.getLink()); - } else { - LiveGameDialogFragment fragment = new LiveGameDialogFragment("1".equals(bean.getShow_type())); - fragment.setActivityId(bean.getActivityId()); - fragment.setRoomId(mLiveUid); - fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGameDialogFragment"); - if (loadingDialog != null && loadingDialog.isShowing()) { - loadingDialog.dismiss(); - loadingDialog = null; - } + if (loadingDialog == null) { + loadingDialog = DialogUitl.loadingDialog(mContext, WordUtil.getString(R.string.login_wait)); } + loadingDialog.setOnShowListener(dialog -> { + if (bean.getActivityId() == -1) {//-1写死跳活动弹窗 + Bus.get().post(new LiveAudienceEvent() + .setActivity(true) + .setType(LiveAudienceEvent.LiveAudienceType.BOTTOM_COLLECTION)); + new Handler(Looper.getMainLooper()).postDelayed(() -> { + loadingDialog.dismiss(); + loadingDialog = null; + }, 300); + } else if (bean.getActivityId() == 0) { + openWebDialog(bean.getLink()); + } else { + LiveGameDialogFragment fragment = new LiveGameDialogFragment("1".equals(bean.getShow_type())); + fragment.setActivityId(bean.getActivityId()); + fragment.setRoomId(mLiveUid); + fragment.setShowListener(dialog1 -> { + new Handler(Looper.getMainLooper()).postDelayed(() -> { + loadingDialog.dismiss(); + loadingDialog = null; + }, 300); + }); + fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGameDialogFragment"); + } + }); + loadingDialog.show(); } @@ -3047,11 +3055,14 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis bundle1.putString("url", url); LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment(); liveHDDialogFragment.setArguments(bundle1); + liveHDDialogFragment.setShowListener(dialog1 -> { + new Handler(Looper.getMainLooper()).postDelayed(() -> { + loadingDialog.dismiss(); + loadingDialog = null; + }, 300); + }); liveHDDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); - if (loadingDialog != null && loadingDialog.isShowing()) { - loadingDialog.dismiss(); - loadingDialog = null; - } + } }) .start();