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(); + } + } }