use of cn.pedant.SafeWebViewBridge.InjectedChromeClient in project 91Pop by DanteAndroid.
the class Browse91PornActivity method onCreate.
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_browse91_porn);
ButterKnife.bind(this);
initAppBar();
isNightModel = dataManager.isOpenNightMode();
historyIdStack = new Stack<>();
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAppCacheEnabled(true);
webSettings.setAppCachePath(AppCacheUtils.getRxCacheDir(context).getAbsolutePath());
mWebView.setWebChromeClient(new InjectedChromeClient("HostApp", HostJsScope.class));
mWebView.setBackgroundColor(0);
mWebView.setBackgroundResource(0);
mWebView.setVisibility(View.INVISIBLE);
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.contains("tid=")) {
int starIndex = url.indexOf("tid=");
String tidStr = StringUtils.subString(url, starIndex + 4, starIndex + 10);
if (!TextUtils.isEmpty(tidStr) && TextUtils.isDigitsOnly(tidStr)) {
Long id = Long.parseLong(tidStr);
presenter.loadContent(id, isNightModel);
historyIdStack.push(id);
} else {
Logger.t(TAG).d(tidStr);
showMessage("暂不支持直接打开此链接", TastyToast.INFO);
}
}
return true;
}
});
AppUtils.setColorSchemeColors(context, swipeLayout);
forum91PronItem = (Forum91PronItem) getIntent().getSerializableExtra(Keys.KEY_INTENT_BROWSE_FORUM_91_PORN_ITEM);
presenter.loadContent(forum91PronItem.getTid(), isNightModel);
historyIdStack.push(forum91PronItem.getTid());
imageList = new ArrayList<>();
boolean needShowTip = dataManager.isViewPorn91ForumContentShowTip();
if (needShowTip) {
// showTipDialog();
}
fabFunction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showOpenNewForum();
}
});
}
Aggregations