From fd15428ed94e93a1e6dadbd46db700a25acb2747 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Thu, 6 Apr 2023 10:34:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=BB=E6=92=AD=E8=81=94?= =?UTF-8?q?=E7=B3=BB=E6=96=B9=E5=BC=8F=E8=AF=A6=E6=83=85=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...LiveUserAnchorMailBoxWebInfoPopDialog.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserAnchorMailBoxWebInfoPopDialog.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserAnchorMailBoxWebInfoPopDialog.java index 143eaed8d..807d50fa5 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveUserAnchorMailBoxWebInfoPopDialog.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserAnchorMailBoxWebInfoPopDialog.java @@ -10,13 +10,19 @@ import android.widget.TextView; import androidx.annotation.NonNull; import com.lxj.xpopup.XPopup; +import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppContext; import com.yunbao.common.dialog.AbsDialogPopupWindow; +import com.yunbao.common.event.JavascriptInterfaceEvent; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.JavascriptInterfaceUtils; import com.yunbao.common.utils.L; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + public class LiveUserAnchorMailBoxWebInfoPopDialog extends AbsDialogPopupWindow { WebView mWebView; TextView textView; @@ -47,10 +53,13 @@ public class LiveUserAnchorMailBoxWebInfoPopDialog extends AbsDialogPopupWindow @Override protected void onCreate() { super.onCreate(); - mWebView=findViewById(R.id.webView); - textView=findViewById(R.id.title); - textView.setText(String.format(WordUtil.getString(R.string.live_user_mailbox_web_title),anchorName)); - mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(CommonAppContext.getTopActivity(),mWebView),"androidObject"); + Bus.getOn(this); + mWebView = findViewById(R.id.webView); + textView = findViewById(R.id.title); + textView.setText(String.format(WordUtil.getString(R.string.live_user_mailbox_web_title), anchorName)); + mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance() + .setDialogClose(true) + .setmContext(CommonAppContext.getTopActivity(), mWebView), "androidObject"); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setDomStorageEnabled(true); String appCachePath = getContext().getCacheDir().getAbsolutePath(); @@ -78,4 +87,17 @@ public class LiveUserAnchorMailBoxWebInfoPopDialog extends AbsDialogPopupWindow }); mWebView.loadUrl(url); } + + @Override + public void dismiss() { + super.dismiss(); + Bus.getOff(this); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { + if (event.getMethod().equals("androidGoBack")) { + dismiss(); + } + } }