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:
Ahmed El-Helw
2016-02-29 16:42:21 -08:00
parent df382e986c
commit 75117fc91a
5 changed files with 23 additions and 33 deletions

View File

@@ -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;