use of com.github.lzyzsd.jsbridge.BridgeWebViewClient in project LearnApp by YouCii.
the class WebFragment method onStart.
@Override
@SuppressLint("SetJavaScriptEnabled")
public void onStart() {
super.onStart();
numAdd.setOnClickListener(this);
numDec.setOnClickListener(this);
webSettings(webView);
webView.setDefaultHandler(new DefaultHandler());
webView.setWebViewClient(new BridgeWebViewClient(webView));
webView.loadUrl("file:///android_asset/android.html");
webView.addJavascriptInterface(new jsInterface(), "Android");
webView.registerHandler("decNativeNum", new BridgeHandler() {
@Override
public void handler(String data, CallBackFunction function) {
if (data.contains("啊啊")) {
nativeNum.setText((Integer.parseInt(nativeNum.getText().toString()) - 1) + "");
} else {
ToastUtils.showShortToast(data);
}
function.onCallBack(data);
}
});
}
use of com.github.lzyzsd.jsbridge.BridgeWebViewClient in project AgentWeb by Justson.
the class JsbridgeWebFragment method getWebViewClient.
private WebViewClient getWebViewClient() {
return new WebViewClient() {
BridgeWebViewClient mBridgeWebViewClient = new BridgeWebViewClient(mBridgeWebView);
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return mBridgeWebViewClient.shouldOverrideUrlLoading(view, url);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
if (mBridgeWebViewClient.shouldOverrideUrlLoading(view, request.getUrl().toString())) {
return true;
} else {
return super.shouldOverrideUrlLoading(view, request);
}
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
mBridgeWebViewClient.onPageFinished(view, url);
}
};
}
Aggregations