Java Code Examples for android.widget.TextView#BufferType

The following examples show how to use android.widget.TextView#BufferType . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Markwon   File: MarkwonImpl.java    License: Apache License 2.0 6 votes vote down vote up
MarkwonImpl(
        @NonNull TextView.BufferType bufferType,
        @Nullable TextSetter textSetter,
        @NonNull Parser parser,
        @NonNull MarkwonVisitorFactory visitorFactory,
        @NonNull MarkwonConfiguration configuration,
        @NonNull List<MarkwonPlugin> plugins,
        boolean fallbackToRawInputWhenEmpty
) {
    this.bufferType = bufferType;
    this.textSetter = textSetter;
    this.parser = parser;
    this.visitorFactory = visitorFactory;
    this.configuration = configuration;
    this.plugins = plugins;
    this.fallbackToRawInputWhenEmpty = fallbackToRawInputWhenEmpty;
}
 
Example 2
public void setText(int resId, TextView.BufferType type, int... ids) {
    for (int id : ids) {
        Button button = getButton(id);
        if (button != null) {
            button.setText(resId, type);
        }
    }
}
 
Example 3
@Override
@CallSuper
public void setText(CharSequence rawText, TextView.BufferType type) {
    final CharSequence text = rawText == null ? "" : rawText;
    final SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(text);
    if (mEmoticonProvider != null)
        EmoticonUtils.replaceWithImages(getContext(), spannableStringBuilder, mEmoticonProvider, mEmoticonSize);
    super.setText(spannableStringBuilder, type);
}
 
Example 4
@Override
public void setText(
        @NonNull TextView textView,
        @NonNull final Spanned markdown,
        @NonNull final TextView.BufferType bufferType,
        @NonNull final Runnable onComplete) {

    // insert version check and do not execute on a device < 21
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        // it's still no-op, so there is no need to start background execution
        applyText(textView, markdown, bufferType, onComplete);
        return;
    }

    final WeakReference<TextView> reference = new WeakReference<>(textView);
    executor.execute(new Runnable() {
        @Override
        public void run() {
            try {
                final PrecomputedTextCompat precomputedTextCompat = precomputedText(reference.get(), markdown);
                if (precomputedTextCompat != null) {
                    applyText(reference.get(), precomputedTextCompat, bufferType, onComplete);
                }
            } catch (Throwable t) {
                Log.e("PrecomputdTxtSetterCmpt", "Exception during pre-computing text", t);
                // apply initial markdown
                applyText(reference.get(), markdown, bufferType, onComplete);
            }
        }
    });
}
 
Example 5
private static void applyText(
        @Nullable final TextView textView,
        @NonNull final Spanned text,
        @NonNull final TextView.BufferType bufferType,
        @NonNull final Runnable onComplete) {
    if (textView != null) {
        textView.post(new Runnable() {
            @Override
            public void run() {
                textView.setText(text, bufferType);
                onComplete.run();
            }
        });
    }
}
 
Example 6
public void setText(CharSequence text, TextView.BufferType type, int... ids) {
    for (int id : ids) {
        Button button = getButton(id);
        if (button != null) {
            button.setText(text, type);
        }
    }
}
 
Example 7
@NonNull
@Override
public ViewFinder setText(final int ID, final CharSequence text, final TextView.BufferType type) {
	((TextView) find(ID)).setText(text, type);
	return this;
}
 
Example 8
@NonNull
ViewFinder setText(@IdRes int ID, CharSequence text, TextView.BufferType type);
 
Example 9
Source Project: Markwon   File: MarkwonImplTest.java    License: Apache License 2.0 4 votes vote down vote up
@Test
public void text_setter() {

    final Markwon.TextSetter textSetter = mock(Markwon.TextSetter.class);
    final MarkwonPlugin plugin = mock(MarkwonPlugin.class);

    final MarkwonImpl impl = new MarkwonImpl(
            TextView.BufferType.EDITABLE,
            textSetter,
            mock(Parser.class),
            mock(MarkwonVisitorFactory.class),
            mock(MarkwonConfiguration.class),
            Collections.singletonList(plugin),
            true
    );

    final TextView textView = mock(TextView.class);
    final Spanned spanned = mock(Spanned.class);

    impl.setParsedMarkdown(textView, spanned);

    final ArgumentCaptor<TextView> textViewArgumentCaptor =
            ArgumentCaptor.forClass(TextView.class);
    final ArgumentCaptor<Spanned> spannedArgumentCaptor =
            ArgumentCaptor.forClass(Spanned.class);
    final ArgumentCaptor<TextView.BufferType> bufferTypeArgumentCaptor =
            ArgumentCaptor.forClass(TextView.BufferType.class);
    final ArgumentCaptor<Runnable> runnableArgumentCaptor =
            ArgumentCaptor.forClass(Runnable.class);

    verify(textSetter, times(1)).setText(
            textViewArgumentCaptor.capture(),
            spannedArgumentCaptor.capture(),
            bufferTypeArgumentCaptor.capture(),
            runnableArgumentCaptor.capture());

    assertEquals(textView, textViewArgumentCaptor.getValue());
    assertEquals(spanned, spannedArgumentCaptor.getValue());
    assertEquals(TextView.BufferType.EDITABLE, bufferTypeArgumentCaptor.getValue());
    assertNotNull(runnableArgumentCaptor.getValue());
}
 
Example 10
Source Project: RichEditText   File: RichEditText.java    License: Apache License 2.0 4 votes vote down vote up
public void setText(CharSequence text, TextView.BufferType type) {
    mEditText.setText(text, type);
}
 
Example 11
/**
 * Delegate method for the input widget
 */
public void setInputWidgetText(CharSequence text, TextView.BufferType type) {
    getInputWidget().setText(text, type);
}
 
Example 12
/**
 * Delegate method for the input widget
 */
public void setInputWidgetText(CharSequence text, TextView.BufferType type) {
    getInputWidget().setText(text, type);
}
 
Example 13
Source Project: SecretTextView   File: SecretTextView.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setText(CharSequence text, TextView.BufferType type) {
    super.setText(text, type);
    resetIfNeeded();
}
 
Example 14
Source Project: AndroidFloatLabel   File: FloatLabel.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the EditText's text with label animation
 *
 * @param resid int String resource ID
 * @param type TextView.BufferType
 */
public void setText(int resid, TextView.BufferType type) {
    mEditText.setText(resid, type);
}
 
Example 15
Source Project: AndroidFloatLabel   File: FloatLabel.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the EditText's text without animating the label
 *
 * @param text CharSequence to set
 * @param type TextView.BufferType
 */
public void setTextWithoutAnimation(CharSequence text, TextView.BufferType type) {
    mSkipAnimation = true;
    mEditText.setText(text, type);
}
 
Example 16
Source Project: AndroidFloatLabel   File: FloatLabel.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the EditText's text with label animation
 *
 * @param resid int String resource ID
 * @param type TextView.BufferType
 */
public void setText(int resid, TextView.BufferType type) {
    mEditText.setText(resid, type);
}
 
Example 17
Source Project: AndroidFloatLabel   File: FloatLabel.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the EditText's text with label animation
 *
 * @param text CharSequence to set
 * @param type TextView.BufferType
 */
public void setText(CharSequence text, TextView.BufferType type) {
    mEditText.setText(text, type);
}
 
Example 18
Source Project: AndroidFloatLabel   File: FloatLabel.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the EditText's text without animating the label
 *
 * @param resid int String resource ID
 * @param type TextView.BufferType
 */
public void setTextWithoutAnimation(int resid, TextView.BufferType type) {
    mSkipAnimation = true;
    mEditText.setText(resid, type);
}
 
Example 19
Source Project: AndroidFloatLabel   File: FloatLabel.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Sets the EditText's text without animating the label
 *
 * @param text CharSequence to set
 * @param type TextView.BufferType
 */
public void setTextWithoutAnimation(CharSequence text, TextView.BufferType type) {
    mSkipAnimation = true;
    mEditText.setText(text, type);
}
 
Example 20
Source Project: RichEditText   File: IEditText.java    License: Apache License 2.0 votes vote down vote up
void setText(CharSequence text, TextView.BufferType type);