android.text.style.DynamicDrawableSpan Java Examples

The following examples show how to use android.text.style.DynamicDrawableSpan. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommentListActivity.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
private SpannableStringBuilder getText(PublicPostBean bean) {
    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
    SpannableString spannableString = new SpannableString(".");
    spannableString.setSpan(new ImageSpan(this, R.drawable.ic_location, DynamicDrawableSpan.ALIGN_BASELINE), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    String location = "";
    if (bean.getLocation() != null) {
        LocationEvent mLocationEvent = BaseApplication.getAppComponent().getGson().fromJson(bean.getLocation(), LocationEvent.class);
        if (mLocationEvent.getCity().equals(mLocationEvent.getTitle())) {
            location = mLocationEvent.getTitle();
        } else {
            location = mLocationEvent.getCity() + "." + mLocationEvent.getTitle();
        }
    }
    spannableStringBuilder.append(TimeUtil.getRealTime(bean.getCreatedAt() == null ? bean.getUpdatedAt() :
            bean.getCreatedAt())).append("   ").append(spannableString).append(location);
    return spannableStringBuilder;
}
 
Example #2
Source File: BaseShareInfoViewHolder.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
private SpannableStringBuilder getText(PublicPostBean bean) {
    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
    SpannableString spannableString = new SpannableString(".");
    spannableString.setSpan(new ImageSpan(getContext(), R.drawable.ic_location, DynamicDrawableSpan.ALIGN_BASELINE), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    String location = "";
    if (bean.getLocation() != null) {
        LocationEvent mLocationEvent = gson.fromJson(bean.getLocation(), LocationEvent.class);
        if (mLocationEvent.getCity().equals(mLocationEvent.getTitle())) {
            location = mLocationEvent.getTitle();
        } else {
            location = mLocationEvent.getCity() + "." + mLocationEvent.getTitle();
        }
    }
    spannableStringBuilder.append(TimeUtil.getRealTime(bean.getCreatedAt() == null ? bean.getUpdatedAt() :
            bean.getCreatedAt())).append("   ").append(spannableString).append(location);
    return spannableStringBuilder;
}
 
Example #3
Source File: CenteredImageSpan.java    From GSYRickText with MIT License 6 votes vote down vote up
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom,
                 Paint paint) {

    if (mVerticalAlignment == DynamicDrawableSpan.ALIGN_BASELINE || mVerticalAlignment == DynamicDrawableSpan.ALIGN_BOTTOM) {
        super.draw(canvas, text, start, end, x, top, y, bottom, paint);
        return;
    }

    Drawable b = getDrawable();
    canvas.save();
    int transY = 0;
    //获得将要显示的文本高度-图片高度除2等居中位置+top(换行情况)
    transY = ((bottom - top) - b.getBounds().bottom) / 2 + top;
    //偏移画布后开始绘制
    canvas.translate(x, transY);
    b.draw(canvas);
    canvas.restore();
}
 
Example #4
Source File: RichTextView.java    From GSYRickText with MIT License 6 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    if (isInEditMode())
        return;

    if (attrs != null) {
        TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.RichTextView);
        needNumberShow = array.getBoolean(R.styleable.RichTextView_needNumberShow, false);
        needUrlShow = array.getBoolean(R.styleable.RichTextView_needUrlShow, false);
        atColor = array.getColor(R.styleable.RichTextView_atColor, Color.BLUE);
        topicColor = array.getColor(R.styleable.RichTextView_topicColor, Color.BLUE);
        linkColor = array.getColor(R.styleable.RichTextView_linkColor, Color.BLUE);
        emojiSize = array.getInteger(R.styleable.RichTextView_emojiSize, 0);
        emojiVerticalAlignment = array.getInteger(R.styleable.RichTextView_emojiVerticalAlignment, DynamicDrawableSpan.ALIGN_BOTTOM);
        array.recycle();
    }
}
 
Example #5
Source File: EmojixTextWatcher.java    From Emojix with Apache License 2.0 6 votes vote down vote up
public EmojixTextWatcher(TextView textView) {
    this.textView = textView;

    SpannableString s = new SpannableString(textView.getText());
    if (!TextUtils.isEmpty(s)) {
        float textSize = textView.getTextSize();

        EmojiconHandler.addEmojis(textView.getContext(), s, (int) textSize,
                DynamicDrawableSpan.ALIGN_BASELINE, (int) textSize, 0, -1);

        textView.setText(s, TextView.BufferType.EDITABLE);

        if (textView instanceof EditText) {
            EditText editText = (EditText) textView;
            editText.setSelection(s.length());
        }
    }
}
 
Example #6
Source File: EmojiTextView.java    From emoji-keyboard with Apache License 2.0 5 votes vote down vote up
private void init(AttributeSet attrs) {
    this.mEmojiTextSize = (int) this.getTextSize();
    if (attrs == null) {
        this.mEmojiSize = (int) this.getTextSize();
    } else {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Emoji);
        this.mEmojiSize = (int) a.getDimension(R.styleable.Emoji_emojiSize, getTextSize());
        this.mEmojiAlignment = a.getInt(R.styleable.Emoji_emojiAlignment, DynamicDrawableSpan.ALIGN_BASELINE);
        this.mTextStart = a.getInteger(R.styleable.Emoji_emojiTextStart, 0);
        this.mTextLength = a.getInteger(R.styleable.Emoji_emojiTextLength, -1);
        this.mUseSystemDefault = a.getBoolean(R.styleable.Emoji_emojiUseSystemDefault, false);
        a.recycle();
    }
    this.setText(getText());
}
 
Example #7
Source File: BetterImageSpan.java    From fresco with MIT License 5 votes vote down vote up
/**
 * A helper function to allow dropping in BetterImageSpan as a replacement to ImageSpan, and
 * allowing for center alignment if passed in.
 */
public static final @BetterImageSpanAlignment int normalizeAlignment(int alignment) {
  switch (alignment) {
    case DynamicDrawableSpan.ALIGN_BOTTOM:
      return ALIGN_BOTTOM;
    case ALIGN_CENTER:
      return ALIGN_CENTER;
    case DynamicDrawableSpan.ALIGN_BASELINE:
    default:
      return ALIGN_BASELINE;
  }
}
 
Example #8
Source File: EmojiconTextView.java    From EmojiChat with Apache License 2.0 5 votes vote down vote up
private void init(AttributeSet attrs) {
    mEmojiconTextSize = (int) getTextSize();
    if (attrs == null) {
        mEmojiconSize = (int) getTextSize();
    } else {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Emojicon);
        mEmojiconSize = (int) a.getDimension(R.styleable.Emojicon_emojiconSize, getTextSize());
        mEmojiconAlignment = a.getInt(R.styleable.Emojicon_emojiconAlignment, DynamicDrawableSpan.ALIGN_BASELINE);
        mTextStart = a.getInteger(R.styleable.Emojicon_emojiconTextStart, 0);
        mTextLength = a.getInteger(R.styleable.Emojicon_emojiconTextLength, -1);
        mUseSystemDefault = a.getBoolean(R.styleable.Emojicon_emojiconUseSystemDefault, false);
        a.recycle();
    }
    setText(getText());
}
 
Example #9
Source File: EmojiconMultiAutoCompleteTextView.java    From EmojiChat with Apache License 2.0 5 votes vote down vote up
private void init(AttributeSet attrs) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Emojicon);
    mEmojiconSize = (int) a.getDimension(R.styleable.Emojicon_emojiconSize, getTextSize());
    mEmojiconAlignment = a.getInt(R.styleable.Emojicon_emojiconAlignment, DynamicDrawableSpan.ALIGN_BASELINE);
    mUseSystemDefault = a.getBoolean(R.styleable.Emojicon_emojiconUseSystemDefault, false);
    a.recycle();
    mEmojiconTextSize = (int) getTextSize();
    setText(getText());
}
 
Example #10
Source File: EmojiconEditText.java    From EmojiChat with Apache License 2.0 5 votes vote down vote up
private void init(AttributeSet attrs) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Emojicon);
    mEmojiconSize = (int) a.getDimension(R.styleable.Emojicon_emojiconSize, getTextSize());
    mEmojiconAlignment = a.getInt(R.styleable.Emojicon_emojiconAlignment, DynamicDrawableSpan.ALIGN_BASELINE);
    mUseSystemDefault = a.getBoolean(R.styleable.Emojicon_emojiconUseSystemDefault, false);
    a.recycle();
    mEmojiconTextSize = (int) getTextSize();
    setText(getText());
}
 
Example #11
Source File: EmojiSpan.java    From umeng_community_android with MIT License 5 votes vote down vote up
public EmojiSpan(Context context, int resourceId, int size, int textSize) {
    super(DynamicDrawableSpan.ALIGN_BASELINE);
    mContext = context;
    mResourceId = resourceId;
    mWidth = mHeight = mSize = size;
    mTextSize = textSize;
}
 
Example #12
Source File: EmojiconEditText.java    From emojicon with Apache License 2.0 5 votes vote down vote up
private void init(AttributeSet attrs) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Emojicon);
    mEmojiconSize = (int) a.getDimension(R.styleable.Emojicon_emojiconSize, getTextSize());
    mEmojiconAlignment = a.getInt(R.styleable.Emojicon_emojiconAlignment, DynamicDrawableSpan.ALIGN_BASELINE);
    mUseSystemDefault = a.getBoolean(R.styleable.Emojicon_emojiconUseSystemDefault, false);
    a.recycle();
    mEmojiconTextSize = (int) getTextSize();
    setText(getText());
}
 
Example #13
Source File: EmojixTextWatcher.java    From Emojix with Apache License 2.0 5 votes vote down vote up
@Override
public void afterTextChanged(Editable s) {
    if (start >= 0) {
        float textSize = textView.getTextSize();
        int pos = start;

        start = -2;
        EmojiconHandler.addEmojis(textView.getContext(), s, (int) textSize,
                DynamicDrawableSpan.ALIGN_BASELINE, (int) textSize, pos, count);
        start = -1;
    }
}
 
Example #14
Source File: EmojiconMultiAutoCompleteTextView.java    From emojicon with Apache License 2.0 5 votes vote down vote up
private void init(AttributeSet attrs) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Emojicon);
    mEmojiconSize = (int) a.getDimension(R.styleable.Emojicon_emojiconSize, getTextSize());
    mEmojiconAlignment = a.getInt(R.styleable.Emojicon_emojiconAlignment, DynamicDrawableSpan.ALIGN_BASELINE);
    mUseSystemDefault = a.getBoolean(R.styleable.Emojicon_emojiconUseSystemDefault, false);
    a.recycle();
    mEmojiconTextSize = (int) getTextSize();
    setText(getText());
}
 
Example #15
Source File: EmojiEditText.java    From emoji-keyboard with Apache License 2.0 5 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    this.mContext = context;
    this.initFocusListener();
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Emoji);
    this.mEmojiconSize = (int) a.getDimension(R.styleable.Emoji_emojiSize, getTextSize());
    this.mEmojiconAlignment = a.getInt(R.styleable.Emoji_emojiAlignment, DynamicDrawableSpan.ALIGN_BASELINE);
    this.mUseSystemDefault = a.getBoolean(R.styleable.Emoji_emojiUseSystemDefault, false);
    a.recycle();
    this.mEmojiconTextSize = (int) getTextSize();
    setText(getText());
}
 
Example #16
Source File: ExpressionTextView.java    From android-expression with Apache License 2.0 5 votes vote down vote up
private void init(AttributeSet attrs) {
    mExpressionTextSize = (int) getTextSize();
    if (attrs == null) {
        mExpressionSize = (int) getTextSize();
    } else {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Expression);
        mExpressionSize = (int) a.getDimension(R.styleable.Expression_expressionSize, getTextSize());
        mExpressionAlignment = a.getInt(R.styleable.Expression_expressionAlignment, DynamicDrawableSpan.ALIGN_BASELINE);
        a.recycle();
    }
    setText(getText());
}
 
Example #17
Source File: ExpressionEditText.java    From android-expression with Apache License 2.0 5 votes vote down vote up
private void init(AttributeSet attrs) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Expression);
    mExpressionSize = (int) a.getDimension(R.styleable.Expression_expressionSize, getTextSize());
    mExpressionAlignment = a.getInt(R.styleable.Expression_expressionAlignment, DynamicDrawableSpan.ALIGN_BASELINE);
    a.recycle();
    mExpressionTextSize = (int) getTextSize();
    setText(getText());
}
 
Example #18
Source File: EmojiconTextView.java    From emojicon with Apache License 2.0 5 votes vote down vote up
private void init(AttributeSet attrs) {
    mEmojiconTextSize = (int) getTextSize();
    if (attrs == null) {
        mEmojiconSize = (int) getTextSize();
    } else {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Emojicon);
        mEmojiconSize = (int) a.getDimension(R.styleable.Emojicon_emojiconSize, getTextSize());
        mEmojiconAlignment = a.getInt(R.styleable.Emojicon_emojiconAlignment, DynamicDrawableSpan.ALIGN_BASELINE);
        mTextStart = a.getInteger(R.styleable.Emojicon_emojiconTextStart, 0);
        mTextLength = a.getInteger(R.styleable.Emojicon_emojiconTextLength, -1);
        mUseSystemDefault = a.getBoolean(R.styleable.Emojicon_emojiconUseSystemDefault, false);
        a.recycle();
    }
    setText(getText());
}
 
Example #19
Source File: BindingAdapters.java    From lttrs-android with Apache License 2.0 5 votes vote down vote up
@BindingAdapter("android:text")
public static void setText(TextView text, SubjectWithImportance subjectWithImportance) {
    if (subjectWithImportance == null || subjectWithImportance.subject == null) {
        text.setText(null);
        return;
    }
    if (subjectWithImportance.important) {
        SpannableStringBuilder header = new SpannableStringBuilder(subjectWithImportance.subject);
        header.append("\u2004\u00bb"); // 1/3 em - 1/2 em would be 2002
        header.setSpan(new ImageSpan(text.getContext(), R.drawable.ic_important_amber_22sp, DynamicDrawableSpan.ALIGN_BASELINE), header.length() - 1, header.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        text.setText(header);
    } else {
        text.setText(subjectWithImportance.subject);
    }
}
 
Example #20
Source File: NotificationActivity.java    From Markwon with Apache License 2.0 5 votes vote down vote up
private void image() {
    // please note that image _could_ be supported only if it would be available immediately
    // debugging possibility
    //
    // doesn't seem to be working

    final Bitmap bitmap = Bitmap.createBitmap(128, 256, Bitmap.Config.ARGB_4444);
    final Canvas canvas = new Canvas(bitmap);
    canvas.drawColor(0xFFAD1457);

    final SpannableStringBuilder builder = new SpannableStringBuilder();
    builder.append("An image: ");

    final int length = builder.length();
    builder.append("[bitmap]");
    builder.setSpan(
            new ImageSpan(this, bitmap, DynamicDrawableSpan.ALIGN_BOTTOM),
            length,
            builder.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
    );

    builder.append(" okay, and ");

    final int start = builder.length();
    builder.append("[resource]");
    builder.setSpan(
            new ImageSpan(this, R.drawable.ic_memory_black_48dp),
            start,
            builder.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
    );

    display(builder);
}
 
Example #21
Source File: ChatAdapter.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 5 votes vote down vote up
public ChatAdapter(ChatRecyclerView aRecyclerView, Activity aContext, ChatAdapterCallback aCallback) {
	messages = new ArrayList<>();
	mRecyclerView = aRecyclerView;
	context = aContext;
	mCallback = aCallback;
	settings = new Settings(context);
	linkPattern = Pattern.compile("((http|https|ftp)\\:\\/\\/[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?\\/?([a-zA-Z0\u200C123456789\\-\\._\\?\\,\\'\\/\\\\\\+&amp;%\\$#\\=~])*[^\\.\\,\\)\\(\\s])");

	emoteAlignment = DynamicDrawableSpan.ALIGN_BASELINE;
	imageMod = new ImageSpan(context, R.drawable.ic_moderator, emoteAlignment);
	imageTurbo = new ImageSpan(context, R.drawable.ic_twitch_turbo, emoteAlignment);
	isNightTheme = settings.getTheme().equals(context.getString(R.string.night_theme_name)) || settings.getTheme().equals(context.getString(R.string.true_night_theme_name));
}
 
Example #22
Source File: LikerTextView.java    From TestChat with Apache License 2.0 5 votes vote down vote up
private SpannableString setImageSpan(List<String> list) {
        SpannableString spannableString = new SpannableString("..");
        if (list != null && list.contains(UserManager.getInstance().getCurrentUser().getObjectId())) {
                spannableString.setSpan(new ImageSpan(getContext(), R.drawable.ic_favorite_deep_orange_a700_24dp, DynamicDrawableSpan.ALIGN_BASELINE), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        } else {
                spannableString.setSpan(new ImageSpan(getContext(), R.drawable.ic_favorite_border_deep_orange_a700_24dp, DynamicDrawableSpan.ALIGN_BASELINE), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        return spannableString;
}
 
Example #23
Source File: WebImageSpan.java    From V2EX with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Drawable getDrawable() {
    if (isShow){
        return super.getDrawable();
    }
    Glide.with(mTextView.getContext()).load(mUri).into(new SimpleTarget<Drawable>() {
        @Override
        public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {

            Resources resources = mTextView.getContext().getResources();
            int targetWidth = (int) (resources.getDisplayMetrics().widthPixels * 0.8);
            Bitmap zoom = zoom(ConvertUtils.drawable2Bitmap(resource), targetWidth);
            BitmapDrawable b = new BitmapDrawable(resources, zoom);
            b.setBounds(0, 0, b.getIntrinsicWidth(), b.getIntrinsicHeight());
            Field mDrawable;
            Field mDrawableRef;
            try { mDrawable = ImageSpan.class.getDeclaredField("mDrawable");
                mDrawable.setAccessible(true);
                mDrawable.set(WebImageSpan.this, b);
                mDrawableRef = DynamicDrawableSpan.class.getDeclaredField("mDrawableRef");
                mDrawableRef.setAccessible(true); mDrawableRef.set(WebImageSpan.this, null);
                isShow = true;
                mTextView.setText(mTextView.getText());
            } catch (IllegalAccessException | NoSuchFieldException e) {
                e.printStackTrace();
            }

        }

    });
    return null;
}
 
Example #24
Source File: EmojiconSpan.java    From imsdk-android with MIT License 5 votes vote down vote up
public EmojiconSpan(Context context, Drawable drawable, int size, int textSize) {
    super(DynamicDrawableSpan.ALIGN_BASELINE);
    mContext = context;
    mDrawable = drawable;
    mResourceId = 0;
    mWidth = mHeight = mSize = size;
    mTextSize = textSize;
}
 
Example #25
Source File: EmojiconSpan.java    From imsdk-android with MIT License 5 votes vote down vote up
public EmojiconSpan(Context context, int resourceId, int size, int textSize) {
    super(DynamicDrawableSpan.ALIGN_BASELINE);
    mContext = context;
    mResourceId = resourceId;
    mWidth = mHeight = mSize = size;
    mTextSize = textSize;
}
 
Example #26
Source File: VisibleRecipientChip.java    From ChipsLibrary with Apache License 2.0 4 votes vote down vote up
public VisibleRecipientChip(final Drawable drawable, final RecipientEntry entry) {
    super(drawable, DynamicDrawableSpan.ALIGN_BOTTOM);

    mDelegate = new SimpleRecipientChip(entry);
}
 
Example #27
Source File: Emoji.java    From Game-of-Thrones with Apache License 2.0 4 votes vote down vote up
public EmojiSpan(EmojiDrawable d) {
    super(d, DynamicDrawableSpan.ALIGN_BOTTOM);
}
 
Example #28
Source File: UserLogAdapter.java    From 600SeriesAndroidUploader with MIT License 4 votes vote down vote up
private void setContent(TextView tv, UserLog ul) {

        if (!init) initDrawables(tv);

        SpannableStringBuilder ssb = new SpannableStringBuilder();

        UserLogMessage.TYPE type = UserLogMessage.TYPE.convert(ul.getType());
        String clock = FormatKit.getInstance().formatAsDayClockSeconds(ul.getTimestamp());
        String text = ul.getMessageParsed();

        if (largeText) clock += "\n";

        switch (type) {
            case WARN:
                ssb.append(" * ").append(text);
                ssb.setSpan(new ImageSpan(iWARN, DynamicDrawableSpan.ALIGN_BASELINE), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                ssb.setSpan(new ForegroundColorSpan(iWARN.getColor()), 3, text.length() + 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            case HELP:
                ssb.append(" * ").append(text);
                ssb.setSpan(new ImageSpan(iHELP, DynamicDrawableSpan.ALIGN_BASELINE), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                ssb.setSpan(new ForegroundColorSpan(iHELP.getColor()), 3, text.length() + 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            case INFO:
                ssb.append(" * ").append(text);
                ssb.setSpan(new ImageSpan(iINFO, DynamicDrawableSpan.ALIGN_BASELINE), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                ssb.setSpan(new ForegroundColorSpan(iINFO.getColor()), 3, text.length() + 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            case NOTE:
                ssb.append(" * ").append(text);
                ssb.setSpan(new ImageSpan(iNOTE, DynamicDrawableSpan.ALIGN_BASELINE), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                ssb.setSpan(new ForegroundColorSpan(iNOTE.getColor()), 3, text.length() + 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            case HISTORY:
                ssb.append(" * ").append(text);
                ssb.setSpan(new ImageSpan(iREFRESH, DynamicDrawableSpan.ALIGN_BASELINE), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                ssb.setSpan(new ForegroundColorSpan(iREFRESH.getColor()), 3, text.length() + 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            case CGM:
                ssb.append(" * ").append(text);
                ssb.setSpan(new ImageSpan(iCGM, DynamicDrawableSpan.ALIGN_BASELINE), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                ssb.setSpan(new ForegroundColorSpan(iCGM.getColor()), 3, text.length() + 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            case OPTION:
                ssb.append(" * ").append(text);
                ssb.setSpan(new ImageSpan(iSETTING, DynamicDrawableSpan.ALIGN_BASELINE), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                ssb.setSpan(new ForegroundColorSpan(iSETTING.getColor()), 3, text.length() + 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            case STARTUP:
            case SHUTDOWN:
            case HEART:
                ssb.append(" * ").append(text);
                ssb.setSpan(new ImageSpan(iHEART, DynamicDrawableSpan.ALIGN_BASELINE), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                ssb.setSpan(new ForegroundColorSpan(cHigh), 3, text.length() + 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                ssb.setSpan(new StyleSpan(Typeface.BOLD_ITALIC), 3, text.length() + 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            case SGV:
                ssb.append(" ").append(text);
                ssb.setSpan(new ForegroundColorSpan(cHigh), 1, text.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            case ESTIMATE:
                ssb.append(" ").append(text);
                ssb.setSpan(new ForegroundColorSpan(cEestimate), 1, text.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            case ISIG:
                ssb.append(" ").append(text);
                ssb.setSpan(new ForegroundColorSpan(cIsig), 1, text.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            case REQUESTED:
            case RECEIVED:
                ssb.append(" ").append(text);
                ssb.setSpan(new ForegroundColorSpan(cHistory), 1, text.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            case SHARE:
                ssb.append(" * ").append(text);
                ssb.setSpan(new ImageSpan(iSHARE, DynamicDrawableSpan.ALIGN_BASELINE), 1, 2, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                ssb.setSpan(new ForegroundColorSpan(iSHARE.getColor()), 3, text.length() + 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            case PUSHOVER:
                ssb.append(" ").append(text);
                ssb.setSpan(new ForegroundColorSpan(cPushover), 1, text.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                break;
            default:
                ssb.append(" ").append(text);
                ssb.setSpan(new ForegroundColorSpan(cNormal), 1, text.length() + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }

        ssb.insert(0, clock);
        ssb.setSpan(new ForegroundColorSpan(cLow), 0, clock.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        ssb.setSpan(new RelativeSizeSpan(0.78f), 0, clock.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

        tv.setText(ssb);
    }
 
Example #29
Source File: VisibleRecipientChip.java    From talk-android with MIT License 4 votes vote down vote up
public VisibleRecipientChip(final Drawable drawable, final RecipientEntry entry) {
    this(drawable, entry, DynamicDrawableSpan.ALIGN_BOTTOM);
}
 
Example #30
Source File: TextCommonUtils.java    From GSYRickText with MIT License 2 votes vote down vote up
/**
 * 单纯获取emoji表示
 *
 * @param context 上下文
 * @param text    需要处理的文本
 * @param size    emoji大小
 * @return 返回显示的spananle
 */
public static Spannable getEmojiText(Context context, String text, int size) {
    return getEmojiText(context, text, size, DynamicDrawableSpan.ALIGN_BOTTOM);

}