mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-05 09:29:07 +08:00
Minor code improvements for RCTTextInput
Summary: @public Expose hasUnseenUpdates in ReactShadowNode. Various text input cleanup and fixes. Differential Revision: D2975870
This commit is contained in:
@@ -44,6 +44,13 @@ public class RCTTextInput extends RCTVirtualText implements AndroidView, CSSNode
|
||||
setMeasureFunction(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notifyChanged(boolean shouldRemeasure) {
|
||||
super.notifyChanged(shouldRemeasure);
|
||||
// needed to trigger onCollectExtraUpdates
|
||||
markUpdated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setThemedContext(ThemedReactContext themedContext) {
|
||||
super.setThemedContext(themedContext);
|
||||
@@ -107,8 +114,7 @@ public class RCTTextInput extends RCTVirtualText implements AndroidView, CSSNode
|
||||
public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) {
|
||||
super.onCollectExtraUpdates(uiViewOperationQueue);
|
||||
if (mJsEventCount != UNSET) {
|
||||
ReactTextUpdate reactTextUpdate =
|
||||
new ReactTextUpdate(getText(), mJsEventCount, false);
|
||||
ReactTextUpdate reactTextUpdate = new ReactTextUpdate(getText(), mJsEventCount, false);
|
||||
uiViewOperationQueue.enqueueUpdateExtraData(getReactTag(), reactTextUpdate);
|
||||
}
|
||||
}
|
||||
@@ -127,7 +133,7 @@ public class RCTTextInput extends RCTVirtualText implements AndroidView, CSSNode
|
||||
@ReactProp(name = PROP_TEXT)
|
||||
public void setText(@Nullable String text) {
|
||||
mText = text;
|
||||
markUpdated();
|
||||
notifyChanged(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,6 +159,7 @@ public class RCTTextInput extends RCTVirtualText implements AndroidView, CSSNode
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performCollectText(SpannableStringBuilder builder) {
|
||||
if (mText != null) {
|
||||
builder.append(mText);
|
||||
@@ -160,16 +167,6 @@ public class RCTTextInput extends RCTVirtualText implements AndroidView, CSSNode
|
||||
super.performCollectText(builder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new CharSequence that includes all the text and styling information to create Layout.
|
||||
*/
|
||||
SpannableStringBuilder getText() {
|
||||
SpannableStringBuilder sb = new SpannableStringBuilder();
|
||||
collectText(sb);
|
||||
applySpans(sb);
|
||||
return sb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsCustomLayoutForChildren() {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user