短剧
This commit is contained in:
parent
1f8025599b
commit
33bce43737
@ -0,0 +1,39 @@
|
||||
package com.yunbao.common.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.Log;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebView;
|
||||
|
||||
public class JavascriptInterfacePlayLetUtils {
|
||||
private Activity mContext;
|
||||
private WebView mWebView;
|
||||
private static JavascriptInterfacePlayLetUtils sInstance;
|
||||
|
||||
public static JavascriptInterfacePlayLetUtils getInstance() {
|
||||
|
||||
synchronized (JavascriptInterfacePlayLetUtils.class) {
|
||||
|
||||
sInstance = new JavascriptInterfacePlayLetUtils();
|
||||
|
||||
return sInstance;
|
||||
}
|
||||
}
|
||||
|
||||
public JavascriptInterfacePlayLetUtils setmContext(Activity mContext, WebView mWebView) {
|
||||
this.mContext = mContext;
|
||||
this.mWebView = mWebView;
|
||||
return this;
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void postEvent(String name, String data) {
|
||||
Log.e("TAG", "postEvent name==" + name);
|
||||
Log.e("TAG", "postEvent data==" + data);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void postWeakBalance(String data) {
|
||||
Log.e("TAG", "postWeakBalance data==" + data);
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.JavascriptInterface;
|
||||
@ -676,4 +677,5 @@ public class JavascriptInterfaceUtils {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,16 +34,17 @@ import com.yunbao.common.HtmlConfig;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.JavascriptInterfacePlayLetUtils;
|
||||
import com.yunbao.common.utils.JavascriptInterfaceUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.live.views.LoadingView;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.activity.MainActivity;
|
||||
@ -93,7 +94,7 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
|
||||
mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
|
||||
mWebView = new WebView(mContext);
|
||||
int aa = BottomBarUtil.getNavigationBarHeightIfRoom(mContext);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
params.topMargin = DpUtil.dp2px(1);
|
||||
mWebView.setLayoutParams(params);
|
||||
mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
@ -114,7 +115,9 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
|
||||
|
||||
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
|
||||
mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(nowMainActivity, mWebView), "androidObject");
|
||||
|
||||
//短剧
|
||||
mWebView.addJavascriptInterface(JavascriptInterfacePlayLetUtils.getInstance().setmContext(nowMainActivity, mWebView), "jsBridge");
|
||||
mWebView.getSettings().setSupportMultipleWindows(true);
|
||||
rootView.addView(mWebView);
|
||||
|
||||
mWebView.setWebViewClient(new WebViewClient() {
|
||||
|
Loading…
Reference in New Issue
Block a user