Skip to content

Commit

Permalink
fix(android): Changing ThemedReactContext to ReactContext to allow cu…
Browse files Browse the repository at this point in the history
…stom stuff (#1994)

* changing ThemedReactContext to ReactContext

* updating documentation

Co-authored-by: Gaurav Gupta <gaurkum@microsoft.com>
  • Loading branch information
gkode and Gaurav Gupta committed May 20, 2021
1 parent f27c28d commit 7b71364
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Expand Up @@ -63,7 +63,6 @@
import com.facebook.react.common.build.ReactBuildConfig;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.SimpleViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.events.ContentSizeChangeEvent;
Expand Down Expand Up @@ -166,13 +165,13 @@ public String getName() {
return REACT_CLASS;
}

protected RNCWebView createRNCWebViewInstance(ThemedReactContext reactContext) {
protected RNCWebView createRNCWebViewInstance(ReactContext reactContext) {
return new RNCWebView(reactContext);
}

@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected WebView createViewInstance(ThemedReactContext reactContext) {
protected WebView createViewInstance(ReactContext reactContext) {
RNCWebView webView = createRNCWebViewInstance(reactContext);
setupWebChromeClient(reactContext, webView);
reactContext.addLifecycleEventListener(webView);
Expand Down Expand Up @@ -589,7 +588,7 @@ public void setOnScroll(WebView view, boolean hasScrollEvent) {
}

@Override
protected void addEventEmitters(ThemedReactContext reactContext, WebView view) {
protected void addEventEmitters(ReactContext reactContext, WebView view) {
// Do not register default touch emitter and let WebView implementation handle touches
view.setWebViewClient(new RNCWebViewClient());
}
Expand Down Expand Up @@ -691,7 +690,7 @@ public void receiveCommand(WebView root, int commandId, @Nullable ReadableArray
@Override
public void onDropViewInstance(WebView webView) {
super.onDropViewInstance(webView);
((ThemedReactContext) webView.getContext()).removeLifecycleEventListener((RNCWebView) webView);
((ReactContext) webView.getContext()).removeLifecycleEventListener((RNCWebView) webView);
((RNCWebView) webView).cleanupCallbacksAndDestroy();
mWebChromeClient = null;
}
Expand Down Expand Up @@ -1263,7 +1262,7 @@ protected static class RNCWebView extends WebView implements LifecycleEventListe
* Activity Context is required for creation of dialogs internally by WebView
* Reactive Native needed for access to ReactNative internal system functionality
*/
public RNCWebView(ThemedReactContext reactContext) {
public RNCWebView(ReactContext reactContext) {
super(reactContext);
this.createCatalystInstance();
progressChangedFilter = new ProgressChangedFilter();
Expand Down
8 changes: 4 additions & 4 deletions docs/Custom-Android.md
Expand Up @@ -19,13 +19,13 @@ public class CustomWebViewManager extends RNCWebViewManager {
protected static class CustomWebViewClient extends RNCWebViewClient { }

protected static class CustomWebView extends RNCWebView {
public CustomWebView(ThemedReactContext reactContext) {
public CustomWebView(ReactContext reactContext) {
super(reactContext);
}
}

@Override
protected RNCWebView createRNCWebViewInstance(ThemedReactContext reactContext) {
protected RNCWebView createRNCWebViewInstance(ReactContext reactContext) {
return new CustomWebView(reactContext);
}

Expand All @@ -35,7 +35,7 @@ public class CustomWebViewManager extends RNCWebViewManager {
}

@Override
protected void addEventEmitters(ThemedReactContext reactContext, WebView view) {
protected void addEventEmitters(ReactContext reactContext, WebView view) {
view.setWebViewClient(new CustomWebViewClient());
}
}
Expand All @@ -52,7 +52,7 @@ public class CustomWebViewManager extends RNCWebViewManager {
...

protected static class CustomWebView extends RNCWebView {
public CustomWebView(ThemedReactContext reactContext) {
public CustomWebView(ReactContext reactContext) {
super(reactContext);
}

Expand Down

0 comments on commit 7b71364

Please sign in to comment.