Java Code Examples for android.text.SpannableStringBuilder

The following are top voted examples for showing how to use android.text.SpannableStringBuilder. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: SciChart.Android.Examples   File: CustomTooltipsWithModifiersFragment.java   Source Code and License 6 votes vote down vote up
@Override
protected void internalUpdate(XySeriesInfo seriesInfo) {
    final SpannableStringBuilder sb = new SpannableStringBuilder();

    sb.append("X: ").append(seriesInfo.getFormattedXValue()).append(StringUtil.NEW_LINE);
    sb.append("Y: ").append(seriesInfo.getFormattedYValue()).append(StringUtil.NEW_LINE);

    if (seriesInfo.seriesName != null) {
        final int start = sb.length();

        sb.append(seriesInfo.seriesName);
        sb.setSpan(new ForegroundColorSpan(ColorUtil.White), start, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        sb.append(StringUtil.NEW_LINE);
    }
    sb.append(modifierName);
    setText(sb);

    // stroke 0xff4d81dd
    setSeriesColor(0xff6495ed);
}
 
Example 2
Project: q-mail   File: NotificationContentCreator.java   Source Code and License 6 votes vote down vote up
private CharSequence getMessagePreview(LocalMessage message) {
    String subject = message.getSubject();
    String snippet = getPreview(message);

    boolean isSubjectEmpty = TextUtils.isEmpty(subject);
    boolean isSnippetPresent = snippet != null;
    if (isSubjectEmpty && isSnippetPresent) {
        return snippet;
    }

    String displaySubject = getMessageSubject(message);

    SpannableStringBuilder preview = new SpannableStringBuilder();
    preview.append(displaySubject);
    if (isSnippetPresent) {
        preview.append('\n');
        preview.append(snippet);
    }
    
    return preview;
}
 
Example 3
Project: mongol-library   File: MongolTextView.java   Source Code and License 6 votes vote down vote up
public MongolTextView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MongolTextView, defStyleAttr, 0);

    boolean isEditText = getDefaultEditable();
    String text = a.getString(R.styleable.MongolTextView_text);
    if (text == null) text = "";
    if (isEditText) {
        SpannableStringBuilder ssb = new SpannableStringBuilder(text);
        mTextStorage = new MongolTextStorage(ssb);
    } else {
        mTextStorage = new MongolTextStorage(text);
    }
    mTextSizePx = a.getDimensionPixelSize(R.styleable.MongolTextView_textSize, 0);
    mTextColor = a.getColor(R.styleable.MongolTextView_textColor, Color.BLACK);
    mGravity = a.getInteger(R.styleable.MongolTextView_gravity, Gravity.TOP);
    a.recycle();

    mContext = context;
    init();
}
 
Example 4
Project: Cable-Android   File: SingleRecipientNotificationBuilder.java   Source Code and License 6 votes vote down vote up
public void setPrimaryMessageBody(@NonNull  Recipients threadRecipients,
                                  @NonNull  Recipient individualRecipient,
                                  @NonNull  CharSequence message,
                                  @Nullable SlideDeck slideDeck)
{
  SpannableStringBuilder stringBuilder = new SpannableStringBuilder();

  if (privacy.isDisplayContact() && (threadRecipients.isGroupRecipient() || !threadRecipients.isSingleRecipient())) {
    stringBuilder.append(Util.getBoldedString(individualRecipient.toShortString() + ": "));
  }

  if (privacy.isDisplayMessage()) {
    setContentText(stringBuilder.append(message));
    this.slideDeck = slideDeck;
  } else {
    setContentText(stringBuilder.append(context.getString(R.string.SingleRecipientNotificationBuilder_new_message)));
  }
}
 
Example 5
Project: SDHtmlTextView   File: ImageHandler.java   Source Code and License 6 votes vote down vote up
@Override
public void handleTagNode(TagNode node, SpannableStringBuilder builder,
		int start, int end, SpanStack stack) {
	String src = node.getAttributeByName("src");

	builder.append("\uFFFC");

	Bitmap bitmap = loadBitmap(src);

	if (bitmap != null) {
		Drawable drawable = new BitmapDrawable(bitmap);
		drawable.setBounds(0, 0, bitmap.getWidth() - 1,
				bitmap.getHeight() - 1);

           stack.pushSpan( new ImageSpan(drawable), start, builder.length() );
	}
}
 
Example 6
Project: LiveGiftLayout   File: ExpressionUtil.java   Source Code and License 6 votes vote down vote up
public void setView(Context mContext, final View view, String content) {
    if (view != null && view instanceof ImageView) {//图片不显示GIF
        Bitmap bitmap = null;
        try {
            bitmap = BitmapFactory.decodeStream(mContext.getAssets().open(content));
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        ((ImageView) view).setImageBitmap(bitmap);
    } else if (view != null && view instanceof TextView) {//文字可显示GIF
        TextView gifTextView = (TextView) view;
        String tempText = "[" + content + "]";
        SpannableStringBuilder sb = prase(mContext, gifTextView, tempText);
        gifTextView.setText(sb);
    }

}
 
Example 7
Project: Nird2   File: UiUtils.java   Source Code and License 6 votes vote down vote up
public static SpannableStringBuilder getTeaser(Context ctx, Spanned body) {
	if (body.length() < TEASER_LENGTH)
		throw new IllegalArgumentException(
				"String is shorter than TEASER_LENGTH");

	SpannableStringBuilder builder =
			new SpannableStringBuilder(body.subSequence(0, TEASER_LENGTH));
	String ellipsis = ctx.getString(R.string.ellipsis);
	builder.append(ellipsis).append(" ");

	Spannable readMore = new SpannableString(
			ctx.getString(R.string.read_more) + ellipsis);
	ForegroundColorSpan fg = new ForegroundColorSpan(
			ContextCompat.getColor(ctx, R.color.briar_text_link));
	readMore.setSpan(fg, 0, readMore.length(),
			Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
	builder.append(readMore);

	return builder;
}
 
Example 8
Project: RLibrary   File: RExTextView.java   Source Code and License 6 votes vote down vote up
/**
 * 匹配 电话号码
 */
protected void patternPhone(SpannableStringBuilder builder, CharSequence input) {
    Matcher matcher = patternPhone.matcher(input);

    while (matcher.find()) {
        int start = matcher.start();
        int end = matcher.end();

        if (!isInOtherSpan(builder, input.length(), start, end)) {
            builder.setSpan(new ImageTextSpan(getContext(), ImageTextSpan.initDrawable(getTextSize()),
                            matcher.group(), matcher.group())
                            .setOnImageSpanClick(mOnImageSpanClick)
                            .setTextColor(mImageSpanTextColor),
                    start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
}
 
Example 9
Project: PSNine   File: JellyBeanSpanFixTextView.java   Source Code and License 6 votes vote down vote up
/**
 * Add spaces around spans until the text is fixed, and then removes the unneeded spaces
 */
private void fixSpannedWithSpaces(SpannableStringBuilder builder, int widthMeasureSpec,
                                  int heightMeasureSpec) {
    long startFix = System.currentTimeMillis();

    FixingResult result = addSpacesAroundSpansUntilFixed(builder, widthMeasureSpec,
            heightMeasureSpec);

    if (result.fixed) {
        removeUnneededSpaces(widthMeasureSpec, heightMeasureSpec, builder, result);
    } else {
        fallbackToString(widthMeasureSpec, heightMeasureSpec);
    }

    if (HtmlTextView.DEBUG) {
        long fixDuration = System.currentTimeMillis() - startFix;
        Log.d(HtmlTextView.TAG, "fixSpannedWithSpaces() duration in ms: " + fixDuration);
    }
}
 
Example 10
Project: RLibrary   File: RExTextView.java   Source Code and License 6 votes vote down vote up
@Override
public void setText(CharSequence text, BufferType type) {
    if (isInEditMode()) {
        super.setText(text, type);
        return;
    }
    if (TextUtils.isEmpty(text)) {
        super.setText(text, type);
    } else {
        SpannableStringBuilder spanBuilder = new SpannableStringBuilder(text);
        if (needPatternUrl) {
            patternUrl(spanBuilder, text);//优先匹配
        }
        if (needPatternMention) {
            patternMention(spanBuilder, text);
        }
        if (needPatternPhone) {
            patternPhone(spanBuilder, text);
        }
        afterPattern(spanBuilder, text);
        super.setText(spanBuilder, type);
    }
}
 
Example 11
Project: FastTextView   File: EllipseFragment.java   Source Code and License 6 votes vote down vote up
@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
    if (mRootView != null) {
      return mRootView;
    }
    mRootView = inflater.inflate(R.layout.ellipse_demo, container, false);
    SpannableStringBuilder spannableStringBuilder = getSpannable();
    FastTextView fastTextView = (FastTextView) mRootView.findViewById(R.id.fast_tv2);
    fastTextView.setText(spannableStringBuilder);
//    fastTextView.setCustomEllipsisSpan(new ImageSpan(drawable));

    TextView tv = (TextView) mRootView.findViewById(R.id.system_tv);
    tv.setText(spannableStringBuilder);
//    tv.setMovementMethod(LinkMovementMethod.getInstance());


    return mRootView;
  }
 
Example 12
Project: okwallet   File: RequestCoinsFragment.java   Source Code and License 6 votes vote down vote up
private void updateView() {
    if (!isResumed())
        return;

    final String bitcoinRequest = determineBitcoinRequestStr(true);
    final byte[] paymentRequest = determinePaymentRequest(true);

    // update qr-code
    qrCodeBitmap = new BitmapDrawable(getResources(), Qr.bitmap(bitcoinRequest));
    qrCodeBitmap.setFilterBitmap(false);
    qrView.setImageDrawable(qrCodeBitmap);

    // update initiate request message
    final SpannableStringBuilder initiateText = new SpannableStringBuilder(
            getString(R.string.request_coins_fragment_initiate_request_qr));
    if (nfcAdapter != null && nfcAdapter.isEnabled())
        initiateText.append(' ').append(getString(R.string.request_coins_fragment_initiate_request_nfc));
    initiateRequestView.setText(initiateText);

    // focus linking
    final int activeAmountViewId = amountCalculatorLink.activeTextView().getId();
    acceptBluetoothPaymentView.setNextFocusUpId(activeAmountViewId);

    paymentRequestRef.set(paymentRequest);
}
 
Example 13
Project: ShangHanLun   File: ATableViewAdapter.java   Source Code and License 6 votes vote down vote up
@Override
public void configurePinnedHeader(View headerView, int position, int alpaha) {
    // TODO Auto-generated method stub
    TextView label = (TextView) headerView.findViewById(R.id.textLabel);
    NSIndexPath ip = getIndexPath(position);
    curSection = ip.getSection();
    String t = mTableView.getDataSource().titleForHeaderInSection(
            mTableView, curSection);
    if (t != null) {
        label.setText(t);
    } else {
        SpannableStringBuilder buider = mTableView.getDataSource()
                .spannerbleTitleForHeaderInSection(mTableView, curSection);
        label.setText(buider);
    }
    // huanghai
    label.setTextColor(Color.BLACK);
    label.setGravity(Gravity.CENTER_VERTICAL);
}
 
Example 14
Project: sealtalk-android-master   File: CharacterParser.java   Source Code and License 6 votes vote down vote up
public SpannableStringBuilder getColoredChattingRecord(String filterStr, MessageContent messageContent) {
    SpannableStringBuilder messageText = new SpannableStringBuilder();
    if (messageContent instanceof TextMessage) {
        TextMessage textMessage = (TextMessage) messageContent;
        String textMessageContent = textMessage.getContent();
        messageText = getOmitColored(filterStr, textMessageContent, 0);
    }
    if (messageContent instanceof RichContentMessage) {
        RichContentMessage richContentMessage = (RichContentMessage) messageContent;
        String messageTitle = richContentMessage.getTitle();
        messageText = getOmitColored(filterStr, messageTitle, 1);
        if (messageText.length() == 0) {
            SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder("[链接] ");
            spannableStringBuilder.append(messageTitle);
            messageText = spannableStringBuilder;
        }
    }
    if (messageContent instanceof FileMessage) {
        FileMessage fileMessage = (FileMessage) messageContent;
        String fileName = fileMessage.getName();
        messageText = getOmitColored(filterStr, fileName, 2);
    }
    return messageText;
}
 
Example 15
Project: SciChart.Android.Examples   File: CustomTooltipsWithModifiersFragment.java   Source Code and License 6 votes vote down vote up
@Override
protected void internalUpdate(XySeriesInfo seriesInfo) {
    final SpannableStringBuilder sb = new SpannableStringBuilder();
    sb.append(modifierName).append(StringUtil.NEW_LINE);

    if (seriesInfo.seriesName != null) {
        sb.append(seriesInfo.seriesName);
        sb.setSpan(new ForegroundColorSpan(ColorUtil.Black), 0, sb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        sb.append(StringUtil.NEW_LINE);
    }

    sb.append("X: ").append(seriesInfo.getFormattedXValue());
    sb.append(" Y: ").append(seriesInfo.getFormattedYValue());

    setText(sb);

    // stroke 0xffff4500
    setSeriesColor(0xffe2460c);
}
 
Example 16
Project: lex   File: LexList.java   Source Code and License 6 votes vote down vote up
@NonNull
private CharSequence makeThreeOrMoreItems() {
    if (separator == null) {
        throw new LexNoSeparatorException();
    }

    SpannableStringBuilder sb = new SpannableStringBuilder(getWrappedItem(0));
    for (int i = 1; i < items.length; i++) {
        if (i == items.length - 1 && lastItemSeparator != null) {
            sb.append(lastItemSeparator);
        } else {
            sb.append(separator);
        }
        sb.append(getWrappedItem(i));
    }
    return sb;
}
 
Example 17
Project: Phoenix-for-VK   File: PreferencesFragment.java   Source Code and License 6 votes vote down vote up
private void disableOnlyFullAppPrefs() {
    String fullOnly = " FULL ONLY ";
    int color = Utils.adjustAlpha(CurrentTheme.getColorAccent(getActivity()), 100);

    for (String name : AppPrefs.ONLY_FULL_APP_PREFS) {
        Preference preference = findPreference(name);
        if (preference != null) {
            preference.setEnabled(false);

            CharSequence summary = TextUtils.isEmpty(preference.getTitle()) ? "" : preference.getTitle();
            summary = fullOnly + " " + summary;

            Spannable spannable = SpannableStringBuilder.valueOf(summary);

            BackgroundColorSpan span = new BackgroundColorSpan(color);
            ForegroundColorSpan span1 = new ForegroundColorSpan(Color.WHITE);

            spannable.setSpan(span, 0, fullOnly.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            spannable.setSpan(span1, 0, fullOnly.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            preference.setTitle(spannable);
        }
    }
}
 
Example 18
Project: PeSanKita-android   File: SingleRecipientNotificationBuilder.java   Source Code and License 6 votes vote down vote up
public void setPrimaryMessageBody(@NonNull  Recipients threadRecipients,
                                  @NonNull  Recipient individualRecipient,
                                  @NonNull  CharSequence message,
                                  @Nullable SlideDeck slideDeck)
{
  SpannableStringBuilder stringBuilder = new SpannableStringBuilder();

  if (privacy.isDisplayContact() && (threadRecipients.isGroupRecipient() || !threadRecipients.isSingleRecipient())) {
    stringBuilder.append(Util.getBoldedString(individualRecipient.toShortString() + ": "));
  }

  if (privacy.isDisplayMessage()) {
    setContentText(stringBuilder.append(message));
    this.slideDeck = slideDeck;
  } else {
    setContentText(stringBuilder.append(context.getString(R.string.SingleRecipientNotificationBuilder_new_message)));
  }
}
 
Example 19
Project: PeSanKita-android   File: SingleRecipientNotificationBuilder.java   Source Code and License 6 votes vote down vote up
public void addMessageBody(@NonNull Recipients threadRecipients,
                           @NonNull Recipient individualRecipient,
                           @Nullable CharSequence messageBody)
{
  SpannableStringBuilder stringBuilder = new SpannableStringBuilder();

  if (privacy.isDisplayContact() && (threadRecipients.isGroupRecipient() || !threadRecipients.isSingleRecipient())) {
    stringBuilder.append(Util.getBoldedString(individualRecipient.toShortString() + ": "));
  }

  if (privacy.isDisplayMessage()) {
    messageBodies.add(stringBuilder.append(messageBody == null ? "" : messageBody));
  } else {
    messageBodies.add(stringBuilder.append(context.getString(R.string.SingleRecipientNotificationBuilder_new_message)));
  }
}
 
Example 20
Project: PeSanKita-android   File: ComposeText.java   Source Code and License 6 votes vote down vote up
public void setHint(@NonNull String hint, @Nullable CharSequence subHint) {
  this.hint = new SpannableString(hint);
  this.hint.setSpan(new RelativeSizeSpan(0.8f), 0, hint.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);

  if (subHint != null) {
    this.subHint = new SpannableString(subHint);
    this.subHint.setSpan(new RelativeSizeSpan(0.8f), 0, subHint.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
  } else {
    this.subHint = null;
  }

  if (this.subHint != null) {
    super.setHint(new SpannableStringBuilder().append(ellipsizeToWidth(this.hint))
                                              .append("\n")
                                              .append(ellipsizeToWidth(this.subHint)));
  } else {
    super.setHint(ellipsizeToWidth(this.hint));
  }
}
 
Example 21
Project: PeSanKita-android   File: FromTextView.java   Source Code and License 6 votes vote down vote up
public void setText(Recipients recipients, boolean read) {
  int        attributes[] = new int[]{R.attr.conversation_list_item_count_color};
  TypedArray colors       = getContext().obtainStyledAttributes(attributes);
  String     fromString   = recipients.toShortString();

  int typeface;

  if (!read) {
    typeface = Typeface.BOLD;
  } else {
    typeface = Typeface.NORMAL;
  }

  SpannableStringBuilder builder = new SpannableStringBuilder(fromString);
  builder.setSpan(new StyleSpan(typeface), 0, builder.length(),
                  Spannable.SPAN_INCLUSIVE_EXCLUSIVE);

  colors.recycle();

  setText(builder);

  if      (recipients.isBlocked()) setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_block_grey600_18dp, 0, 0, 0);
  else if (recipients.isMuted())   setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_volume_off_grey600_18dp, 0, 0, 0);
  else                             setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
}
 
Example 22
Project: Aequorea   File: RichText.java   Source Code and License 6 votes vote down vote up
/**
 * 生成富文本
 *
 * @return Spanned
 */
private CharSequence generateRichText() {
    TextView textView = textViewSoftReference.get();
    if (textView == null) {
        return null;
    }
    if (config.richType != RichType.MARKDOWN) {
        analyzeImages(config.source);
    } else {
        imageHolderMap = new HashMap<>();
    }
    SpannableStringBuilder spannableStringBuilder = null;
    if (config.cacheType > CacheType.NONE) {
        spannableStringBuilder = RichTextPool.getPool().loadCache(config.source);
    }
    if (spannableStringBuilder == null) {
        spannableStringBuilder = parseRichText();
    }
    richText = new SoftReference<>(spannableStringBuilder);
    config.imageGetter.registerImageLoadNotify(this);
    cachedSpannedParser.setAccentColor(getAccentColor(textView.getContext()));
    count = cachedSpannedParser.parse(spannableStringBuilder, this, config);
    return spannableStringBuilder;
}
 
Example 23
Project: Cable-Android   File: FromTextView.java   Source Code and License 6 votes vote down vote up
public void setText(Recipients recipients, boolean read) {
  int        attributes[] = new int[]{R.attr.conversation_list_item_count_color};
  TypedArray colors       = getContext().obtainStyledAttributes(attributes);
  String     fromString   = recipients.toShortString();

  int typeface;

  if (!read) {
    typeface = Typeface.BOLD;
  } else {
    typeface = Typeface.NORMAL;
  }

  SpannableStringBuilder builder = new SpannableStringBuilder(fromString);
  builder.setSpan(new StyleSpan(typeface), 0, builder.length(),
                  Spannable.SPAN_INCLUSIVE_EXCLUSIVE);

  colors.recycle();

  setText(builder);

  if      (recipients.isBlocked()) setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_block_grey600_18dp, 0, 0, 0);
  else if (recipients.isMuted())   setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_volume_off_grey600_18dp, 0, 0, 0);
  else                             setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
}
 
Example 24
Project: browser   File: CCPActivityBase.java   Source Code and License 6 votes vote down vote up
/**
 *
 */
protected SpannableString buildActionTitle() {
    int dimensionPixelSize = mActionBarActivity.getResources().getDimensionPixelSize(R.dimen.BigTextSize);

    int mutIndex = 0;
    String format = "%s";
    if(isMute) {
        format = format + " #";
        mutIndex += 2;
    }

    SpannableString spannableString = new SpannableString(mTitleText);
    //EmoticonUtil.getTextFormat(mActionBarActivity, String.format(format, new Object[]{mTitleText}), dimensionPixelSize);
    if(isMute) {
        if(mMuteIcon == null) {
            mMuteIcon = getTitleIconTips(dimensionPixelSize, R.drawable.chat_mute_notify_title_icon);
        }
        int length = spannableString.length() - mutIndex + 1;
        spannableString.setSpan(mMuteIcon, length, length + 1, SpannableStringBuilder.SPAN_POINT_MARK);
    }
    return spannableString;
}
 
Example 25
Project: LucaHome-AndroidApplication   File: ShoppingListEditActivity.java   Source Code and License 5 votes vote down vote up
/**
 * Build a custom error text
 */
private SpannableStringBuilder createErrorText(@NonNull String errorString) {
    ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(Color.RED);
    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(errorString);
    spannableStringBuilder.setSpan(foregroundColorSpan, 0, errorString.length(), 0);
    return spannableStringBuilder;
}
 
Example 26
Project: xifan   File: PatternUtils.java   Source Code and License 5 votes vote down vote up
private static SpannableStringBuilder getUrlTextSpannableString(Context context, String source,
        int size) {
    SpannableStringBuilder builder = new SpannableStringBuilder(source);
    String prefix = " ";
    builder.replace(0, prefix.length(), prefix);
    Drawable drawable = context.getResources().getDrawable(R.mipmap.ic_status_link);
    drawable.setBounds(0, 0, size, size);
    builder.setSpan(new VerticalImageSpan(drawable), prefix.length(), source.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    builder.append(App.getInstance().getString(R.string.text_url_link));
    return builder;
}
 
Example 27
Project: mongol-library   File: MongolTextStorage.java   Source Code and License 5 votes vote down vote up
@Override
public void removeSpan(Object what) {
    if (!(mUnicodeText instanceof Spanned)) {
        return;
    }
    if (!(mUnicodeText instanceof SpannableStringBuilder)) {
        return;
    }
    ((SpannableStringBuilder) mUnicodeText).removeSpan(what);
    ((SpannableStringBuilder) mGlyphText).removeSpan(what);

    final int length = mUnicodeText.length();
    if (mChangelistener != null)
        mChangelistener.onSpanChanged((Spanned) mUnicodeText, what, 0, 0, length, length);
}
 
Example 28
Project: BookLoadingView   File: JumpingBeans.java   Source Code and License 5 votes vote down vote up
private JumpingBeansSpan[] getJumpingBeansSpans(SpannableStringBuilder sbb) {
    JumpingBeansSpan[] spans;
    if (waveCharDelay == -1) {
        waveCharDelay = loopDuration / (3 * (endPos - startPos));
    }

    spans = new JumpingBeansSpan[endPos - startPos];
    for (int pos = startPos; pos < endPos; pos++) {
        JumpingBeansSpan jumpingBean =
                new JumpingBeansSpan(textView, loopDuration, pos - startPos, waveCharDelay, animRange);
        sbb.setSpan(jumpingBean, pos, pos + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        spans[pos - startPos] = jumpingBean;
    }
    return spans;
}
 
Example 29
Project: LucaHome-AndroidApplication   File: WirelessSwitchEditActivity.java   Source Code and License 5 votes vote down vote up
/**
 * Build a custom error text
 */
private SpannableStringBuilder createErrorText(@NonNull String errorString) {
    ForegroundColorSpan foregroundColorSpan = new ForegroundColorSpan(Color.RED);
    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(errorString);
    spannableStringBuilder.setSpan(foregroundColorSpan, 0, errorString.length(), 0);
    return spannableStringBuilder;
}
 
Example 30
Project: Android-Spans   File: Span.java   Source Code and License 5 votes vote down vote up
android.text.Spannable build(SpannableStringBuilder builder) {
    if (nodes != null) {
        for (Object child : nodes) {
            if (child instanceof Span) {
                ((Span) child).build(builder);
            } else {
                builder.append(child.toString());
            }
        }
    }
    return builder;
}
 
Example 31
Project: Slide-RSS   File: SpoilerRobotoTextView.java   Source Code and License 5 votes vote down vote up
private static SpannableStringBuilder removeNewlines(SpannableStringBuilder s) {
    int start = 0;
    int end = s.length();
    while (start < end && Character.isWhitespace(s.charAt(start))) {
        start++;
    }

    while (end > start && Character.isWhitespace(s.charAt(end - 1))) {
        end--;
    }

    return (SpannableStringBuilder) s.subSequence(start, end);
}
 
Example 32
Project: QMUI_Android   File: QMUISpanHelper.java   Source Code and License 5 votes vote down vote up
/**
 * 在text左边或者右边添加icon,
 * 默认TextView添加leftDrawable或rightDrawable不能适应TextView match_parent的情况
 *
 * @param left true 则在文字左边添加 icon,false 则在文字右边添加 icon
 * @param text 文字内容
 * @param icon 需要被添加的 icon
 * @return 返回带有 icon 的文字
 */
public static CharSequence generateSideIconText(boolean left, int iconPadding, CharSequence text, Drawable icon) {
    if (icon == null) {
        return text;
    }

    icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
    String iconTag = "[icon]";
    SpannableStringBuilder builder = new SpannableStringBuilder();
    int start, end;
    if (left) {
        start = 0;
        builder.append(iconTag);
        end = builder.length();
        builder.append(text);
    } else {
        builder.append(text);
        start = builder.length();
        builder.append(iconTag);
        end = builder.length();
    }

    QMUIMarginImageSpan imageSpan;

    if (left) {
        imageSpan = new QMUIMarginImageSpan(icon, QMUIAlignMiddleImageSpan.ALIGN_MIDDLE, 0, iconPadding);
    } else {
        imageSpan = new QMUIMarginImageSpan(icon, QMUIAlignMiddleImageSpan.ALIGN_MIDDLE, iconPadding, 0);
    }

    builder.setSpan(imageSpan, start, end, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
    imageSpan.setAvoidSuperChangeFontMetrics(true);
    return builder;
}
 
Example 33
Project: mongol-library   File: MongolTextStorage.java   Source Code and License 5 votes vote down vote up
@Override
public void setFilters(InputFilter[] filters) {
    if (!(mUnicodeText instanceof SpannableStringBuilder)) {
        return;
    }
    // TODO: this is untested!
    int oldLength = mUnicodeText.length();
    ((SpannableStringBuilder) mUnicodeText).setFilters(filters);
    ((SpannableStringBuilder) mGlyphText).setFilters(filters);
    if (mChangelistener != null)
        mChangelistener.onTextChanged(mUnicodeText, 0, oldLength, mUnicodeText.length());
}
 
Example 34
Project: SciChart.Android.Examples   File: CustomizationRolloverModifierTooltipsFragment.java   Source Code and License 5 votes vote down vote up
@Override
protected boolean updateInternal(AxisInfo axisInfo) {
    final SpannableStringBuilder sb = new SpannableStringBuilder();
    sb.append("Axis ID: ").append(axisInfo.axisId).append(StringUtil.NEW_LINE);
    sb.append("Value: ").append(axisInfo.axisFormattedDataValue);

    setText(sb);

    return true;
}
 
Example 35
Project: orgzly-android   File: UserTimeFormatter.java   Source Code and License 5 votes vote down vote up
public CharSequence formatAll(OrgRange time) {
    SpannableStringBuilder s = new SpannableStringBuilder();

    s.append(formatAll(time.getStartTime()));

    if (time.getEndTime() != null) {
        s.append(" — ");
        s.append(formatAll(time.getEndTime()));
    }

    return s;
}
 
Example 36
Project: RNLearn_Project1   File: RCTVirtualText.java   Source Code and License 5 votes vote down vote up
@Override
protected void performApplySpans(SpannableStringBuilder builder, int begin, int end, boolean isEditable) {
  mFontStylingSpan.freeze();

  // All spans will automatically extend to the right of the text, but not the left - except
  // for spans that start at the beginning of the text.
  final int flag;
  if (isEditable) {
    flag = Spannable.SPAN_EXCLUSIVE_EXCLUSIVE;
  } else {
    flag = begin == 0 ?
        Spannable.SPAN_INCLUSIVE_INCLUSIVE :
        Spannable.SPAN_EXCLUSIVE_INCLUSIVE;
  }

  builder.setSpan(
      mFontStylingSpan,
      begin,
      end,
      flag);

  if (mShadowStyleSpan.getColor() != 0 && mShadowStyleSpan.getRadius() != 0) {
    mShadowStyleSpan.freeze();

    builder.setSpan(
        mShadowStyleSpan,
        begin,
        end,
        flag);
  }

  for (int i = 0, childCount = getChildCount(); i < childCount; ++i) {
    FlatTextShadowNode child = (FlatTextShadowNode) getChildAt(i);
    child.applySpans(builder, isEditable);
  }
}
 
Example 37
Project: anitrend-app   File: MarkDown.java   Source Code and License 5 votes vote down vote up
private static SpannableStringBuilder fromMD(String content) {
    if(content == null)
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
            return (SpannableStringBuilder) Html.fromHtml("<b>No content available</b>", Html.FROM_HTML_MODE_COMPACT | Html.FROM_HTML_OPTION_USE_CSS_COLORS | Html.FROM_HTML_SEPARATOR_LINE_BREAK_LIST);
        else return (SpannableStringBuilder) Html.fromHtml("<b>No content available</b>");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
        return (SpannableStringBuilder) Html.fromHtml(Processor.process(content), Html.FROM_HTML_MODE_COMPACT | Html.FROM_HTML_OPTION_USE_CSS_COLORS | Html.FROM_HTML_SEPARATOR_LINE_BREAK_LIST);
    else return (SpannableStringBuilder) Html.fromHtml(Processor.process(content));
}
 
Example 38
Project: QMark   File: EditSourceListAdapter.java   Source Code and License 5 votes vote down vote up
@Override
public void bind(int position, EditSourceListBean data) {
	mFB.display(mImgBg, data.imgBgUrl);
	mFB.display(mImgCatgy, data.ImgCatgyUrl);
	mTextLeft.setText(data.textLeft);
	Resources resources = getView().getResources();
	SpannableStringBuilder spans = new SpannableStringBuilder(resources.getString(R.string.i_m_category_text_sign_count, data.textSignSize));
	spans.setSpan(new ForegroundColorSpan(resources.getColor(R.color.text_title_orange)), 0, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
	spans.setSpan(new ForegroundColorSpan(resources.getColor(R.color.text_title_orange)), spans.length() - 3, spans.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
	mTextSignSize.setText(spans);
}
 
Example 39
Project: Espresso   File: CompanyDetailFragment.java   Source Code and License 5 votes vote down vote up
@Override
public void setCompanyName(String name) {
    String companyName = getString(R.string.company_name) + "\n" + name;
    Spannable spannable = new SpannableStringBuilder(companyName);
    spannable.setSpan(new StyleSpan(Typeface.BOLD), 0, companyName.length() - name.length() - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    spannable.setSpan(new StyleSpan(Typeface.NORMAL), companyName.length() - name.length(), companyName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    textViewCompanyName.setText(spannable);
}
 
Example 40
Project: Espresso   File: CompanyDetailFragment.java   Source Code and License 5 votes vote down vote up
@Override
public void setCompanyWebsite(String website) {
    this.website = website;
    String ws = getString(R.string.official_website) + "\n" + website;
    Spannable spannable = new SpannableStringBuilder(ws);
    spannable.setSpan(new StyleSpan(Typeface.BOLD), 0, ws.length() - website.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    spannable.setSpan(new URLSpan(website), ws.length() - website.length(), ws.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    textViewWebsite.setText(spannable);
}
 
Example 41
Project: social-app-android   File: ProfileActivity.java   Source Code and License 5 votes vote down vote up
private Spannable buildCounterSpannable(String label, int value) {
    SpannableStringBuilder contentString = new SpannableStringBuilder();
    contentString.append(String.valueOf(value));
    contentString.append("\n");
    int start = contentString.length();
    contentString.append(label);
    contentString.setSpan(new TextAppearanceSpan(this, R.style.TextAppearance_Second_Light), start, contentString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    return contentString;
}
 
Example 42
Project: mapbox-navigation-android   File: DistanceUtils.java   Source Code and License 5 votes vote down vote up
private static SpannableStringBuilder roundToNearestMile(double distance, boolean spansEnabled,
                                                         String largeFinalUnit, String largeUnitFormat) {
  distance = TurfConversion.convertDistance(distance, TurfConstants.UNIT_METERS, largeFinalUnit);

  // Distance value
  int roundedNumber = (int) Math.round(distance);

  if (spansEnabled) {
    return generateSpannedText(String.valueOf(roundedNumber), largeUnitFormat);
  } else {
    return new SpannableStringBuilder(String.valueOf(roundedNumber) + largeUnitFormat);
  }
}
 
Example 43
Project: MKAPP   File: AdapterRule.java   Source Code and License 5 votes vote down vote up
private void markPro(MenuItem menu, String sku) {
    if (sku == null || !IAB.isPurchased(sku, context)) {
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        boolean dark = prefs.getBoolean("dark_theme", false);
        SpannableStringBuilder ssb = new SpannableStringBuilder("  " + menu.getTitle());
        ssb.setSpan(new ImageSpan(context, dark ? R.drawable.ic_shopping_cart_white_24dp : R.drawable.ic_shopping_cart_black_24dp), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        menu.setTitle(ssb);
    }
}
 
Example 44
Project: Android-UtilCode   File: SpannableStringUtils.java   Source Code and License 5 votes vote down vote up
public Builder() {
    flag = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
    foregroundColor = defaultValue;
    backgroundColor = defaultValue;
    quoteColor = defaultValue;
    margin = -1;
    fontSize = -1;
    proportion = -1;
    xProportion = -1;
    align = ALIGN_BOTTOM;
    mBuilder = new SpannableStringBuilder();
}
 
Example 45
Project: boohee_v5.6   File: MineHeadViewFactory.java   Source Code and License 5 votes vote down vote up
private CharSequence getSportHint(float overCalorie) {
    String[] sportName = new String[]{"快走", "跑步(慢)", "爬楼梯", "跳舞"};
    float[] sportMet = new float[]{5.0f, 6.5f, 6.4f, 6.0f};
    int minute = (int) ((overCalorie / FormulaUtils.calcCalorie(sportMet[(int) (Math.random()
            * ((double) sportName.length))], new WeightRecordDao(this.mContext)
            .getLastestWeight())) * 60.0f);
    SpannableStringBuilder sb = new SpannableStringBuilder();
    sb.append("多吃了可用运动抵消。如:");
    int start = sb.length();
    sb.append(String.format("%s %d分钟", new Object[]{sportName[choose], Integer.valueOf
            (minute)}));
    sb.setSpan(new ForegroundColorSpan(this.mContext.getResources().getColor(R.color.hb)),
            start, sb.length(), 17);
    return sb;
}
 
Example 46
Project: PlusGram   File: DeleteBySelectContacts.java   Source Code and License 5 votes vote down vote up
private ChipSpan createAndPutChipForUser(TLRPC.User user) {
    LayoutInflater lf = (LayoutInflater) ApplicationLoader.applicationContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    View textView = lf.inflate(R.layout.group_create_bubble, null);
    TextView text = (TextView) textView.findViewById(R.id.bubble_text_view);
    String name = UserObject.getUserName(user);
    if (name.length() == 0 && user.phone != null && user.phone.length() != 0) {
        name = PhoneFormat.getInstance().format("+" + user.phone);
    }
    text.setText(name + ", ");

    int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    textView.measure(spec, spec);
    textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
    Bitmap b = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(b);
    canvas.translate(-textView.getScrollX(), -textView.getScrollY());
    textView.draw(canvas);
    textView.setDrawingCacheEnabled(true);
    Bitmap cacheBmp = textView.getDrawingCache();
    Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true);
    textView.destroyDrawingCache();

    final BitmapDrawable bmpDrawable = new BitmapDrawable(b);
    bmpDrawable.setBounds(0, 0, b.getWidth(), b.getHeight());

    SpannableStringBuilder ssb = new SpannableStringBuilder("");
    ChipSpan span = new ChipSpan(bmpDrawable, ImageSpan.ALIGN_BASELINE);
    allSpans.add(span);
    selectedContacts.put(user.id, span);
    for (ImageSpan sp : allSpans) {
        ssb.append("<<");
        ssb.setSpan(sp, ssb.length() - 2, ssb.length(), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
    }
    userSelectEditText.setText(ssb);
    userSelectEditText.setSelection(ssb.length());
    return span;
}
 
Example 47
Project: aos-Video   File: VideoListPresenter.java   Source Code and License 5 votes vote down vote up
public VideoListPresenter(Context context,AdapterDefaultValues defaultValues,  ExtendedClickListener onExtendedClick, HttpImageManager imageManager) {
    super(context, defaultValues,  onExtendedClick, imageManager);
    mOnExtendedClick = onExtendedClick;
    mSpannableStringBuilder = new SpannableStringBuilder();
    mTextNoShadowSpan = new TextShadowSpan();
    mThinPhoneInPortrait = (mContext.getResources().getConfiguration().screenWidthDp < 350);
}
 
Example 48
Project: mobile-store   File: Utils.java   Source Code and License 5 votes vote down vote up
/**
 * Formats the app name using "sans-serif" and then appends the summary after a space with
 * "sans-serif-light". Doesn't mandate any font sizes or any other styles, that is up to the
 * {@link android.widget.TextView} which it ends up being displayed in.
 */
public static CharSequence formatAppNameAndSummary(String appName, String summary) {
    String toFormat = appName + ' ' + summary;
    CharacterStyle normal = new TypefaceSpan("sans-serif");
    CharacterStyle light = new TypefaceSpan("sans-serif-light");

    SpannableStringBuilder sb = new SpannableStringBuilder(toFormat);
    sb.setSpan(normal, 0, appName.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    sb.setSpan(light, appName.length(), toFormat.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    return sb;
}
 
Example 49
Project: yyox   File: ExpressionCommonUtils.java   Source Code and License 5 votes vote down vote up
public static void spannableEmoticonFilter(TextView tv_content, String content) {

        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(content);
        Spannable spannable = EmojiDisplay.spannableFilter(tv_content.getContext(),
                spannableStringBuilder,
                content,
                EmoticonsKeyboardUtils.getFontHeight(tv_content));
        tv_content.setText(spannable);
    }
 
Example 50
Project: LJFramework   File: SpannableStringUtils.java   Source Code and License 5 votes vote down vote up
private Builder(@NonNull CharSequence text) {
    this.text = text;
    flag = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
    foregroundColor = defaultValue;
    backgroundColor = defaultValue;
    quoteColor = defaultValue;
    proportion = -1;
    xProportion = -1;
    mBuilder = new SpannableStringBuilder();
}
 
Example 51
Project: mongol-library   File: MongolTextStorageInstrumentedTest.java   Source Code and License 5 votes vote down vote up
@Test
public void replace_partialStringFromPartialString() throws Exception {
    String unicode = "abc";
    String replacementString = "123";
    MongolTextStorage storage = new MongolTextStorage(unicode);
    CharSequence result = storage.replace(1, 2, replacementString, 1, 2);
    CharSequence expected = new SpannableStringBuilder("a2c");
    assertEquals(expected, result);
}
 
Example 52
Project: PeSanKita-android   File: AbstractNotificationBuilder.java   Source Code and License 5 votes vote down vote up
protected CharSequence getStyledMessage(@NonNull Recipient recipient, @Nullable CharSequence message) {
  SpannableStringBuilder builder = new SpannableStringBuilder();
  builder.append(Util.getBoldedString(recipient.toShortString()));
  builder.append(": ");
  builder.append(message == null ? "" : message);

  return builder;
}
 
Example 53
Project: PeSanKita-android   File: RecipientsEditor.java   Source Code and License 5 votes vote down vote up
public void populate(Recipients list) {
    SpannableStringBuilder sb = new SpannableStringBuilder();

    for (Recipient c : list.getRecipientsList()) {
        if (sb.length() != 0) {
            sb.append(", ");
        }

        sb.append(contactToToken(c));
    }

    setText(sb);
}
 
Example 54
Project: PeSanKita-android   File: ComposeText.java   Source Code and License 5 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
  super.onLayout(changed, left, top, right, bottom);

  if (!TextUtils.isEmpty(hint)) {
    if (!TextUtils.isEmpty(subHint)) {
      setHint(new SpannableStringBuilder().append(ellipsizeToWidth(hint))
                                          .append("\n")
                                          .append(ellipsizeToWidth(subHint)));
    } else {
      setHint(ellipsizeToWidth(hint));
    }
  }
}
 
Example 55
Project: SolidRefactor   File: PointOfInterestDetailFragment.java   Source Code and License 5 votes vote down vote up
private SpannableStringBuilder buildBoldLabelString(String label) {
    int x = label.indexOf(':');
    SpannableStringBuilder s = new SpannableStringBuilder(label);
    s.setSpan(new StyleSpan(Typeface.BOLD), 0, x, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    return s;
}
 
Example 56
Project: mvvm-template   File: HrHandler.java   Source Code and License 5 votes vote down vote up
@Override public void handleTagNode(TagNode tagNode, SpannableStringBuilder spannableStringBuilder, int i, int i1) {
    spannableStringBuilder.append("\n");
    SpannableStringBuilder builder = new SpannableStringBuilder("$");
    HrSpan hrSpan = new HrSpan(color, width);
    builder.setSpan(hrSpan, 0, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    builder.setSpan(new CenterSpan(), 0, builder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    builder.append("\n");
    spannableStringBuilder.append(builder);
}
 
Example 57
Project: revolution-irc   File: MessageBuilder.java   Source Code and License 5 votes vote down vote up
private void buildValueModeList(SpannableStringBuilder builder, Map<Character, Set<String>> modes) {
    for (Map.Entry<Character, Set<String>> mode : modes.entrySet()) {
        for (String val : mode.getValue()) {
            if (mode.getKey() == 'b')
                appendDelim(builder, SpannableStringHelper.getText(mContext, R.string.message_mode_channel_ban, buildColoredMessage(val, IRCColorUtils.getBanMaskColor(mContext), false)));
            else
                appendDelim(builder, SpannableStringHelper.getText(mContext, R.string.message_mode_channel_value, String.valueOf(mode.getKey()), val));
        }
    }
}
 
Example 58
Project: mongol-library   File: MongolTextStorageInstrumentedTest.java   Source Code and License 5 votes vote down vote up
@Test
public void append_toEmptyString() throws Exception {
    String unicode = "";
    String appendString = "1";
    MongolTextStorage storage = new MongolTextStorage(unicode);
    CharSequence result = storage.append(appendString);
    CharSequence expected = new SpannableStringBuilder("1");
    assertEquals(expected, result);
}
 
Example 59
Project: chromium-for-android-56-debug-video   File: ExpandablePreferenceGroup.java   Source Code and License 5 votes vote down vote up
/**
 * Set the title for the preference group.
 * @param resourceId The resource id of the text to use.
 * @param count The number of entries the preference group contains.
 */
public void setGroupTitle(int resourceId, int count) {
    SpannableStringBuilder spannable =
            new SpannableStringBuilder(getContext().getResources().getString(resourceId));
    String prefCount = String.format(Locale.getDefault(), " - %d", count);
    spannable.append(prefCount);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        spannable.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),
                   0,
                   spannable.length() - prefCount.length(),
                   Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        spannable.setSpan(new TypefaceSpan("sans-serif-medium"),
                   0,
                   spannable.length() - prefCount.length(),
                   Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    }

    // Color the first part of the title blue.
    ForegroundColorSpan blueSpan = new ForegroundColorSpan(
            ApiCompatibilityUtils.getColor(getContext().getResources(),
                    R.color.pref_accent_color));
    spannable.setSpan(blueSpan, 0, spannable.length() - prefCount.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    // Gray out the total count of items.
    int gray = ApiCompatibilityUtils.getColor(getContext().getResources(),
            R.color.expandable_group_dark_gray);
    spannable.setSpan(new ForegroundColorSpan(gray),
               spannable.length() - prefCount.length(),
               spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    setTitle(spannable);
}
 
Example 60
Project: Hitalk   File: RegisterLayout.java   Source Code and License 5 votes vote down vote up
private void initPassHint() {
    String hintPart1 = mRes.getString(R.string.passwordRegTips);
    String hintPart2 = mRes.getString(R.string.passwordRegSubTips);
    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
    SpannableString sPart1 = new SpannableString(hintPart1);
    SpannableString sPart2 = new SpannableString(hintPart2);
    AbsoluteSizeSpan span = new AbsoluteSizeSpan(DisplayUtil.dip2px(mAppCtx,12));
    sPart2.setSpan(span,0,hintPart2.length(), Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
    spannableStringBuilder.append(sPart1).append(sPart2);
    mPassdEt.setHint(spannableStringBuilder);
}