Weekend time to see the next Safe-java-js-webview-bridge source code, organized a copy of the call between the class diagram.
The basic idea of the open Source Library is divided into three steps:
1. Write the class (such as Hostjsscope.java) that invokes the local function on the native side, and dynamically generate the JS code according to the class (in the Jscalljava constructor) when initializing webviewchromeclient;
2. The dynamically generated JS code is injected into the webview by Webview.loadurl triggered onprogresschanged, which can be called by the front end;
3. Call the Hostjsscope corresponding interface on the front-end, WebView the Onprompt event, and then call the local Hostjsscope method,
If it is synchronous and has a return value, returned by the prompt return value, and if it is asynchronous, reflection calls Jscallback to return the data to the front end.
It is time to parse the call relationship. (Forgive the errors in the diagram due to a lack of understanding of UML timing diagrams)
The Safe-java-js-webview-bridge of hybrid development source analysis