Java Code Examples for android.widget.TextView#length()

The following examples show how to use android.widget.TextView#length() . 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 want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * Highlights all the {@link Mentionable}s in the test {@link Comment}.
 */
private void highlightMentions(final TextView commentTextView, final List<Mentionable> mentions) {
    if(commentTextView != null && mentions != null && !mentions.isEmpty()) {
        final Spannable spannable = new SpannableString(commentTextView.getText());

        for (Mentionable mention: mentions) {
            if (mention != null) {
                final int start = mention.getMentionOffset();
                final int end = start + mention.getMentionLength();

                if (commentTextView.length() >= end) {
                    spannable.setSpan(new ForegroundColorSpan(orange), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                    commentTextView.setText(spannable, TextView.BufferType.SPANNABLE);
                } else {
                    //Something went wrong.  The expected text that we're trying to highlight does not
                    // match the actual text at that position.
                    Log.w("Mentions Sample", "Mention lost. [" + mention + "]");
                }
            }
        }
    }
}
 
Example 2
private boolean expand() {
    if (!isCompact)
        return false;
    else {
        TextView subtitle = (TextView) layout.findViewById(R.id.notification_subtitle);
        if ( (subtitle.getLineCount() <= MIN_LINES && subtitle.length() < 80) && !isActionButtons) {
            return false;
        }
        isCompact = false;
        subtitle.setMaxLines(MAX_LINES);
        if (isActionButtons)
            themeClass.showActionButtons(layout, -1);
        if (displayTime < MAX_DISPLAY_TIME) {
            handler.removeCallbacks(closeTimer);
            handler.postDelayed(closeTimer, displayTime);
        }
        return true;
    }
}
 
Example 3
@Override
public boolean isValid(TextView view) {
    return view.length() <= value;
}
 
Example 4
@Override
public boolean isValid(TextView view) {
    return view.length() >= value;
}
 
Example 5
Source Project: MagicForm   File: ValidationLength.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public boolean isValid(TextView view)
{
	return (mMin == null || mMin <= view.length()) && (mMax == null || mMax >= view.length());
}