Example usage for com.facebook.react.views.text ReactTextUpdate containsImages

List of usage examples for com.facebook.react.views.text ReactTextUpdate containsImages

Introduction

In this page you can find the example usage for com.facebook.react.views.text ReactTextUpdate containsImages.

Prototype

public boolean containsImages() 

Source Link

Usage

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;// w w  w  .  ja v a  2s  . 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;
}

From source file:fr.bamlab.textinput.ReactTextInputManager.java

License:Open Source License

@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);
        }//w  ww  .j  a  v a 2  s .  c  o  m
        view.maybeSetText(update);
    }
}