FileDocCategorySizeDatePackage
CardViewEclairMr1.javaAPI DocAndroid 5.1 API6561Thu Mar 12 22:22:56 GMT 2015android.support.v7.widget

CardViewEclairMr1

public class CardViewEclairMr1 extends Object implements CardViewImpl

Fields Summary
final android.graphics.RectF
sCornerRect
Constructors Summary
Methods Summary
RoundRectDrawableWithShadowcreateBackground(android.content.Context context, int backgroundColor, float radius, float elevation, float maxElevation)

        return new RoundRectDrawableWithShadow(context.getResources(), backgroundColor, radius,
                elevation, maxElevation);
    
public floatgetElevation(CardViewDelegate cardView)

        return getShadowBackground(cardView).getShadowSize();
    
public floatgetMaxElevation(CardViewDelegate cardView)

        return getShadowBackground(cardView).getMaxShadowSize();
    
public floatgetMinHeight(CardViewDelegate cardView)

        return getShadowBackground(cardView).getMinHeight();
    
public floatgetMinWidth(CardViewDelegate cardView)

        return getShadowBackground(cardView).getMinWidth();
    
public floatgetRadius(CardViewDelegate cardView)

        return getShadowBackground(cardView).getCornerRadius();
    
private RoundRectDrawableWithShadowgetShadowBackground(CardViewDelegate cardView)

        return ((RoundRectDrawableWithShadow) cardView.getBackground());
    
public voidinitStatic()


    
       
        // Draws a round rect using 7 draw operations. This is faster than using
        // canvas.drawRoundRect before JBMR1 because API 11-16 used alpha mask textures to draw
        // shapes.
        RoundRectDrawableWithShadow.sRoundRectHelper
                = new RoundRectDrawableWithShadow.RoundRectHelper() {
            @Override
            public void drawRoundRect(Canvas canvas, RectF bounds, float cornerRadius,
                    Paint paint) {
                final float twoRadius = cornerRadius * 2;
                final float innerWidth = bounds.width() - twoRadius - 1;
                final float innerHeight = bounds.height() - twoRadius - 1;
                // increment it to account for half pixels.
                if (cornerRadius >= 1f) {
                    cornerRadius += .5f;
                    sCornerRect.set(-cornerRadius, -cornerRadius, cornerRadius, cornerRadius);
                    int saved = canvas.save();
                    canvas.translate(bounds.left + cornerRadius, bounds.top + cornerRadius);
                    canvas.drawArc(sCornerRect, 180, 90, true, paint);
                    canvas.translate(innerWidth, 0);
                    canvas.rotate(90);
                    canvas.drawArc(sCornerRect, 180, 90, true, paint);
                    canvas.translate(innerHeight, 0);
                    canvas.rotate(90);
                    canvas.drawArc(sCornerRect, 180, 90, true, paint);
                    canvas.translate(innerWidth, 0);
                    canvas.rotate(90);
                    canvas.drawArc(sCornerRect, 180, 90, true, paint);
                    canvas.restoreToCount(saved);
                    //draw top and bottom pieces
                    canvas.drawRect(bounds.left + cornerRadius - 1f, bounds.top,
                            bounds.right - cornerRadius + 1f, bounds.top + cornerRadius,
                            paint);
                    canvas.drawRect(bounds.left + cornerRadius - 1f,
                            bounds.bottom - cornerRadius + 1f, bounds.right - cornerRadius + 1f,
                            bounds.bottom, paint);
                }
////                center
                canvas.drawRect(bounds.left, bounds.top + Math.max(0, cornerRadius - 1f),
                        bounds.right, bounds.bottom - cornerRadius + 1f, paint);
            }
        };
    
public voidinitialize(CardViewDelegate cardView, android.content.Context context, int backgroundColor, float radius, float elevation, float maxElevation)

        RoundRectDrawableWithShadow background = createBackground(context, backgroundColor, radius,
                elevation, maxElevation);
        background.setAddPaddingForCorners(cardView.getPreventCornerOverlap());
        cardView.setBackgroundDrawable(background);
        updatePadding(cardView);
    
public voidonCompatPaddingChanged(CardViewDelegate cardView)

        // NO OP
    
public voidonPreventCornerOverlapChanged(CardViewDelegate cardView)

        getShadowBackground(cardView).setAddPaddingForCorners(cardView.getPreventCornerOverlap());
        updatePadding(cardView);
    
public voidsetBackgroundColor(CardViewDelegate cardView, int color)

        getShadowBackground(cardView).setColor(color);
    
public voidsetElevation(CardViewDelegate cardView, float elevation)

        getShadowBackground(cardView).setShadowSize(elevation);
    
public voidsetMaxElevation(CardViewDelegate cardView, float maxElevation)

        getShadowBackground(cardView).setMaxShadowSize(maxElevation);
        updatePadding(cardView);
    
public voidsetRadius(CardViewDelegate cardView, float radius)

        getShadowBackground(cardView).setCornerRadius(radius);
        updatePadding(cardView);
    
public voidupdatePadding(CardViewDelegate cardView)

        Rect shadowPadding = new Rect();
        getShadowBackground(cardView).getMaxShadowAndCornerPadding(shadowPadding);
        ((View) cardView).setMinimumHeight((int) Math.ceil(getMinHeight(cardView)));
        ((View) cardView).setMinimumWidth((int) Math.ceil(getMinWidth(cardView)));
        cardView.setShadowPadding(shadowPadding.left, shadowPadding.top,
                shadowPadding.right, shadowPadding.bottom);