当前位置: 首页>>代码示例>>Java>>正文


Java TextUtils.indexOf方法代码示例

本文整理汇总了Java中android.text.TextUtils.indexOf方法的典型用法代码示例。如果您正苦于以下问题:Java TextUtils.indexOf方法的具体用法?Java TextUtils.indexOf怎么用?Java TextUtils.indexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.text.TextUtils的用法示例。


在下文中一共展示了TextUtils.indexOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: replaceWithLink

import android.text.TextUtils; //导入方法依赖的package包/类
public CharSequence replaceWithLink(CharSequence source, String param, ArrayList<Integer> uids, AbstractMap<Integer, TLRPC.User> usersDict) {
    int start = TextUtils.indexOf(source, param);
    if (start >= 0) {
        SpannableStringBuilder names = new SpannableStringBuilder("");
        for (int a = 0; a < uids.size(); a++) {
            TLRPC.User user = null;
            if (usersDict != null) {
                user = usersDict.get(uids.get(a));
            }
            if (user == null) {
                user = MessagesController.getInstance().getUser(uids.get(a));
            }
            if (user != null) {
                String name = UserObject.getUserName(user);
                start = names.length();
                if (names.length() != 0) {
                    names.append(", ");
                }
                names.append(name);
                names.setSpan(new URLSpanNoUnderlineBold("" + user.id), start, start + name.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }
        return TextUtils.replace(source, new String[]{param}, new CharSequence[]{names});
    }
    return source;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:27,代码来源:MessageObject.java

示例2: shouldOverrideUrlLoading

import android.text.TextUtils; //导入方法依赖的package包/类
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
	String decode;
	try {
		decode = URLDecoder.decode(url, "UTF-8");
	} catch (UnsupportedEncodingException e) {
		// No handling
		return false;
	}

	if (TextUtils.indexOf(url, CALLBACK_SCHEME) == 0) {
		callback(decode);
		return true;
	} else if (TextUtils.indexOf(url, STATE_SCHEME) == 0) {
		stateCheck(decode);
		return true;
	}

	return super.shouldOverrideUrlLoading(view, url);
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:21,代码来源:RichEditor.java

示例3: shouldOverrideUrlLoading

import android.text.TextUtils; //导入方法依赖的package包/类
@Override public boolean shouldOverrideUrlLoading(WebView view, String url) {
  String decode;
  try {
    decode = URLDecoder.decode(url, "UTF-8");
  } catch (UnsupportedEncodingException e) {
    // No handling
    return false;
  }

  if (TextUtils.indexOf(url, CALLBACK_SCHEME) == 0) {
    callback(decode);
    return true;
  } else if (TextUtils.indexOf(url, STATE_SCHEME) == 0) {
    stateCheck(decode);
    return true;
  }

  return super.shouldOverrideUrlLoading(view, url);
}
 
开发者ID:androidDaniel,项目名称:riched_editor_x5,代码行数:20,代码来源:RichEditor.java

示例4: getformatedSearchSnippet

import android.text.TextUtils; //导入方法依赖的package包/类
public CharSequence getformatedSearchSnippet() {
    //TODO implement improved snippet function
    String CleanedSearchString = " " + ArabicUtilities.cleanTextForSearchingWthStingBuilder(searchString) + " ";
    StringBuilder cleanedUnformattedPage = new StringBuilder(ArabicUtilities.cleanTextForSearchingWthStingBuilder(unformatedPage));
    int firstMatchStart = cleanedUnformattedPage.indexOf(CleanedSearchString);
    cleanedUnformattedPage.delete(0, Math.max(firstMatchStart - 100, 0));
    cleanedUnformattedPage.delete(
            Math.min(firstMatchStart + CleanedSearchString.length() + 100, cleanedUnformattedPage.length())
            , cleanedUnformattedPage.length());
    cleanedUnformattedPage.insert(0, "...");
    cleanedUnformattedPage.append("...");

    Spannable snippet = SpannableString.
            valueOf(cleanedUnformattedPage.toString());
    int index = TextUtils.indexOf(snippet, CleanedSearchString);
    while (index >= 0) {

        snippet.setSpan(new BackgroundColorSpan(0xFF8B008B), index, index
                + CleanedSearchString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        index = TextUtils.indexOf(snippet, CleanedSearchString, index + CleanedSearchString.length());
    }

    return snippet;
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:25,代码来源:SearchResult.java

示例5: getDesiredSize

import android.text.TextUtils; //导入方法依赖的package包/类
/**
 * Return how wide a layout must be in order to display the
 * specified text slice with one line per paragraph.
 */
public static Rect getDesiredSize(CharSequence source,
                                  int start, int end,
                                  TextPaint paint) {

    MongolTextLine tl = MongolTextLine.obtain();

    float longestWidth = 0;
    float heightSum = 0;

    int next;
    for (int i = start; i <= end; i = next) {
        next = TextUtils.indexOf(source, '\n', i, end);

        if (next < 0)
            next = end;

        tl.set(paint, source, i, next);
        RectF size = tl.measure();
        float width = size.width(); // horizontal line orientation
        heightSum += size.height(); // horizontal line orientation

        if (width > longestWidth)
            longestWidth = width;

        next++;
    }

    MongolTextLine.recycle(tl);

    if (heightSum == 0) {
        heightSum = paint.getFontMetrics().bottom - paint.getFontMetrics().top;
    }

    // returning the size as a vertical line orientation (swapping width and height)
    return new Rect(0, 0, (int) heightSum, (int) longestWidth);
}
 
开发者ID:suragch,项目名称:mongol-library,代码行数:41,代码来源:MongolLayout.java

示例6: stateCheck

import android.text.TextUtils; //导入方法依赖的package包/类
private void stateCheck(String text) {
	String state = text.replaceFirst(STATE_SCHEME, "").toUpperCase(Locale.ENGLISH);
	List<Type> types = new ArrayList<Type>();
	for (Type type : Type.values()) {
		if (TextUtils.indexOf(state, type.name()) != -1) {
			types.add(type);
		}
	}

	if (decorationStateListener != null) {
		decorationStateListener.onStateChangeListener(state, types);
	}
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:14,代码来源:RichEditor.java

示例7: clearAutocompleteSpanIfInvalid

import android.text.TextUtils; //导入方法依赖的package包/类
private void clearAutocompleteSpanIfInvalid() {
    Editable editableText = getEditableText();
    CharSequence previousUserText = mAutocompleteSpan.mUserText;
    CharSequence previousAutocompleteText = mAutocompleteSpan.mAutocompleteText;
    if (editableText.length()
            != (previousUserText.length() + previousAutocompleteText.length())) {
        mAutocompleteSpan.clearSpan();
    } else if (TextUtils.indexOf(getText(), previousUserText) != 0
            || TextUtils.indexOf(getText(),
                    previousAutocompleteText, previousUserText.length()) != 0) {
        mAutocompleteSpan.clearSpan();
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:14,代码来源:UrlBar.java

示例8: removeSeparators

import android.text.TextUtils; //导入方法依赖的package包/类
public static void removeSeparators(Editable s) {
    int index = TextUtils.indexOf(s, SEPARATOR);
    while (index >= 0) {
        s.delete(index, index + 1);
        index = TextUtils.indexOf(s, SEPARATOR, index + 1);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:8,代码来源:CreditCardNumberFormattingTextWatcher.java

示例9: stateCheck

import android.text.TextUtils; //导入方法依赖的package包/类
private void stateCheck(String text) {
  String state = text.replaceFirst(STATE_SCHEME, "").toUpperCase(Locale.ENGLISH);
  List<Type> types = new ArrayList<>();
  for (Type type : Type.values()) {
    if (TextUtils.indexOf(state, type.name()) != -1) {
      types.add(type);
    }
  }

  if (mDecorationStateListener != null) {
    mDecorationStateListener.onStateChangeListener(state, types);
  }
}
 
开发者ID:androidDaniel,项目名称:riched_editor_x5,代码行数:14,代码来源:RichEditor.java

示例10: onMeasure

import android.text.TextUtils; //导入方法依赖的package包/类
@SuppressLint({"DrawAllocation"})
protected void onMeasure(int i, int i2) {
    try {
        super.onMeasure(i, i2);
    } catch (Throwable e) {
        FirebaseCrash.report(e);
        setMeasuredDimension(MeasureSpec.getSize(i), AndroidUtilities.dp(51.0f));
        FileLog.e("tmessages", e);
    }
    this.f399b = null;
    if (this.f398a != null && this.f398a.length() > 0) {
        CharSequence text = getText();
        if (text.length() > 1 && text.charAt(0) == '@') {
            int indexOf = TextUtils.indexOf(text, ' ');
            if (indexOf != -1) {
                TextPaint paint = getPaint();
                int ceil = (int) Math.ceil((double) paint.measureText(text, 0, indexOf + 1));
                int measuredWidth = (getMeasuredWidth() - getPaddingLeft()) - getPaddingRight();
                this.f400c = text.subSequence(0, indexOf + 1).length();
                CharSequence ellipsize = TextUtils.ellipsize(this.f398a, paint, (float) (measuredWidth - ceil), TruncateAt.END);
                this.f401d = ceil;
                try {
                    this.f399b = new StaticLayout(ellipsize, getPaint(), measuredWidth - ceil, Alignment.ALIGN_NORMAL, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT, 0.0f, false);
                    if (this.f399b.getLineCount() > 0) {
                        this.f401d = (int) (((float) this.f401d) + (-this.f399b.getLineLeft(0)));
                    }
                    this.f402e = ((getMeasuredHeight() - this.f399b.getLineBottom(0)) / 2) + AndroidUtilities.dp(0.5f);
                } catch (Throwable e2) {
                    FirebaseCrash.report(e2);
                    FileLog.e("tmessages", e2);
                }
            }
        }
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:36,代码来源:EditTextCaption.java

示例11: withinBlockquoteConsecutive

import android.text.TextUtils; //导入方法依赖的package包/类
private static void withinBlockquoteConsecutive(Context context, StringBuilder out, Spanned text,
                                                int start, int end) {
    out.append("<p").append(getTextDirection(text, start, end)).append(">");
    int next;
    for (int i = start; i < end; i = next) {
        next = TextUtils.indexOf(text, '\n', i, end);
        if (next < 0) {
            next = end;
        }
        int nl = 0;
        while (next < end && text.charAt(next) == '\n') {
            nl++;
            next++;
        }
        withinParagraph(context, out, text, i, next - nl);
        if (nl == 1) {
            out.append("<br>\n");
        } else {
            for (int j = 2; j < nl; j++) {
                out.append("<br>");
            }
            if (next != end) {
                /* Paragraph should be closed and reopened */
                out.append("</p>\n");
                out.append("<p").append(getTextDirection(text, start, end)).append(">");
            }
        }
    }
    out.append("</p>\n");
}
 
开发者ID:Pixplicity,项目名称:HtmlCompat,代码行数:31,代码来源:HtmlCompat.java

示例12: stateCheck

import android.text.TextUtils; //导入方法依赖的package包/类
public void stateCheck(String text) {

        String state = text.replaceFirst(STATE_SCHEME, "").toUpperCase(Locale.ENGLISH);
        List<Type> types = new ArrayList<>();
        for (Type type : Type.values()) {
            if (TextUtils.indexOf(state, type.name()) != -1) {
                types.add(type);
            }
        }

        if (mStateChangeListener != null) {
            mStateChangeListener.onStateChangeListener(state, types);
        }
    }
 
开发者ID:nowandfurure,项目名称:richeditor,代码行数:15,代码来源:RichEditor.java

示例13: shouldOverrideUrlLoading

import android.text.TextUtils; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {

    String decode;
    try {
        decode = URLDecoder.decode(url, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        // No handling
        return false;
    }

    Log.e("decode",decode);

    if (TextUtils.indexOf(url, CALLBACK_SCHEME) == 0) {
        callback(decode);
        return true;
    } else if (TextUtils.indexOf(url, STATE_SCHEME) == 0) {
        stateCheck(decode);
        return true;
    }
    if(TextUtils.indexOf(url,LINK_CHANGE_SCHEME) == 0){
        linkChangeCallBack(decode);
        return true;
    }

    if(TextUtils.indexOf(url,IMAGE_CLICK_SCHEME) == 0){
        imageClickCallBack(decode);
        return true;
    }

    return super.shouldOverrideUrlLoading(view, url);
}
 
开发者ID:nowandfurure,项目名称:richeditor,代码行数:34,代码来源:RichEditor.java

示例14: setAutocompleteText

import android.text.TextUtils; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:52,代码来源:UrlBar.java

示例15: hasDashOrSpace

import android.text.TextUtils; //导入方法依赖的package包/类
public static boolean hasDashOrSpace(final CharSequence s, final int start,
        final int count) {
    return TextUtils.indexOf(s, " ", start, start + count) != -1
            || TextUtils.indexOf(s, "-", start, start + count) != -1;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:6,代码来源:CreditCardNumberFormattingTextWatcher.java


注:本文中的android.text.TextUtils.indexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。