use of com.github.lzyzsd.jsbridge.CallBackFunction 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.CallBackFunction in project AgentWeb by Justson.
the class JsbridgeWebFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
mBridgeWebView = new BridgeWebView(getActivity());
mAgentWeb = AgentWeb.with(this).setAgentWebParent((ViewGroup) view, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)).useDefaultIndicator(-1, 2).setAgentWebWebSettings(getSettings()).setWebViewClient(getWebViewClient()).setWebChromeClient(mWebChromeClient).setWebView(mBridgeWebView).setSecurityType(AgentWeb.SecurityType.STRICT_CHECK).createAgentWeb().ready().go(getUrl());
initView(view);
mBridgeWebView.registerHandler("submitFromWeb", new BridgeHandler() {
@Override
public void handler(String data, CallBackFunction function) {
function.onCallBack("submitFromWeb exe, response data δΈζ from Java");
}
});
User user = new User();
Location location = new Location();
location.address = "SDU";
user.location = location;
user.name = "Agentweb --> Jsbridge";
mBridgeWebView.callHandler("functionInJs", new Gson().toJson(user), new CallBackFunction() {
@Override
public void onCallBack(String data) {
Log.i(TAG, "data:" + data);
}
});
mBridgeWebView.send("hello");
}
Aggregations