use of com.github.lzyzsd.jsbridge.DefaultHandler 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);
}
});
}
Aggregations