From 8946c651462e3911902f2ee072159ef4002f0e1f Mon Sep 17 00:00:00 2001 From: Adam Comella Date: Thu, 21 Feb 2019 15:38:55 -0800 Subject: [PATCH] Need to handle TintContextWrapper now that ReactTextView inherits from AppCompatTextView Similar to https://github.com/facebook/react-native/commit/58437cd10a667bbcbc16781df855fd7c3d73bf49 --- .../facebook/react/views/text/ReactTextView.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java index 33a830d23dcac5..fe9c6f78405c1f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java @@ -11,6 +11,7 @@ import android.graphics.drawable.Drawable; import android.os.Build; import android.support.v7.widget.AppCompatTextView; +import android.support.v7.widget.TintContextWrapper; import android.text.Layout; import android.text.Spannable; import android.text.Spanned; @@ -80,6 +81,13 @@ private WritableMap inlineViewJson(int visibility, int index, int left, int top, return json; } + private ReactContext getReactContext() { + Context context = getContext(); + return (context instanceof TintContextWrapper) + ? (ReactContext)((TintContextWrapper)context).getBaseContext() + : (ReactContext)context; + } + @Override protected void onLayout(boolean changed, int textViewLeft, @@ -103,7 +111,7 @@ protected void onLayout(boolean changed, return; } - UIManagerModule uiManager = ((ReactContext) getContext()).getNativeModule(UIManagerModule.class); + UIManagerModule uiManager = getReactContext().getNativeModule(UIManagerModule.class); Spanned text = (Spanned) getText(); Layout layout = getLayout(); @@ -225,8 +233,7 @@ public int compare(Object o1, Object o2) { WritableMap event = Arguments.createMap(); event.putArray("inlineViews", inlineViewInfoArray2); - ReactContext reactContext = (ReactContext) getContext(); - reactContext.getJSModule(RCTEventEmitter.class).receiveEvent( + getReactContext().getJSModule(RCTEventEmitter.class).receiveEvent( getId(), "topInlineViewLayout", event