fix(refactor): Converting dispatchEvent static method to non static method (#1939)

* converting static method dispatch event to non static

* removing typo

* removing typo

Co-authored-by: Gaurav Gupta <gaurkum@microsoft.com>
This commit is contained in:
Gaurav Gupta
2021-03-24 21:28:20 +01:00
committed by GitHub
co-authored by Gaurav Gupta
parent 9d9fda87fa
commit 344ccce3ee
@@ -161,13 +161,6 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
mWebViewConfig = webViewConfig; mWebViewConfig = webViewConfig;
} }
protected static void dispatchEvent(WebView webView, Event event) {
ReactContext reactContext = (ReactContext) webView.getContext();
EventDispatcher eventDispatcher =
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
eventDispatcher.dispatchEvent(event);
}
@Override @Override
public String getName() { public String getName() {
return REACT_CLASS; return REACT_CLASS;
@@ -838,7 +831,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
RNCWebView reactWebView = (RNCWebView) webView; RNCWebView reactWebView = (RNCWebView) webView;
reactWebView.callInjectedJavaScriptBeforeContentLoaded(); reactWebView.callInjectedJavaScriptBeforeContentLoaded();
dispatchEvent( ((RNCWebView) webView).dispatchEvent(
webView, webView,
new TopLoadingStartEvent( new TopLoadingStartEvent(
webView.getId(), webView.getId(),
@@ -885,7 +878,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
} else { } else {
FLog.w(TAG, "Couldn't use blocking synchronous call for onShouldStartLoadWithRequest due to debugging or missing Catalyst instance, falling back to old event-and-load."); FLog.w(TAG, "Couldn't use blocking synchronous call for onShouldStartLoadWithRequest due to debugging or missing Catalyst instance, falling back to old event-and-load.");
progressChangedFilter.setWaitingForCommandLoadUrl(true); progressChangedFilter.setWaitingForCommandLoadUrl(true);
dispatchEvent( ((RNCWebView) view).dispatchEvent(
view, view,
new TopShouldStartLoadWithRequestEvent( new TopShouldStartLoadWithRequestEvent(
view.getId(), view.getId(),
@@ -992,7 +985,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
eventData.putDouble("code", errorCode); eventData.putDouble("code", errorCode);
eventData.putString("description", description); eventData.putString("description", description);
dispatchEvent( ((RNCWebView) webView).dispatchEvent(
webView, webView,
new TopLoadingErrorEvent(webView.getId(), eventData)); new TopLoadingErrorEvent(webView.getId(), eventData));
} }
@@ -1010,7 +1003,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
eventData.putInt("statusCode", errorResponse.getStatusCode()); eventData.putInt("statusCode", errorResponse.getStatusCode());
eventData.putString("description", errorResponse.getReasonPhrase()); eventData.putString("description", errorResponse.getReasonPhrase());
dispatchEvent( ((RNCWebView) webView).dispatchEvent(
webView, webView,
new TopHttpErrorEvent(webView.getId(), eventData)); new TopHttpErrorEvent(webView.getId(), eventData));
} }
@@ -1042,7 +1035,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
WritableMap event = createWebViewEvent(webView, webView.getUrl()); WritableMap event = createWebViewEvent(webView, webView.getUrl());
event.putBoolean("didCrash", detail.didCrash()); event.putBoolean("didCrash", detail.didCrash());
dispatchEvent( ((RNCWebView) webView).dispatchEvent(
webView, webView,
new TopRenderProcessGoneEvent(webView.getId(), event) new TopRenderProcessGoneEvent(webView.getId(), event)
); );
@@ -1052,7 +1045,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
} }
protected void emitFinishEvent(WebView webView, String url) { protected void emitFinishEvent(WebView webView, String url) {
dispatchEvent( ((RNCWebView) webView).dispatchEvent(
webView, webView,
new TopLoadingFinishEvent( new TopLoadingFinishEvent(
webView.getId(), webView.getId(),
@@ -1181,7 +1174,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
event.putBoolean("canGoBack", webView.canGoBack()); event.putBoolean("canGoBack", webView.canGoBack());
event.putBoolean("canGoForward", webView.canGoForward()); event.putBoolean("canGoForward", webView.canGoForward());
event.putDouble("progress", (float) newProgress / 100); event.putDouble("progress", (float) newProgress / 100);
dispatchEvent( ((RNCWebView) webView).dispatchEvent(
webView, webView,
new TopLoadingProgressEvent( new TopLoadingProgressEvent(
webView.getId(), webView.getId(),
@@ -1492,6 +1485,13 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
} }
} }
protected void dispatchEvent(WebView webView, Event event) {
ReactContext reactContext = (ReactContext) webView.getContext();
EventDispatcher eventDispatcher =
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher();
eventDispatcher.dispatchEvent(event);
}
protected void cleanupCallbacksAndDestroy() { protected void cleanupCallbacksAndDestroy() {
setWebViewClient(null); setWebViewClient(null);
destroy(); destroy();