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 commandModifier and Type | Field and Description |
---|---|
static int |
COMMAND_GO_BACK |
static int |
COMMAND_GO_FORWARD |
static int |
COMMAND_RELOAD |
static int |
COMMAND_STOP_LOADING |
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 |
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 |
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, updateExtraData
setAccessibilityComponentType, setAccessibilityLabel, setAccessibilityLiveRegion, setBackgroundColor, setElevation, setImportantForAccessibility, setOpacity, setRenderToHardwareTexture, setRotation, setScaleX, setScaleY, setTestId, setTransform, setTranslateX, setTranslateY, setZIndex
createView, getExportedCustomBubblingEventTypeConstants, getExportedCustomDirectEventTypeConstants, getExportedViewConstants, getNativeProps, onAfterUpdateTransaction, updateProperties
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 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)
ViewManager
createViewInstance
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 setInjectedJavaScript(android.webkit.WebView view, @Nullable java.lang.String injectedJavaScript)
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)
ViewManager
addEventEmitters
in class ViewManager<android.webkit.WebView,LayoutShadowNode>
@Nullable public java.util.Map<java.lang.String,java.lang.Integer> getCommandsMap()
ViewManager
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
.
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)
ViewManager
UIManager
. 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)
ViewManager
ViewManager
subclass.onDropViewInstance
in class ViewManager<android.webkit.WebView,LayoutShadowNode>