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

The following are Jave code examples for showing how to use substring() 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.
+ Save this method
Example 1
Project: buildAPKsApps   File: RecipientsEditor.java   View Source Code Vote up 6 votes
private static Recipient getRecipientAt(Spanned sp, int start, int end) {
    Annotation[] a = sp.getSpans(start, end, Annotation.class);
    String person_id = getAnnotation(a, "person_id");
    String name = getAnnotation(a, "name");
    String label = getAnnotation(a, "label");
    String bcc = getAnnotation(a, "bcc");
    String number = getAnnotation(a, "number");

    Recipient r = new Recipient();

    r.name = name;
    r.label = label;
    r.bcc = bcc.equals("true");
    r.number = TextUtils.isEmpty(number) ? TextUtils.substring(sp, start, end) : number;
    r.nameAndNumber = Recipient.buildNameAndNumber(r.name, r.number);

    if (person_id.length() > 0) {
        r.person_id = Long.parseLong(person_id);
    } else {
        r.person_id = -1;
    }

    return r;
}
 
Example 2
Project: PeSanKita-android   File: RecipientsEditor.java   View Source Code Vote up 5 votes
private static String getFieldAt(String field, Spanned sp, int start, int end,
        Context context) {
    Annotation[] a = sp.getSpans(start, end, Annotation.class);
    String fieldValue = getAnnotation(a, field);
    if (TextUtils.isEmpty(fieldValue)) {
        fieldValue = TextUtils.substring(sp, start, end);
    }
    return fieldValue;

}
 
Example 3
Project: Cable-Android   File: RecipientsEditor.java   View Source Code Vote up 5 votes
private static String getFieldAt(String field, Spanned sp, int start, int end,
        Context context) {
    Annotation[] a = sp.getSpans(start, end, Annotation.class);
    String fieldValue = getAnnotation(a, field);
    if (TextUtils.isEmpty(fieldValue)) {
        fieldValue = TextUtils.substring(sp, start, end);
    }
    return fieldValue;

}
 
Example 4
Project: firefox-tv   File: InlineAutocompleteEditText.java   View Source Code Vote up 5 votes
/**
 * Get the portion of text that is not marked as autocomplete text.
 *
 * @param text Current text content that may include autocomplete text
 */
private static String getNonAutocompleteText(final Editable text) {
    final int start = text.getSpanStart(AUTOCOMPLETE_SPAN);
    if (start < 0) {
        // No autocomplete text; return the whole string.
        return text.toString();
    }

    // Only return the portion that's not autocomplete text
    return TextUtils.substring(text, 0, start);
}