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 | Field and Description |
|---|---|
static int |
COMMAND_GO_BACK |
static int |
COMMAND_GO_FORWARD |
static int |
COMMAND_RELOAD |
PROP_TEST_ID| 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 |
setDomStorageEnabled(android.webkit.WebView view,
boolean enabled) |
void |
setHtml(android.webkit.WebView view,
java.lang.String html) |
void |
setInjectedJavaScript(android.webkit.WebView view,
java.lang.String injectedJavaScript) |
void |
setJavaScriptEnabled(android.webkit.WebView view,
boolean enabled) |
void |
setUrl(android.webkit.WebView view,
java.lang.String url) |
void |
setUserAgent(android.webkit.WebView view,
java.lang.String userAgent) |
createShadowNodeInstance, getShadowNodeClass, updateExtraDatasetAccessibilityComponentType, setAccessibilityLabel, setAccessibilityLiveRegion, setBackgroundColor, setDecomposedMatrix, setElevation, setImportantForAccessibility, setOpacity, setRenderToHardwareTexture, setRotation, setScaleX, setScaleY, setTestId, setTranslateX, setTranslateYcreateView, getExportedCustomBubblingEventTypeConstants, getExportedCustomDirectEventTypeConstants, getExportedViewConstants, getNativeProps, onAfterUpdateTransaction, updatePropertiespublic static final int COMMAND_GO_BACK
public static final int COMMAND_GO_FORWARD
public static final int COMMAND_RELOAD
public ReactWebViewManager()
public ReactWebViewManager(WebViewConfig webViewConfig)
public java.lang.String getName()
getName 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 setDomStorageEnabled(android.webkit.WebView view,
boolean enabled)
public void setUserAgent(android.webkit.WebView view,
@Nullable
java.lang.String userAgent)
public void setInjectedJavaScript(android.webkit.WebView view,
@Nullable
java.lang.String injectedJavaScript)
public void setHtml(android.webkit.WebView view,
@Nullable
java.lang.String html)
public void setUrl(android.webkit.WebView view,
@Nullable
java.lang.String url)
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>