public class Bridge extends Object implements Listener, EventLauncher
Modifier and Type | Class and Description |
---|---|
static interface |
Bridge.LaunchboxApiCheckResult |
Modifier and Type | Field and Description |
---|---|
protected List<Bridge.LaunchboxApiCheckResult> |
launchboxCheckCallbacks |
Constructor and Description |
---|
Bridge(HybridWebView webView) |
Modifier and Type | Method and Description |
---|---|
void |
call(Plugin plugin,
String methodName,
Object data,
JavascriptCallbackImpl callback)
Calls the specified method of the concrete plugin (if such method is available)
|
void |
callOnReload()
Called when url has changed or has been reloaded
|
void |
dispose() |
void |
fireEvent(String eventName,
Object data)
Used by the plugins to fire an event on the js side
|
void |
fireEvent(String eventName,
String method,
Object data)
Used by the plugins to fire an event on the js side
|
void |
fireInitializingEvent(String eventName,
String method,
Object data)
Used by the plugins to fire an event on the js side
|
String |
getJavaScripts(JavascriptAppenderImpl loader)
Returns the complete implementation that contains the javascript implementations of
the bridge and all the plugins
|
boolean |
isInitialized()
Check if bridge is already initialized
|
void |
isLaunchboxApiInjected(Bridge.LaunchboxApiCheckResult result) |
String |
receiveAndRespond(String input)
Not implemented and not currently needed
|
void |
receiveAsync(String message)
A message from the js side is decoded here and directed to the correct plugin
|
void |
sendReplyToCallback(long callbackId,
String method,
Object data)
Used by the callback objects to forward the call to the js side
|
void |
setInitialized(boolean initialized)
Set initialized state for bridge.
|
void |
setPluginRegistry(PluginRegistryImpl plugins) |
protected final List<Bridge.LaunchboxApiCheckResult> launchboxCheckCallbacks
public Bridge(HybridWebView webView)
public void setPluginRegistry(PluginRegistryImpl plugins)
public void isLaunchboxApiInjected(Bridge.LaunchboxApiCheckResult result)
public String getJavaScripts(JavascriptAppenderImpl loader)
public void receiveAsync(String message)
receiveAsync
in interface Listener
public void call(Plugin plugin, String methodName, Object data, JavascriptCallbackImpl callback) throws BridgeException
plugin
- plugin providing the methodmethodName
- name of the method to be calleddata
- could be null, String, Boolean, Number, Array or a Map of any of suchcallback
- a callback object that should be used to return the resultBridgeException
public String receiveAndRespond(String input)
receiveAndRespond
in interface Listener
public void sendReplyToCallback(long callbackId, String method, Object data)
callbackId
- method
- data
- public void fireEvent(String eventName, Object data)
fireEvent
in interface EventLauncher
eventName
- Name of the event (JavaScript function) to call.data
- JSON-compatible object passed to JavaScript or null if no data..public void fireEvent(String eventName, String method, Object data)
fireEvent
in interface EventLauncher
eventName
- A name under which a group of events is stored on the JavaScripts side.method
- Name of the event (JavaScript function) to call.data
- JSON-compatible object passed to JavaScript or null if no data..public void fireInitializingEvent(String eventName, String method, Object data)
fireInitializingEvent
in interface EventLauncher
eventName
- A name under which a group of events is stored on the JavaScripts side.method
- Name of the event (JavaScript function) to call.data
- JSON-compatible object passed to JavaScript or null if no data..public void setInitialized(boolean initialized)
initialized
- public boolean isInitialized()
public void callOnReload()
public void dispose()