FileDocCategorySizeDatePackage
BulletSpan.javaAPI DocAndroid 5.1 API3548Thu Mar 12 22:22:10 GMT 2015android.text.style

BulletSpan

public class BulletSpan extends Object implements LeadingMarginSpan, android.text.ParcelableSpan

(Omit source code)

Fields Summary
private final int
mGapWidth
private final boolean
mWantColor
private final int
mColor
private static final int
BULLET_RADIUS
private static android.graphics.Path
sBulletPath
public static final int
STANDARD_GAP_WIDTH
Constructors Summary
public BulletSpan()


      
        mGapWidth = STANDARD_GAP_WIDTH;
        mWantColor = false;
        mColor = 0;
    
public BulletSpan(int gapWidth)

        mGapWidth = gapWidth;
        mWantColor = false;
        mColor = 0;
    
public BulletSpan(int gapWidth, int color)

        mGapWidth = gapWidth;
        mWantColor = true;
        mColor = color;
    
public BulletSpan(android.os.Parcel src)

        mGapWidth = src.readInt();
        mWantColor = src.readInt() != 0;
        mColor = src.readInt();
    
Methods Summary
public intdescribeContents()

        return 0;
    
public voiddrawLeadingMargin(android.graphics.Canvas c, android.graphics.Paint p, int x, int dir, int top, int baseline, int bottom, java.lang.CharSequence text, int start, int end, boolean first, android.text.Layout l)

        if (((Spanned) text).getSpanStart(this) == start) {
            Paint.Style style = p.getStyle();
            int oldcolor = 0;

            if (mWantColor) {
                oldcolor = p.getColor();
                p.setColor(mColor);
            }

            p.setStyle(Paint.Style.FILL);

            if (c.isHardwareAccelerated()) {
                if (sBulletPath == null) {
                    sBulletPath = new Path();
                    // Bullet is slightly better to avoid aliasing artifacts on mdpi devices.
                    sBulletPath.addCircle(0.0f, 0.0f, 1.2f * BULLET_RADIUS, Direction.CW);
                }

                c.save();
                c.translate(x + dir * BULLET_RADIUS, (top + bottom) / 2.0f);
                c.drawPath(sBulletPath, p);
                c.restore();
            } else {
                c.drawCircle(x + dir * BULLET_RADIUS, (top + bottom) / 2.0f, BULLET_RADIUS, p);
            }

            if (mWantColor) {
                p.setColor(oldcolor);
            }

            p.setStyle(style);
        }
    
public intgetLeadingMargin(boolean first)

        return 2 * BULLET_RADIUS + mGapWidth;
    
public intgetSpanTypeId()

        return TextUtils.BULLET_SPAN;
    
public voidwriteToParcel(android.os.Parcel dest, int flags)

        dest.writeInt(mGapWidth);
        dest.writeInt(mWantColor ? 1 : 0);
        dest.writeInt(mColor);