Files
react-native-webview/android/src/main/java/com/reactnativecommunity/webview/events/TopShouldStartLoadWithRequestEvent.java
T
Thibault Malbranche b1b662628e feat(Android Webview): Support onShouldStartLoadWithRequest on Android (#107)
This PR adds support for `onShouldStartLoadWithRequest` on android.

The initial PR was #59

The issue for this PR is: #106

fixes #106
2018-11-30 02:59:12 +01:00

41 lines
1.1 KiB
Java

package com.reactnativecommunity.webview.events;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.events.Event;
import com.facebook.react.uimanager.events.RCTEventEmitter;
public class TopShouldStartLoadWithRequestEvent extends Event<TopMessageEvent> {
public static final String EVENT_NAME = "topShouldStartLoadWithRequest";
private final String mUrl;
public TopShouldStartLoadWithRequestEvent(int viewId, String url) {
super(viewId);
mUrl = url;
}
@Override
public String getEventName() {
return EVENT_NAME;
}
@Override
public boolean canCoalesce() {
return false;
}
@Override
public short getCoalescingKey() {
// All events for a given view can be coalesced.
return 0;
}
@Override
public void dispatch(RCTEventEmitter rctEventEmitter) {
WritableMap data = Arguments.createMap();
data.putString("url", mUrl);
data.putString("navigationType", "other");
rctEventEmitter.receiveEvent(getViewTag(), EVENT_NAME, data);
}
}