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


Java TextUtils.copySpansFrom方法代码示例

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


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

示例1: terminateToken

import android.text.TextUtils; //导入方法依赖的package包/类
/**
 * Returns <code>text</code>, modified, if necessary, to ensure that
 * it ends with a token terminator (for example a space or comma).
 * It is a method from the MultiAutoCompleteTextView.Tokenizer interface.
 */
public CharSequence terminateToken(CharSequence text) {
    int i = text.length();

    while (i > 0 && text.charAt(i - 1) == ' ') {
        i--;
    }

    char c;
    if (i > 0 && ((c = text.charAt(i - 1)) == ',' || c == ';')) {
        return text;
    } else {
        // Use the same delimiter the user just typed.
        // This lets them have a mixture of commas and semicolons in their list.
        String separator = mLastSeparator + " ";
        if (text instanceof Spanned) {
            SpannableString sp = new SpannableString(text + separator);
            TextUtils.copySpansFrom((Spanned) text, 0, text.length(),
                                    Object.class, sp, 0);
            return sp;
        } else {
            return text + separator;
        }
    }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:30,代码来源:RecipientsEditor.java

示例2: terminateToken

import android.text.TextUtils; //导入方法依赖的package包/类
@Override
public CharSequence terminateToken(CharSequence text) {
    int i = text.length();

    while (i > 0 && text.charAt(i - 1) == ' ') {
        i--;
    }

    if (i > 0 && text.charAt(i - 1) == ' ') {
        return text;
    } else {
        if (text instanceof Spanned) {
            SpannableString sp = new SpannableString(text + " ");
            TextUtils.copySpansFrom((Spanned) text, 0, text.length(),
                    Object.class, sp, 0);
            return sp;
        } else {
            return text + " ";
        }
    }
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:22,代码来源:SpaceTokenizer.java

示例3: terminateToken

import android.text.TextUtils; //导入方法依赖的package包/类
@Override
public CharSequence terminateToken(CharSequence text) {
    int i = text.length();

    while (i > 0 && Character.isWhitespace(text.charAt(i - 1)) ) {
        i--;
    }

    if (i > 0 && Character.isWhitespace(text.charAt(i - 1)) ) {
        return text;
    } else {
        if (text instanceof Spanned) {
            SpannableString sp = new SpannableString(text + " ");
            TextUtils.copySpansFrom((Spanned) text, 0, text.length(),
                    Object.class, sp, 0);
            return sp;
        } else {
            return text + " ";
        }
    }
}
 
开发者ID:mithrilcoin-io,项目名称:EosCommander,代码行数:22,代码来源:WhitSpaceTokenizer.java

示例4: terminateToken

import android.text.TextUtils; //导入方法依赖的package包/类
public CharSequence terminateToken(CharSequence text) {
    int i = text.length();

    while (i > 0 && text.charAt(i - 1) == ' ') {
        i--;
    }

    if (i > 0 && text.charAt(i - 1) == ' ') {
        return text;
    } else {
        if (text instanceof Spanned) {
            SpannableString sp = new SpannableString(text + " ");
            TextUtils.copySpansFrom((Spanned) text, 0, text.length(),
                    Object.class, sp, 0);
            return sp;
        } else {
            return text + " ";
        }
    }
}
 
开发者ID:mecid,项目名称:robird-reborn,代码行数:21,代码来源:UsernameCompleteAdapter.java

示例5: terminateToken

import android.text.TextUtils; //导入方法依赖的package包/类
public CharSequence terminateToken(CharSequence text) {
    int i = text.length();
    int lastNonSpaceIdx = i-1;
    while (lastNonSpaceIdx >= 0 && text.charAt(lastNonSpaceIdx) == ' ') {
        --lastNonSpaceIdx;
    }
    if (lastNonSpaceIdx >= 0 && text.charAt(lastNonSpaceIdx-1) == ',') {
        return text;
    } else if (text instanceof Spanned) {
        SpannableString sp = new SpannableString(text + ",");
        TextUtils.copySpansFrom((Spanned) text, 0, text.length(), Object.class, sp, 0);
        return sp;
    } else {
        return text + ",";
    }
}
 
开发者ID:TryGhost,项目名称:Ghost-Android,代码行数:17,代码来源:ChipsEditText.java

示例6: terminateToken

import android.text.TextUtils; //导入方法依赖的package包/类
@Override
public CharSequence terminateToken(CharSequence text) {
    int i = text.length();
    while (i > 0 && text.charAt(i - 1) == ' ') {
        i--;
    }
    if (i > 0 && text.charAt(i - 1) == ' ') {
        return text;
    } else if (text instanceof Spanned) {
        SpannableString s = new SpannableString(text + " ");
        TextUtils.copySpansFrom((Spanned) text, 0, text.length(), Object.class, s, 0);
        return s;
    } else {
        return text + " ";
    }
}
 
开发者ID:Vavassor,项目名称:Tusky,代码行数:17,代码来源:MentionTokenizer.java

示例7: getInputFilterProhibitEmoji

import android.text.TextUtils; //导入方法依赖的package包/类
public  InputFilter getInputFilterProhibitEmoji()
 {
     InputFilter filter = new InputFilter() {
         @Override
         public CharSequence filter(CharSequence source, int start, int end,
                                    Spanned dest, int dstart, int dend)
{
             StringBuffer buffer = new StringBuffer();
             for (int i = start; i < end; i++)
	{
                 char codePoint = source.charAt(i);
                 if (!getIsEmoji(codePoint))
		{
                     buffer.append(codePoint);
                 }
		else
		{
			//  ToastUtil.show("群组昵称不能含有第三方表情");
                     i++;
                     continue;
                 }
             }
             if (source instanceof Spanned)
	{
                 SpannableString sp = new SpannableString(buffer);
                 TextUtils.copySpansFrom((Spanned) source, start, end, null,
								sp, 0);
                 return sp;
             }
	else
	{
                 return buffer;
             }
         }
     };
     return filter;
 }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:38,代码来源:ChatActivity.java

示例8: filter

import android.text.TextUtils; //导入方法依赖的package包/类
@Override
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend)
{
  char[] v = new char[end - start];
  TextUtils.getChars(source, start, end, v, 0);

  Spannable emojified = EmojiProvider.getInstance(view.getContext()).emojify(new String(v), view);

  if (source instanceof Spanned && emojified != null) {
    TextUtils.copySpansFrom((Spanned) source, start, end, null, emojified, 0);
  }

  return emojified;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:15,代码来源:EmojiFilter.java

示例9: filter

import android.text.TextUtils; //导入方法依赖的package包/类
@Nullable
@Override
public CharSequence filter(CharSequence source, int start, int end,
		Spanned dest, int dstart, int dend) {

	char[] v = new char[end - start];
	TextUtils.getChars(source, start, end, v, 0);
	Spannable emojified = EmojiProvider.getInstance(view.getContext())
			.emojify(new String(v), view);
	if (source instanceof Spanned && emojified != null) {
		TextUtils.copySpansFrom((Spanned) source, start, end, null,
				emojified, 0);
	}
	return emojified;
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:16,代码来源:EmojiFilter.java

示例10: show

import android.text.TextUtils; //导入方法依赖的package包/类
/**
 * Show the BluetoothChooserDialog.
 */
@VisibleForTesting
void show() {
    // Emphasize the origin.
    Profile profile = Profile.getLastUsedProfile();
    SpannableString origin = new SpannableString(mOrigin);
    OmniboxUrlEmphasizer.emphasizeUrl(
            origin, mActivity.getResources(), profile, mSecurityLevel, false, true, true);
    // Construct a full string and replace the origin text with emphasized version.
    SpannableString title =
            new SpannableString(mActivity.getString(R.string.bluetooth_dialog_title, mOrigin));
    int start = title.toString().indexOf(mOrigin);
    TextUtils.copySpansFrom(origin, 0, origin.length(), Object.class, title, start);

    String noneFound = mActivity.getString(R.string.bluetooth_not_found);

    SpannableString searching = SpanApplier.applySpans(
            mActivity.getString(R.string.bluetooth_searching),
            new SpanInfo("<link>", "</link>",
                    new BluetoothClickableSpan(LinkType.EXPLAIN_BLUETOOTH, mActivity)));

    String positiveButton = mActivity.getString(R.string.bluetooth_confirm_button);

    SpannableString statusIdleNoneFound = SpanApplier.applySpans(
            mActivity.getString(R.string.bluetooth_not_seeing_it_idle_none_found),
            new SpanInfo("<link1>", "</link1>",
                    new BluetoothClickableSpan(LinkType.EXPLAIN_BLUETOOTH, mActivity)),
            new SpanInfo("<link2>", "</link2>",
                    new BluetoothClickableSpan(LinkType.RESTART_SEARCH, mActivity)));

    SpannableString statusActive = SpanApplier.applySpans(
            mActivity.getString(R.string.bluetooth_not_seeing_it),
            new SpanInfo("<link>", "</link>",
                    new BluetoothClickableSpan(LinkType.EXPLAIN_BLUETOOTH, mActivity)));

    SpannableString statusIdleSomeFound = SpanApplier.applySpans(
            mActivity.getString(R.string.bluetooth_not_seeing_it_idle_some_found),
            new SpanInfo("<link1>", "</link1>",
                    new BluetoothClickableSpan(LinkType.EXPLAIN_BLUETOOTH, mActivity)),
            new SpanInfo("<link2>", "</link2>",
                    new BluetoothClickableSpan(LinkType.RESTART_SEARCH, mActivity)));

    ItemChooserDialog.ItemChooserLabels labels =
            new ItemChooserDialog.ItemChooserLabels(title, searching, noneFound, statusActive,
                    statusIdleNoneFound, statusIdleSomeFound, positiveButton);
    mItemChooserDialog = new ItemChooserDialog(mActivity, this, labels);

    mActivity.registerReceiver(mLocationModeBroadcastReceiver,
            new IntentFilter(LocationManager.MODE_CHANGED_ACTION));
    mIsLocationModeChangedReceiverRegistered = true;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:54,代码来源:BluetoothChooserDialog.java

示例11: show

import android.text.TextUtils; //导入方法依赖的package包/类
/**
 * Shows the UsbChooserDialog.
 *
 * @param activity Activity which is used for launching a dialog.
 * @param origin The origin for the site wanting to connect to the USB device.
 * @param securityLevel The security level of the connection to the site wanting to connect to
 *                      the USB device. For valid values see SecurityStateModel::SecurityLevel.
 */
@VisibleForTesting
void show(Activity activity, String origin, int securityLevel) {
    // Emphasize the origin.
    Profile profile = Profile.getLastUsedProfile();
    SpannableString originSpannableString = new SpannableString(origin);
    OmniboxUrlEmphasizer.emphasizeUrl(originSpannableString, activity.getResources(), profile,
            securityLevel, false /* isInternalPage */, true /* useDarkColors */,
            true /* emphasizeHttpsScheme */);
    // Construct a full string and replace the origin text with emphasized version.
    SpannableString title =
            new SpannableString(activity.getString(R.string.usb_chooser_dialog_prompt, origin));
    int start = title.toString().indexOf(origin);
    TextUtils.copySpansFrom(originSpannableString, 0, originSpannableString.length(),
            Object.class, title, start);

    String searching = "";
    String noneFound = activity.getString(R.string.usb_chooser_dialog_no_devices_found_prompt);
    SpannableString statusActive =
            SpanApplier.applySpans(
                    activity.getString(R.string.usb_chooser_dialog_footnote_text),
                    new SpanInfo("<link>", "</link>", new NoUnderlineClickableSpan() {
                        @Override
                        public void onClick(View view) {
                            if (mNativeUsbChooserDialogPtr == 0) {
                                return;
                            }

                            nativeLoadUsbHelpPage(mNativeUsbChooserDialogPtr);

                            // Get rid of the highlight background on selection.
                            view.invalidate();
                        }
                    }));
    SpannableString statusIdleNoneFound = statusActive;
    SpannableString statusIdleSomeFound = statusActive;
    String positiveButton = activity.getString(R.string.usb_chooser_dialog_connect_button_text);

    ItemChooserDialog.ItemChooserLabels labels =
            new ItemChooserDialog.ItemChooserLabels(title, searching, noneFound, statusActive,
                    statusIdleNoneFound, statusIdleSomeFound, positiveButton);
    mItemChooserDialog = new ItemChooserDialog(activity, this, labels);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:51,代码来源:UsbChooserDialog.java

示例12: filter

import android.text.TextUtils; //导入方法依赖的package包/类
public CharSequence filter(CharSequence source) {
    StringBuilder output = new StringBuilder(source);
    final int sourceLength = source.length();

    for (int i = 0; i < sourceLength; i++) {
        char c = source.charAt(i);

        // Character requires Unicode, try to replace it
        if (!mStripNonDecodableOnly || !gsm.canEncode(c)) {
            String s = String.valueOf(c);

            // Try normalizing the character into Unicode NFKD form and
            // stripping out diacritic mark characters.
            s = Normalizer.normalize(s, Normalizer.Form.NFKD);
            s = diacritics.matcher(s).replaceAll("");

            // Special case characters that don't get stripped by the
            // above technique.
            s = s.replace("Œ", "OE");
            s = s.replace("œ", "oe");
            s = s.replace("Ł", "L");
            s = s.replace("ł", "l");
            s = s.replace("Đ", "DJ");
            s = s.replace("đ", "dj");
            s = s.replace("Α", "A");
            s = s.replace("Β", "B");
            s = s.replace("Ε", "E");
            s = s.replace("Ζ", "Z");
            s = s.replace("Η", "H");
            s = s.replace("Ι", "I");
            s = s.replace("Κ", "K");
            s = s.replace("Μ", "M");
            s = s.replace("Ν", "N");
            s = s.replace("Ο", "O");
            s = s.replace("Ρ", "P");
            s = s.replace("Τ", "T");
            s = s.replace("Υ", "Y");
            s = s.replace("Χ", "X");
            s = s.replace("α", "A");
            s = s.replace("β", "B");
            s = s.replace("γ", "Γ");
            s = s.replace("δ", "Δ");
            s = s.replace("ε", "E");
            s = s.replace("ζ", "Z");
            s = s.replace("η", "H");
            s = s.replace("θ", "Θ");
            s = s.replace("ι", "I");
            s = s.replace("κ", "K");
            s = s.replace("λ", "Λ");
            s = s.replace("μ", "M");
            s = s.replace("ν", "N");
            s = s.replace("ξ", "Ξ");
            s = s.replace("ο", "O");
            s = s.replace("π", "Π");
            s = s.replace("ρ", "P");
            s = s.replace("σ", "Σ");
            s = s.replace("τ", "T");
            s = s.replace("υ", "Y");
            s = s.replace("φ", "Φ");
            s = s.replace("χ", "X");
            s = s.replace("ψ", "Ψ");
            s = s.replace("ω", "Ω");
            s = s.replace("ς", "Σ");

            output.replace(i, i + 1, s);
        }
    }

    // Source is a spanned string, so copy the spans from it
    if (source instanceof Spanned) {
        SpannableString spannedoutput = new SpannableString(output);
        TextUtils.copySpansFrom(
                (Spanned) source, 0, sourceLength, null, spannedoutput, 0);

        return spannedoutput;
    }

    // Source is a vanilla charsequence, so return output as-is
    return output.toString();
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:81,代码来源:UnicodeFilter.java


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