@Override public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) { super.onCollectExtraUpdates(uiViewOperationQueue); if (mJsEventCount != UNSET) { ReactTextUpdate reactTextUpdate = new ReactTextUpdate( getText(), mJsEventCount, false, getPadding(Spacing.START), getPadding(Spacing.TOP), getPadding(Spacing.END), getPadding(Spacing.BOTTOM), UNSET); // TODO: the Float.NaN should be replaced with the real line height see D3592781 uiViewOperationQueue.enqueueUpdateExtraData(getReactTag(), reactTextUpdate); } }
public void maybeSetText(ReactTextUpdate reactTextUpdate) { // Only set the text if it is up to date. mMostRecentEventCount = reactTextUpdate.getJsEventCounter(); if (mMostRecentEventCount < mNativeEventCount) { return; } // The current text gets replaced with the text received from JS. However, the spans on the // current text need to be adapted to the new text. Since TextView#setText() will remove or // reset some of these spans even if they are set directly, SpannableStringBuilder#replace() is // used instead (this is also used by the the keyboard implementation underneath the covers). SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(reactTextUpdate.getText()); manageSpans(spannableStringBuilder); mContainsImages = reactTextUpdate.containsImages(); mIsSettingTextFromJS = true; getText().replace(0, length(), spannableStringBuilder); mIsSettingTextFromJS = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (getBreakStrategy() != reactTextUpdate.getTextBreakStrategy()) { setBreakStrategy(reactTextUpdate.getTextBreakStrategy()); } } }
@Override public void updateExtraData(ReactEditText view, Object extraData) { if (extraData instanceof ReactTextUpdate) { ReactTextUpdate update = (ReactTextUpdate) extraData; view.setPadding( (int) update.getPaddingLeft(), (int) update.getPaddingTop(), (int) update.getPaddingRight(), (int) update.getPaddingBottom()); if (update.containsImages()) { Spannable spannable = update.getText(); TextInlineImageSpan.possiblyUpdateInlineImageSpans(spannable, view); } view.maybeSetText(update); } }
@Override public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) { super.onCollectExtraUpdates(uiViewOperationQueue); if (mJsEventCount != UNSET) { Spannable preparedSpannableText = fromTextCSSNode(this); ReactTextUpdate reactTextUpdate = new ReactTextUpdate( preparedSpannableText, mJsEventCount, mContainsImages, getPadding(Spacing.LEFT), getPadding(Spacing.TOP), getPadding(Spacing.RIGHT), getPadding(Spacing.BOTTOM), mTextAlign, mTextBreakStrategy ); uiViewOperationQueue.enqueueUpdateExtraData(getReactTag(), reactTextUpdate); } }
public void maybeSetText(ReactTextUpdate reactTextUpdate) { // Only set the text if it is up to date. if (reactTextUpdate.getJsEventCounter() < mNativeEventCount) { return; } // The current text gets replaced with the text received from JS. However, the spans on the // current text need to be adapted to the new text. Since TextView#setText() will remove or // reset some of these spans even if they are set directly, SpannableStringBuilder#replace() is // used instead (this is also used by the the keyboard implementation underneath the covers). SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(reactTextUpdate.getText()); manageSpans(spannableStringBuilder); mContainsImages = reactTextUpdate.containsImages(); mIsSettingTextFromJS = true; getText().replace(0, length(), spannableStringBuilder); mIsSettingTextFromJS = false; }
@Override public void updateExtraData(ReactEditText view, Object extraData) { if (extraData instanceof float[]) { float[] padding = (float[]) extraData; view.setPadding( (int) Math.ceil(padding[0]), (int) Math.ceil(padding[1]), (int) Math.ceil(padding[2]), (int) Math.ceil(padding[3])); } else if (extraData instanceof ReactTextUpdate) { ReactTextUpdate update = (ReactTextUpdate) extraData; if (update.containsImages()) { Spannable spannable = update.getText(); TextInlineImageSpan.possiblyUpdateInlineImageSpans(spannable, view); } view.maybeSetText(update); } }
public void maybeSetText(ReactTextUpdate reactTextUpdate) { // Only set the text if it is up to date. mMostRecentEventCount = reactTextUpdate.getJsEventCounter(); if (mMostRecentEventCount < mNativeEventCount) { return; } // The current text gets replaced with the text received from JS. However, the spans on the // current text need to be adapted to the new text. Since TextView#setText() will remove or // reset some of these spans even if they are set directly, SpannableStringBuilder#replace() is // used instead (this is also used by the the keyboard implementation underneath the covers). SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(reactTextUpdate.getText()); manageSpans(spannableStringBuilder); mContainsImages = reactTextUpdate.containsImages(); mIsSettingTextFromJS = true; getText().replace(0, length(), spannableStringBuilder); mIsSettingTextFromJS = false; }
@Override public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) { super.onCollectExtraUpdates(uiViewOperationQueue); if (mComputedPadding != null) { uiViewOperationQueue.enqueueUpdateExtraData(getReactTag(), mComputedPadding); mComputedPadding = null; } if (mJsEventCount != UNSET) { Spannable preparedSpannableText = fromTextCSSNode(this); ReactTextUpdate reactTextUpdate = new ReactTextUpdate(preparedSpannableText, mJsEventCount, mContainsImages); uiViewOperationQueue.enqueueUpdateExtraData(getReactTag(), reactTextUpdate); } }
@Override public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) { super.onCollectExtraUpdates(uiViewOperationQueue); if (mComputedPadding != null) { float[] updatedPadding = mComputedPadding; if (getLayoutDirection() == CSSDirection.RTL) { updatedPadding = new float[] { getPadding(Spacing.END), getPadding(Spacing.TOP), getPadding(Spacing.START), getPadding(Spacing.BOTTOM), }; } uiViewOperationQueue.enqueueUpdateExtraData(getReactTag(), updatedPadding); mComputedPadding = null; } if (mJsEventCount != UNSET) { Spannable preparedSpannableText = fromTextCSSNode(this); ReactTextUpdate reactTextUpdate = new ReactTextUpdate( preparedSpannableText, mJsEventCount, mContainsImages, getPadding(Spacing.START), getPadding(Spacing.TOP), getPadding(Spacing.END), getPadding(Spacing.BOTTOM), mTextAlign ); uiViewOperationQueue.enqueueUpdateExtraData(getReactTag(), reactTextUpdate); } }