Example usage for android.text TextUtils substring

List of usage examples for android.text TextUtils substring

Introduction

In this page you can find the example usage for android.text TextUtils substring.

Prototype

public static String substring(CharSequence source, int start, int end) 

Source Link

Document

Create a new String object containing the given range of characters from the source string.

Usage

From source file:Main.java

public static String getFileName(String url) {
    return TextUtils.substring(url, url.lastIndexOf("/"), url.length());
}

From source file:Main.java

public static String getSortXMPPName(String jid) {
    if (jid != null) {
        return TextUtils.substring(jid, 0, jid.indexOf("@"));
    }/*from w  w  w  . ja v  a2 s  .co m*/
    return "";
}

From source file:com.citrus.sdk.payment.CardOption.java

/**
 * This constructor will be used internally, mostly to display the saved card details.
 *
 * @param name           - User friendly name of the card. e.g. Debit Card (4242) or Credit Card (1234)
 * @param token          - Stored token for Card payment.
 * @param cardHolderName - Name of the card holder.
 * @param cardNumber     - Card number/*from ww w .  ja  v  a 2 s .  c o m*/
 * @param cardScheme     - Card scheme e.g. VISA, MASTER etc.
 * @param cardExpiry     - Card expiry date. In MMYYYY format.
 */
CardOption(String name, String token, String cardHolderName, String cardNumber, CardScheme cardScheme,
        String cardExpiry) {
    super(name, token);
    if (!android.text.TextUtils.isEmpty(cardHolderName)) {
        this.cardHolderName = cardHolderName;
    } else {
        this.cardHolderName = "Card Holder Name";
    }

    this.cardNumber = normalizeCardNumber(cardNumber);
    this.cardExpiry = cardExpiry;
    this.cardScheme = cardScheme;

    // The received expiry date is in MMYYYY format so take out expiry month and year which will be required for display purpose.
    if (!TextUtils.isEmpty(cardExpiry)) {
        this.cardExpiryMonth = TextUtils.substring(cardExpiry, 0, 2);
        this.cardExpiryYear = TextUtils.substring(cardExpiry, 2, cardExpiry.length());
    }
}

From source file:org.mozilla.focus.widget.InlineAutocompleteEditText.java

/**
 * Get the portion of text that is not marked as autocomplete text.
 *
 * @param text Current text content that may include autocomplete text
 */// www. j a va 2s .  c o m
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);
}

From source file:com.duy.pascal.ui.editor.view.CodeSuggestsEditText.java

protected void replaceText(CharSequence text) {
    clearComposingText();// w  w w  .  j  a va 2 s.  c om

    int end = getSelectionEnd();
    int start;
    if (SymbolsTokenizer.TOKEN.contains(text.toString().trim())) {
        start = end;
    } else {
        start = mTokenizer.findTokenStart(getText(), end);
    }
    start = Math.max(start, 0);
    end = Math.max(end, 0);
    Editable editable = getText();
    String original = TextUtils.substring(editable, start, end);

    QwertyKeyListener.markAsReplaced(editable, start, end, original);
    editable.replace(start, end, mTokenizer.terminateToken(text));
}