Skip to content

Commit

Permalink
Need to handle TintContextWrapper now that ReactTextView inherits fro…
Browse files Browse the repository at this point in the history
…m AppCompatTextView

Similar to 58437cd
  • Loading branch information
Adam Comella committed Apr 1, 2019
1 parent 81688bd commit c5e8473
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.graphics.drawable.Drawable;
import android.os.Build;
import androidx.appcompat.widget.AppCompatTextView;
import android.support.v7.widget.TintContextWrapper;
import android.text.Layout;
import android.text.Spannable;
import android.text.Spanned;
Expand Down Expand Up @@ -84,6 +85,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,
Expand All @@ -107,7 +115,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();
Expand Down Expand Up @@ -229,8 +237,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
Expand Down

0 comments on commit c5e8473

Please sign in to comment.