Java Code Examples for android.widget.TextView#BufferType

The following examples show how to use android.widget.TextView#BufferType . 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 File: MarkwonImpl.java    From Markwon with 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
Source File: BottomButtonBar.java    From android-oauth-client with Apache License 2.0 5 votes vote down vote up
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
Source File: EmoticonTextView.java    From EmoticonGIFKeyboard with Apache License 2.0 5 votes vote down vote up
@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
Source File: PrecomputedTextSetterCompat.java    From Markwon with Apache License 2.0 5 votes vote down vote up
@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
Source File: PrecomputedTextSetterCompat.java    From Markwon with Apache License 2.0 5 votes vote down vote up
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
Source File: BottomButtonBar.java    From android-oauth-client with Apache License 2.0 5 votes vote down vote up
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
Source File: ViewFinderImpl.java    From RendererRecyclerViewAdapter with Apache License 2.0 4 votes vote down vote up
@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
Source File: SecretTextView.java    From SecretTextView with 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 9
Source File: FloatingLabelAutoCompleteTextView.java    From android-floatinglabel-widgets with Apache License 2.0 4 votes vote down vote up
/**
 * Delegate method for the input widget
 */
public void setInputWidgetText(CharSequence text, TextView.BufferType type) {
    getInputWidget().setText(text, type);
}
 
Example 10
Source File: FloatingLabelEditText.java    From android-floatinglabel-widgets with Apache License 2.0 4 votes vote down vote up
/**
 * Delegate method for the input widget
 */
public void setInputWidgetText(CharSequence text, TextView.BufferType type) {
    getInputWidget().setText(text, type);
}
 
Example 11
Source File: RichEditText.java    From RichEditText with Apache License 2.0 4 votes vote down vote up
public void setText(CharSequence text, TextView.BufferType type) {
    mEditText.setText(text, type);
}
 
Example 12
Source File: MarkwonImplTest.java    From Markwon with 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 13
Source File: ViewFinder.java    From RendererRecyclerViewAdapter with Apache License 2.0 4 votes vote down vote up
@NonNull
ViewFinder setText(@IdRes int ID, CharSequence text, TextView.BufferType type);
 
Example 14
Source File: FloatLabel.java    From AndroidFloatLabel with 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 15
Source File: FloatLabel.java    From AndroidFloatLabel with 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 16
Source File: FloatLabel.java    From AndroidFloatLabel with 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 File: FloatLabel.java    From AndroidFloatLabel with 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 File: FloatLabel.java    From AndroidFloatLabel with 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 File: FloatLabel.java    From AndroidFloatLabel with 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 File: IEditText.java    From RichEditText with Apache License 2.0 votes vote down vote up
void setText(CharSequence text, TextView.BufferType type);