public class ReactWebViewManager extends SimpleViewManager<android.webkit.WebView>
WebView
Can accept following commands:
- GO_BACK
- GO_FORWARD
- RELOAD
WebView instances could emit following direct events:
- topLoadingFinish
- topLoadingStart
- topLoadingError
Each event will carry the following properties:
- target - view's react tag
- url - url set for the webview
- loading - whether webview is in a loading state
- title - title of the current page
- canGoBack - boolean, whether there is anything on a history stack to go back
- canGoForward - boolean, whether it is possible to request GO_FORWARD command| Modifier and Type | Class and Description |
|---|---|
protected static class |
ReactWebViewManager.ReactWebView
Subclass of
WebView that implements LifecycleEventListener interface in order
to call WebView.destroy() on activty destroy event and also to clear the client |
protected static class |
ReactWebViewManager.ReactWebViewClient |
BaseJavaModule.JavaMethodNativeModule.NativeMethod| Modifier and Type | Field and Description |
|---|---|
static int |
COMMAND_GO_BACK |
static int |
COMMAND_GO_FORWARD |
static int |
COMMAND_INJECT_JAVASCRIPT |
static int |
COMMAND_POST_MESSAGE |
static int |
COMMAND_RELOAD |
static int |
COMMAND_STOP_LOADING |
protected static java.lang.String |
REACT_CLASS |
PROP_TEST_IDMETHOD_TYPE_ASYNC, METHOD_TYPE_PROMISE, METHOD_TYPE_SYNC| Constructor and Description |
|---|
ReactWebViewManager() |
ReactWebViewManager(WebViewConfig webViewConfig) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addEventEmitters(ThemedReactContext reactContext,
android.webkit.WebView view)
Subclasses can override this method to install custom event emitters on the given View.
|
protected android.webkit.WebView |
createViewInstance(ThemedReactContext reactContext)
Subclasses should return a new View instance of the proper type.
|
java.util.Map<java.lang.String,java.lang.Integer> |
getCommandsMap()
Subclasses of
ViewManager that expect to receive commands through
UIManagerModule.dispatchViewManagerCommand(int, int, com.facebook.react.bridge.ReadableArray) should override this method returning the
map between names of the commands and IDs that are then used in ViewManager.receiveCommand(T, int, com.facebook.react.bridge.ReadableArray) method
whenever the command is dispatched for this particular ViewManager. |
java.lang.String |
getName() |
void |
onDropViewInstance(android.webkit.WebView webView)
Called when view is detached from view hierarchy and allows for some additional cleanup by
the
ViewManager subclass. |
void |
receiveCommand(android.webkit.WebView root,
int commandId,
ReadableArray args)
Subclasses may use this method to receive events/commands directly from JS through the
UIManager. |
void |
setAllowUniversalAccessFromFileURLs(android.webkit.WebView view,
boolean allow) |
void |
setDomStorageEnabled(android.webkit.WebView view,
boolean enabled) |
void |
setInjectedJavaScript(android.webkit.WebView view,
java.lang.String injectedJavaScript) |
void |
setJavaScriptEnabled(android.webkit.WebView view,
boolean enabled) |
void |
setMediaPlaybackRequiresUserAction(android.webkit.WebView view,
boolean requires) |
void |
setMessagingEnabled(android.webkit.WebView view,
boolean enabled) |
void |
setOnContentSizeChange(android.webkit.WebView view,
boolean sendContentSizeChangeEvents) |
void |
setScalesPageToFit(android.webkit.WebView view,
boolean enabled) |
void |
setSource(android.webkit.WebView view,
ReadableMap source) |
void |
setUserAgent(android.webkit.WebView view,
java.lang.String userAgent) |
createShadowNodeInstance, getShadowNodeClass, updateExtraDatasetAccessibilityComponentType, setAccessibilityLabel, setAccessibilityLiveRegion, setBackgroundColor, setElevation, setImportantForAccessibility, setOpacity, setRenderToHardwareTexture, setRotation, setScaleX, setScaleY, setTestId, setTransform, setTranslateX, setTranslateY, setZIndexcreateView, getExportedCustomBubblingEventTypeConstants, getExportedCustomDirectEventTypeConstants, getExportedViewConstants, getNativeProps, onAfterUpdateTransaction, updatePropertiescanOverrideExistingModule, getConstants, getMethods, initialize, onCatalystInstanceDestroy, supportsWebWorkersprotected static final java.lang.String REACT_CLASS
public static final int COMMAND_GO_BACK
public static final int COMMAND_GO_FORWARD
public static final int COMMAND_RELOAD
public static final int COMMAND_STOP_LOADING
public static final int COMMAND_POST_MESSAGE
public static final int COMMAND_INJECT_JAVASCRIPT
public ReactWebViewManager()
public ReactWebViewManager(WebViewConfig webViewConfig)
public java.lang.String getName()
getName in interface NativeModulegetName in class ViewManager<android.webkit.WebView,LayoutShadowNode>protected android.webkit.WebView createViewInstance(ThemedReactContext reactContext)
ViewManagercreateViewInstance in class ViewManager<android.webkit.WebView,LayoutShadowNode>public void setJavaScriptEnabled(android.webkit.WebView view,
boolean enabled)
public void setScalesPageToFit(android.webkit.WebView view,
boolean enabled)
public void setDomStorageEnabled(android.webkit.WebView view,
boolean enabled)
public void setUserAgent(android.webkit.WebView view,
@Nullable
java.lang.String userAgent)
public void setMediaPlaybackRequiresUserAction(android.webkit.WebView view,
boolean requires)
public void setAllowUniversalAccessFromFileURLs(android.webkit.WebView view,
boolean allow)
public void setInjectedJavaScript(android.webkit.WebView view,
@Nullable
java.lang.String injectedJavaScript)
public void setMessagingEnabled(android.webkit.WebView view,
boolean enabled)
public void setSource(android.webkit.WebView view,
@Nullable
ReadableMap source)
public void setOnContentSizeChange(android.webkit.WebView view,
boolean sendContentSizeChangeEvents)
protected void addEventEmitters(ThemedReactContext reactContext, android.webkit.WebView view)
ViewManageraddEventEmitters in class ViewManager<android.webkit.WebView,LayoutShadowNode>@Nullable public java.util.Map<java.lang.String,java.lang.Integer> getCommandsMap()
ViewManagerViewManager that expect to receive commands through
UIManagerModule.dispatchViewManagerCommand(int, int, com.facebook.react.bridge.ReadableArray) should override this method returning the
map between names of the commands and IDs that are then used in ViewManager.receiveCommand(T, int, com.facebook.react.bridge.ReadableArray) method
whenever the command is dispatched for this particular ViewManager.
As an example we may consider ReactWebViewManager that expose the following commands:
goBack, goForward, reload. In this case the map returned from ViewManager.getCommandsMap() from
ReactWebViewManager will look as follows:
{
"goBack": 1,
"goForward": 2,
"reload": 3,
}
Now assuming that "reload" command is dispatched through UIManagerModule we trigger
ReactWebViewManager#receiveCommand passing "3" as commandId argument.getCommandsMap in class ViewManager<android.webkit.WebView,LayoutShadowNode>public void receiveCommand(android.webkit.WebView root,
int commandId,
@Nullable
ReadableArray args)
ViewManagerUIManager. Good example of such a command would be scrollTo request with
coordinates for a ScrollView or goBack request for a WebView instance.receiveCommand in class ViewManager<android.webkit.WebView,LayoutShadowNode>root - View instance that should receive the commandcommandId - code of the commandargs - optional arguments for the commandpublic void onDropViewInstance(android.webkit.WebView webView)
ViewManagerViewManager subclass.onDropViewInstance in class ViewManager<android.webkit.WebView,LayoutShadowNode>