List of usage examples for com.facebook.react.views.text ReactTextUpdate getJsEventCounter
public int getJsEventCounter()
From source file:fr.bamlab.textinput.ReactEditText.java
License:Open Source License
public void maybeSetText(ReactTextUpdate reactTextUpdate) { // Only set the text if it is up to date. if (reactTextUpdate.getJsEventCounter() < mNativeEventCount) { return;/*from ww w.j a v a 2 s.co m*/ } // 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; }