测试更改

This commit is contained in:
18401019693 2022-11-18 15:49:24 +08:00
parent 4a28abf5b7
commit 859d884941
20 changed files with 157 additions and 147 deletions

View File

@ -139,7 +139,7 @@ public class WebViewActivity extends AbsActivity {
} }
}); });
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView).setPageClose(true).setLiveZhuangBana(false), "androidObject"); mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView).setPageClose(true).setLiveZhuangBana(false), "androidObject");
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true); mWebView.getSettings().setDomStorageEnabled(true);

View File

@ -40,6 +40,7 @@ public class JavascriptInterfaceUtils {
private boolean dialogClose = false; private boolean dialogClose = false;
//同名activity跳转问题 //同名activity跳转问题
private boolean LiveZhuangBana = true; private boolean LiveZhuangBana = true;
private static JavascriptInterfaceUtils sInstance;
public JavascriptInterfaceUtils setPageClose(boolean pageClose) { public JavascriptInterfaceUtils setPageClose(boolean pageClose) {
this.pageClose = pageClose; this.pageClose = pageClose;
@ -56,9 +57,21 @@ public class JavascriptInterfaceUtils {
return this; return this;
} }
public JavascriptInterfaceUtils(Activity mContext, WebView mWebView) { public JavascriptInterfaceUtils setmContext(Activity mContext, WebView mWebView) {
this.mContext = mContext; this.mContext = mContext;
this.mWebView = mWebView; this.mWebView = mWebView;
return this;
}
public static JavascriptInterfaceUtils getInstance() {
if (sInstance == null) {
synchronized (CityUtil.class) {
if (sInstance == null) {
sInstance = new JavascriptInterfaceUtils();
}
}
}
return sInstance;
} }
@ -453,6 +466,7 @@ public class JavascriptInterfaceUtils {
.setData(json)); .setData(json));
} }
@JavascriptInterface @JavascriptInterface
public void setHeight(String height, String width) { public void setHeight(String height, String width) {
if ("0".equals(height)) { if ("0".equals(height)) {

View File

@ -140,7 +140,7 @@ public class WebViewActivityMedal extends AbsActivity {
} }
}); });
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView), "androidObject"); mWebView.addJavascriptInterface( JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView), "androidObject");
mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setJavaScriptEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);

View File

@ -199,7 +199,7 @@ public class ZhuangBanActivity extends AbsActivity {
} }
}); });
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView) mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView)
.setPageClose(true) .setPageClose(true)
.setLiveZhuangBana(true), "androidObject"); .setLiveZhuangBana(true), "androidObject");
mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setJavaScriptEnabled(true);

View File

@ -95,7 +95,7 @@ public class LiveFansFragment extends AbsDialogFragment {
}); });
mWebView.getSettings().setJavaScriptEnabled(true); // 是否开启JS支持 mWebView.getSettings().setJavaScriptEnabled(true); // 是否开启JS支持
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView).setPageClose(false), "androidObject"); mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView).setPageClose(false), "androidObject");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
} }

View File

@ -159,7 +159,7 @@ public class LiveGameDialogFragment extends AbsDialogFragment {
mWebView = (WebView) findViewById(R.id.rlWebview); mWebView = (WebView) findViewById(R.id.rlWebview);
tabLayout = (TabLayout) findViewById(R.id.tabLayout); tabLayout = (TabLayout) findViewById(R.id.tabLayout);
layout = (LinearLayout) findViewById(R.id.bg_layout); layout = (LinearLayout) findViewById(R.id.bg_layout);
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(getActivity(), mWebView) mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(getActivity(), mWebView)
.setLiveZhuangBana(true). .setLiveZhuangBana(true).
setDialogClose(true). setDialogClose(true).
setPageClose(false), "androidObject"); setPageClose(false), "androidObject");

View File

@ -146,7 +146,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
mWebView = (WebView) findViewById(R.id.rlWebview); mWebView = (WebView) findViewById(R.id.rlWebview);
htmlError = (TextView) findViewById(R.id.html_error); htmlError = (TextView) findViewById(R.id.html_error);
findViewById(R.id.btn_back).setOnClickListener(v -> dismiss()); findViewById(R.id.btn_back).setOnClickListener(v -> dismiss());
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(getActivity(), mWebView) mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(getActivity(), mWebView)
.setLiveZhuangBana(true). .setLiveZhuangBana(true).
setDialogClose(true). setDialogClose(true).
setPageClose(false), "androidObject"); setPageClose(false), "androidObject");

View File

@ -76,7 +76,7 @@ public class LiveOneDialogFragment extends AbsDialogFragment {
public void onActivityCreated(Bundle savedInstanceState) { public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
mWebView = (WebView) findViewById(R.id.rlWebview); mWebView = (WebView) findViewById(R.id.rlWebview);
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView), "androidObject"); mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView), "androidObject");
mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setJavaScriptEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);

View File

@ -75,7 +75,7 @@ public class TurnTableWebViewHolder extends AbsLivePageViewHolder implements Vie
}); });
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView), "androidObject"); mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView), "androidObject");
mWebView.setWebChromeClient(new WebChromeClient() { mWebView.setWebChromeClient(new WebChromeClient() {
@Override @Override
public void onProgressChanged(WebView view, int newProgress) { public void onProgressChanged(WebView view, int newProgress) {

View File

@ -97,7 +97,7 @@ public class WishlistWebViewHolder extends AbsLivePageViewHolder implements View
// 自适应 屏幕大小界面 // 自适应 屏幕大小界面
webSettings.setLoadWithOverviewMode(true); webSettings.setLoadWithOverviewMode(true);
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils((Activity) mContext, mWebView).setPageClose(false), "androidObject"); mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext((Activity) mContext, mWebView).setPageClose(false), "androidObject");
mWebView.setWebChromeClient(new WebChromeClient() { mWebView.setWebChromeClient(new WebChromeClient() {
@Override @Override
public void onProgressChanged(WebView view, int newProgress) { public void onProgressChanged(WebView view, int newProgress) {

View File

@ -6,18 +6,17 @@ import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
import static com.yunbao.main.activity.MyWalletActivity.dis; import static com.yunbao.main.activity.MyWalletActivity.dis;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.ProgressDialog;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.webkit.JavascriptInterface;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.adjust.sdk.Adjust; import com.adjust.sdk.Adjust;
@ -28,19 +27,13 @@ import com.google.android.gms.ads.identifier.AdvertisingIdClient;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException; import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException; import com.google.android.gms.common.GooglePlayServicesRepairableException;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.event.JavascriptInterfaceEvent;
import com.yunbao.common.http.CommonHttpUtil; import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.GoogleBillingUtilNew; import com.yunbao.common.utils.GoogleBillingUtilNew;
import com.yunbao.common.utils.JavascriptInterfaceUtils;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.main.R; import com.yunbao.main.R;
import com.yunbao.main.views.TestWebViewClient; import com.yunbao.main.views.TestWebViewClient;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@ -54,24 +47,11 @@ public class GoogleFragment extends Fragment {
private WebView rlWebview; private WebView rlWebview;
private String url; private String url;
String adid = null; String adid = null;
private Activity mContext;
@SuppressLint("ValidFragment") @SuppressLint("ValidFragment")
public GoogleFragment(Activity context, String urls) { public GoogleFragment(String urls) {
url = urls; url = urls;
mContext = context; Log.e("google", "111aa");
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bus.getOn(this);
}
@Override
public void onDetach() {
super.onDetach();
Bus.getOff(this);
} }
@Override @Override
@ -114,7 +94,7 @@ public class GoogleFragment extends Fragment {
webSettings.setBuiltInZoomControls(true); // 是否支持缩放变焦前提是支持缩放 webSettings.setBuiltInZoomControls(true); // 是否支持缩放变焦前提是支持缩放
rlWebview.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, rlWebview).setPageClose(true), "androidObject"); rlWebview.addJavascriptInterface(new JsInteration(), "androidObject");
TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(), rlWebview); TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(), rlWebview);
@ -131,20 +111,19 @@ public class GoogleFragment extends Fragment {
} }
private Handler payHandler = new Handler(); private Handler payHandler = new Handler();
//js调用原生
public class JsInteration {
public void release() { @JavascriptInterface
public void androidNewGoToGooglePay(String ProductId, String OrderNumber, String MoneyUsd) {
} Log.e(TAG, "ProductId" + ProductId + "OrderNumber" + OrderNumber + "MoneyUsd" + MoneyUsd);
mProductId = ProductId;
@Subscribe(threadMode = ThreadMode.MAIN) mOrderid = OrderNumber;
public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) { MoneyUsds = MoneyUsd;
if (!TextUtils.isEmpty(event.getMethod())) { // googleBillingUtil.purchaseInApp(getActivity(), mProductId);
if (TextUtils.equals(event.getMethod(), "androidNewGoToGooglePay")) {
mProductId = event.getProductId();
mOrderid = event.getOrderNumber();
MoneyUsds = event.getMoneyUsd();
GoogleBillingUtilNew.getInstance().setBillingListener(new GoogleBillingUtilNew.GoogleBillingListener() { GoogleBillingUtilNew.getInstance().setBillingListener(new GoogleBillingUtilNew.GoogleBillingListener() {
@Override @Override
public void onPaySuccess(List<Purchase> list) { public void onPaySuccess(List<Purchase> list) {
@ -198,11 +177,11 @@ public class GoogleFragment extends Fragment {
}); });
AdjustEvent adjustEvent2 = new AdjustEvent("tr8lb9"); AdjustEvent adjustEvent2 = new AdjustEvent("tr8lb9");
adjustEvent2.setRevenue(Double.parseDouble(MoneyUsds), "HKD"); adjustEvent2.setRevenue(Double.parseDouble(MoneyUsds),"HKD");
adjustEvent2.addCallbackParameter("GOrderid", purchase.getOrderId()); adjustEvent2.addCallbackParameter("GOrderid",purchase.getOrderId());
adjustEvent2.addCallbackParameter("POrderid", mOrderid); adjustEvent2.addCallbackParameter("POrderid",mOrderid);
adjustEvent2.addCallbackParameter("Uid", CommonAppConfig.getInstance().getUid()); adjustEvent2.addCallbackParameter("Uid", CommonAppConfig.getInstance().getUid());
adjustEvent2.addCallbackParameter("GADid", adid); adjustEvent2.addCallbackParameter("GADid",adid);
adjustEvent2.setOrderId(mOrderid); adjustEvent2.setOrderId(mOrderid);
Adjust.trackEvent(adjustEvent2); Adjust.trackEvent(adjustEvent2);
@ -220,9 +199,9 @@ public class GoogleFragment extends Fragment {
@Override @Override
public void onPayFailed(int code, String msg) { public void onPayFailed(int code, String msg) {
Log.e("谷歌支付",code+msg);
} }
}).checkSku(event.getProductId()) }).checkSku(ProductId)
; ;
//下单 //下单
Bundle params = new Bundle(); Bundle params = new Bundle();
@ -230,7 +209,24 @@ public class GoogleFragment extends Fragment {
params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD"); params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD");
logger.logEvent(AppEventsConstants.EVENT_NAME_INITIATED_CHECKOUT, Double.parseDouble(MoneyUsds), logger.logEvent(AppEventsConstants.EVENT_NAME_INITIATED_CHECKOUT, Double.parseDouble(MoneyUsds),
params); params);
}
@JavascriptInterface
public void androidMethodBack() {
getActivity().onBackPressed();
}
@JavascriptInterface
public void androidGoBack() {
getActivity().onBackPressed();
} }
} }
public void release() {
} }
} }

View File

@ -121,26 +121,26 @@ public class MyWalletActivity extends AbsActivity {
Log.i("tss", "首充"); Log.i("tss", "首充");
if (CommonAppConfig.IS_GOOGLE_PLAY == false) { if (CommonAppConfig.IS_GOOGLE_PLAY == false) {
//链接版本 //链接版本
fragments = new Fragment[]{new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"),
new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"),
new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd")}; new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd")};
} else { } else {
rView.setVisibility(View.VISIBLE); rView.setVisibility(View.VISIBLE);
fragments = new Fragment[]{new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"),
new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), new GoogleFragment( CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"),
new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())}; new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())};
} }
} else { } else {
if (CommonAppConfig.IS_GOOGLE_PLAY == false) { if (CommonAppConfig.IS_GOOGLE_PLAY == false) {
Log.i("tss", "不是首充"); Log.i("tss", "不是首充");
//链接版本 //链接版本
fragments = new Fragment[]{new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"),
new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"),
new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd")}; new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd")};
} else { } else {
rView.setVisibility(View.VISIBLE); rView.setVisibility(View.VISIBLE);
fragments = new Fragment[]{new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"),
new GoogleFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"), new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd"),
new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())}; new WalletFragment(this, CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())};
} }
} }

View File

@ -200,7 +200,7 @@ public class MyWebViewActivity extends AbsActivity {
} }
}); });
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView).setPageClose(true), "androidObject"); mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView).setPageClose(true), "androidObject");
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setDomStorageEnabled(true); mWebView.getSettings().setDomStorageEnabled(true);

View File

@ -172,7 +172,7 @@ public class MyWebViewActivity2 extends AbsActivity {
} }
}); });
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView) mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView)
.setPageClose(true) .setPageClose(true)
.setLiveZhuangBana(false), "androidObject"); .setLiveZhuangBana(false), "androidObject");
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口

View File

@ -32,7 +32,7 @@ public class RechargeActivity extends AbsActivity {
webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
rlWebview.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, rlWebview).setPageClose(true), "androidObject"); rlWebview.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, rlWebview).setPageClose(true), "androidObject");
TestWebViewClient testWebViewClient = new TestWebViewClient(this, rlWebview); TestWebViewClient testWebViewClient = new TestWebViewClient(this, rlWebview);

View File

@ -153,7 +153,7 @@ public class RewardActivity extends AbsActivity {
}); });
mWebView.getSettings().setJavaScriptEnabled(true); // 是否开启JS支持 mWebView.getSettings().setJavaScriptEnabled(true); // 是否开启JS支持
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView) mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView)
.setPageClose(true) .setPageClose(true)
.setLiveZhuangBana(false), "androidObject"); .setLiveZhuangBana(false), "androidObject");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

View File

@ -53,7 +53,7 @@ public class WalletFragment extends Fragment {
webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
rlWebview.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, rlWebview).setPageClose(true), "androidObject"); rlWebview.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, rlWebview).setPageClose(true), "androidObject");
TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(), rlWebview); TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(), rlWebview);

View File

@ -135,7 +135,7 @@ public class WeekWebViewActivity extends AbsActivity {
} }
}); });
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView).setPageClose(true), "androidObject"); mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView).setPageClose(true), "androidObject");
mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setJavaScriptEnabled(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);

View File

@ -175,7 +175,7 @@ public class ZhuangBanActivity extends AbsActivity {
mWebView.getSettings().setJavaScriptEnabled(true); // 是否开启JS支持 mWebView.getSettings().setJavaScriptEnabled(true); // 是否开启JS支持
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
mWebView.getSettings().setDomStorageEnabled(true); mWebView.getSettings().setDomStorageEnabled(true);
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(mContext, mWebView) mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(mContext, mWebView)
.setPageClose(true) .setPageClose(true)
.setLiveZhuangBana(false), "androidObject"); .setLiveZhuangBana(false), "androidObject");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

View File

@ -111,7 +111,7 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);// 不加载缓存内容 mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);// 不加载缓存内容
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
mWebView.addJavascriptInterface(new JavascriptInterfaceUtils(nowMainActivity, mWebView), "androidObject"); mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext(nowMainActivity, mWebView), "androidObject");
rootView.addView(mWebView); rootView.addView(mWebView);