Java Code Examples for android.text.TextUtils.concat()

The following are Jave code examples for showing how to use concat() of the android.text.TextUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: GoSCELE   File: ScheduleDailyProvider.java   Source Code and License Vote up 6 votes
@Override
public RemoteViews getViewAt(int position) {
    ScheduleDailyGroupModel model = list.get(position);
    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.layout_schedule_daily_widget);

    remoteViews.setTextViewText(R.id.title_schedule_daily, model.day);

    CharSequence builder = null;
    for (ScheduleDailyModel e : model.scheduleDailyModels()) {
        String course = e.desc.substring(0, e.desc.indexOf(" Ruang: "));
        String room = e.desc.substring(e.desc.indexOf(" Ruang: ") + 8);
        SpannableString title = new SpannableString(course);
        title.setSpan(new RelativeSizeSpan(1.2f), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        SpannableString time = new SpannableString("R. " + room + "\t\t" + e.time);
        time.setSpan(new ForegroundColorSpan(context.getResources().getColor(android.R.color.darker_gray)), 0, time.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        if (builder == null) {
            builder = TextUtils.concat(title, "\n", time + "\n\n");
        } else {
            builder = TextUtils.concat(builder, title, "\n", time + "\n\n");
        }
    }
    remoteViews.setTextViewText(R.id.content_schedule_daily, builder == null ? "(empty)\n\n" : builder);

    return remoteViews;
}
 
Example 2
Project: Sprog-App   File: Bypass.java   Source Code and License Vote up 5 votes
public CharSequence markdownToSpannable(String markdown, ImageGetter imageGetter) {
    Document document = processMarkdown(markdown);

    int size = document.getElementCount();
    CharSequence[] spans = new CharSequence[size];

    for (int i = 0; i < size; i++) {
        spans[i] = recurseElement(document.getElement(i), i, size, imageGetter);
    }

    return TextUtils.concat(spans);
}
 
Example 3
Project: javaide   File: ConsoleEditText.java   Source Code and License Vote up 5 votes
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
    CharSequence returnStr = source;
    String curStr = dest.subSequence(dstart, dend).toString();
    String newStr = source.toString();
    int length = end - start;
    int dlength = dend - dstart;
    if (dlength > 0 && length == 0) {
        // Case: Remove chars, Simple
        returnStr = TextListener.this.removeStr(dest.subSequence(dstart, dend), dstart);
    } else if (length > 0 && dlength == 0) {
        // Case: Insert chars, Simple
        returnStr = TextListener.this.insertStr(source.subSequence(start, end), dstart);
    } else if (curStr.length() > newStr.length()) {
        // Case: Remove string or replace
        if (curStr.startsWith(newStr)) {
            // Case: Insert chars, by append
            returnStr = TextUtils.concat(curStr.subSequence(0, newStr.length()), TextListener.this.removeStr(curStr.subSequence(newStr.length(), curStr.length()), dstart + curStr.length()));
        } else {
            // Case Replace chars.
            returnStr = TextListener.this.updateStr(curStr, dstart, newStr);
        }
    } else if (curStr.length() < newStr.length()) {
        // Case: Append String or rrepace.
        if (newStr.startsWith(curStr)) {
            // Addend, Insert
            returnStr = TextUtils.concat(curStr, TextListener.this.insertStr(newStr.subSequence(curStr.length(), newStr.length()), dstart + curStr.length()));
        } else {
            returnStr = TextListener.this.updateStr(curStr, dstart, newStr);
        }
    } else {
        // No update os str...
    }

    // If the return value is same as the source values, return the source value.
    return returnStr;
}
 
Example 4
Project: chromium-for-android-56-debug-video   File: UrlBar.java   Source Code and License Vote up 4 votes
/**
 * Autocompletes the text on the url bar and selects the text that was not entered by the
 * user. Using append() instead of setText() to preserve the soft-keyboard layout.
 * @param userText user The text entered by the user.
 * @param inlineAutocompleteText The suggested autocompletion for the user's text.
 */
public void setAutocompleteText(CharSequence userText, CharSequence inlineAutocompleteText) {
    boolean emptyAutocomplete = TextUtils.isEmpty(inlineAutocompleteText);

    if (!emptyAutocomplete) mDisableTextScrollingFromAutocomplete = true;

    int autocompleteIndex = userText.length();

    String previousText = getQueryText();
    CharSequence newText = TextUtils.concat(userText, inlineAutocompleteText);

    setIgnoreTextChangesForAutocomplete(true);
    mDisableTextAccessibilityEvents = true;

    if (!TextUtils.equals(previousText, newText)) {
        // The previous text may also have included autocomplete text, so we only
        // append the new autocomplete text that has changed.
        if (TextUtils.indexOf(newText, previousText) == 0) {
            append(newText.subSequence(previousText.length(), newText.length()));
        } else {
            setUrl(newText.toString(), null);
        }
    }

    if (getSelectionStart() != autocompleteIndex
            || getSelectionEnd() != getText().length()) {
        setSelection(autocompleteIndex, getText().length());

        if (inlineAutocompleteText.length() != 0) {
            // Sending a TYPE_VIEW_TEXT_SELECTION_CHANGED accessibility event causes the
            // previous TYPE_VIEW_TEXT_CHANGED event to be swallowed. As a result the user
            // hears the autocomplete text but *not* the text they typed. Instead we send a
            // TYPE_ANNOUNCEMENT event, which doesn't swallow the text-changed event.
            announceForAccessibility(inlineAutocompleteText);
        }
    }

    if (emptyAutocomplete) {
        mAutocompleteSpan.clearSpan();
    } else {
        mAutocompleteSpan.setSpan(userText, inlineAutocompleteText);
    }

    setIgnoreTextChangesForAutocomplete(false);
    mDisableTextAccessibilityEvents = false;
}