Cleanup updateState method on TextInputManager

Summary:
Quick refactor to cleanup the updateState method on TextInputManager

changelog:[internal]

Reviewed By: JoshuaGross

Differential Revision: D22149752

fbshipit-source-id: 0461b1769b9a7a3b25257bbf2039dc461a164c6f
This commit is contained in:
David Vacca
2020-06-19 21:50:43 -07:00
committed by Facebook GitHub Bot
parent 85669d8c30
commit f8bcb1063e
2 changed files with 10 additions and 6 deletions
@@ -142,7 +142,6 @@ public class ReactTextUpdate {
public static ReactTextUpdate buildReactTextUpdateFromState(
Spannable text,
int jsEventCounter,
boolean containsImages,
int textAlign,
int textBreakStrategy,
int justificationMode,
@@ -150,7 +149,7 @@ public class ReactTextUpdate {
ReactTextUpdate textUpdate =
new ReactTextUpdate(
text, jsEventCounter, containsImages, textAlign, textBreakStrategy, justificationMode);
text, jsEventCounter, false, textAlign, textBreakStrategy, justificationMode);
textUpdate.mAttributedString = attributedString;
return textUpdate;
@@ -1086,7 +1086,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
});
}
private class ReactContentSizeWatcher implements ContentSizeWatcher {
private static class ReactContentSizeWatcher implements ContentSizeWatcher {
private ReactEditText mEditText;
private @Nullable EventDispatcher mEventDispatcher;
private int mPreviousContentWidth = 0;
@@ -1167,7 +1167,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
}
}
private class ReactScrollWatcher implements ScrollWatcher {
private static class ReactScrollWatcher implements ScrollWatcher {
private ReactEditText mReactEditText;
private EventDispatcher mEventDispatcher;
@@ -1235,11 +1235,18 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
@Override
public Object updateState(
ReactEditText view, ReactStylesDiffMap props, @Nullable StateWrapper stateWrapper) {
if (stateWrapper == null) {
throw new IllegalArgumentException("Unable to update a NULL state.");
}
ReadableNativeMap state = stateWrapper.getState();
ReadableMap attributedString = state.getMap("attributedString");
ReadableMap paragraphAttributes = state.getMap("paragraphAttributes");
if (attributedString == null || paragraphAttributes == null) {
throw new IllegalArgumentException("Invalid TextInput State was received as a parameters");
}
Spannable spanned =
TextLayoutManager.getOrCreateSpannableForText(
view.getContext(), attributedString, mReactTextViewManagerCallback);
@@ -1248,11 +1255,9 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
TextAttributeProps.getTextBreakStrategy(paragraphAttributes.getString("textBreakStrategy"));
view.mStateWrapper = stateWrapper;
return ReactTextUpdate.buildReactTextUpdateFromState(
spanned,
state.getInt("mostRecentEventCount"),
false, // TODO add this into local Data
TextAttributeProps.getTextAlignment(props, TextLayoutManager.isRTL(attributedString)),
textBreakStrategy,
TextAttributeProps.getJustificationMode(props),