FileDocCategorySizeDatePackage
ImageCardView.javaAPI DocAndroid 5.1 API7484Thu Mar 12 22:22:56 GMT 2015android.support.v17.leanback.widget

ImageCardView

public class ImageCardView extends BaseCardView
A card view with an {@link ImageView} as its main region.

Fields Summary
private android.widget.ImageView
mImageView
private android.view.View
mInfoArea
private android.widget.TextView
mTitleView
private android.widget.TextView
mContentView
private android.widget.ImageView
mBadgeImage
private android.widget.ImageView
mBadgeFadeMask
private boolean
mAttachedToWindow
Constructors Summary
public ImageCardView(android.content.Context context)

        this(context, null);
    
public ImageCardView(android.content.Context context, android.util.AttributeSet attrs)

        this(context, attrs, R.attr.imageCardViewStyle);
    
public ImageCardView(android.content.Context context, android.util.AttributeSet attrs, int defStyle)

        super(context, attrs, defStyle);

        LayoutInflater inflater = LayoutInflater.from(context);
        View v = inflater.inflate(R.layout.lb_image_card_view, this);

        mImageView = (ImageView) v.findViewById(R.id.main_image);
        mImageView.setVisibility(View.INVISIBLE);
        mInfoArea = v.findViewById(R.id.info_field);
        mTitleView = (TextView) v.findViewById(R.id.title_text);
        mContentView = (TextView) v.findViewById(R.id.content_text);
        mBadgeImage = (ImageView) v.findViewById(R.id.extra_badge);
        mBadgeFadeMask = (ImageView) v.findViewById(R.id.fade_mask);

        if (mInfoArea != null) {
            TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.lbImageCardView,
                    defStyle, 0);
            try {
                setInfoAreaBackground(
                        a.getDrawable(R.styleable.lbImageCardView_infoAreaBackground));
            } finally {
                a.recycle();
            }
        }
    
Methods Summary
private voidfadeIn()

        mImageView.setAlpha(0f);
        if (mAttachedToWindow) {
            mImageView.animate().alpha(1f).setDuration(mImageView.getResources().getInteger(
                    android.R.integer.config_shortAnimTime));
        }
    
public android.graphics.drawable.DrawablegetBadgeImage()

        if (mBadgeImage == null) {
            return null;
        }

        return mBadgeImage.getDrawable();
    
public java.lang.CharSequencegetContentText()

        if (mContentView == null) {
            return null;
        }

        return mContentView.getText();
    
public android.graphics.drawable.DrawablegetInfoAreaBackground()

        if (mInfoArea != null) {
            return mInfoArea.getBackground();
        }
        return null;
    
public android.graphics.drawable.DrawablegetMainImage()

        if (mImageView == null) {
            return null;
        }

        return mImageView.getDrawable();
    
public final android.widget.ImageViewgetMainImageView()

        return mImageView;
    
public java.lang.CharSequencegetTitleText()

        if (mTitleView == null) {
            return null;
        }

        return mTitleView.getText();
    
public booleanhasOverlappingRendering()

        return false;
    
protected voidonAttachedToWindow()

        super.onAttachedToWindow();
        mAttachedToWindow = true;
        if (mImageView.getAlpha() == 0) {
            fadeIn();
        }
    
protected voidonDetachedFromWindow()

        mAttachedToWindow = false;
        mImageView.animate().cancel();
        mImageView.setAlpha(1f);
        super.onDetachedFromWindow();
    
public voidsetBadgeImage(android.graphics.drawable.Drawable drawable)

        if (mBadgeImage == null) {
            return;
        }

        if (drawable != null) {
            mBadgeImage.setImageDrawable(drawable);
            mBadgeImage.setVisibility(View.VISIBLE);
            mBadgeFadeMask.setVisibility(View.VISIBLE);
        } else {
            mBadgeImage.setVisibility(View.GONE);
            mBadgeFadeMask.setVisibility(View.GONE);
        }
    
public voidsetContentText(java.lang.CharSequence text)

        if (mContentView == null) {
            return;
        }

        mContentView.setText(text);
        setTextMaxLines();
    
public voidsetInfoAreaBackground(android.graphics.drawable.Drawable drawable)

        if (mInfoArea != null) {
            mInfoArea.setBackground(drawable);
            if (mBadgeImage != null) {
                mBadgeImage.setBackground(drawable);
            }
        }
    
public voidsetInfoAreaBackgroundColor(int color)

        if (mInfoArea != null) {
            mInfoArea.setBackgroundColor(color);
            if (mBadgeImage != null) {
                mBadgeImage.setBackgroundColor(color);
            }
        }
    
public voidsetMainImage(android.graphics.drawable.Drawable drawable)
Set drawable with fade-in animation.

        setMainImage(drawable, true);
    
public voidsetMainImage(android.graphics.drawable.Drawable drawable, boolean fade)
Set drawable with optional fade-in animation.

        if (mImageView == null) {
            return;
        }

        mImageView.setImageDrawable(drawable);
        if (drawable == null) {
            mImageView.animate().cancel();
            mImageView.setAlpha(1f);
            mImageView.setVisibility(View.INVISIBLE);
        } else {
            mImageView.setVisibility(View.VISIBLE);
            if (fade) {
                fadeIn();
            } else {
                mImageView.animate().cancel();
                mImageView.setAlpha(1f);
            }
        }
    
public voidsetMainImageAdjustViewBounds(boolean adjustViewBounds)

        if (mImageView != null) {
            mImageView.setAdjustViewBounds(adjustViewBounds);
        }
    
public voidsetMainImageDimensions(int width, int height)

        ViewGroup.LayoutParams lp = mImageView.getLayoutParams();
        lp.width = width;
        lp.height = height;
        mImageView.setLayoutParams(lp);
    
public voidsetMainImageScaleType(android.widget.ImageView.ScaleType scaleType)

        if (mImageView != null) {
            mImageView.setScaleType(scaleType);
        }
    
private voidsetTextMaxLines()

        if (TextUtils.isEmpty(getTitleText())) {
            mContentView.setMaxLines(2);
        } else {
            mContentView.setMaxLines(1);
        }
        if (TextUtils.isEmpty(getContentText())) {
            mTitleView.setMaxLines(2);
        } else {
            mTitleView.setMaxLines(1);
        }
    
public voidsetTitleText(java.lang.CharSequence text)

        if (mTitleView == null) {
            return;
        }

        mTitleView.setText(text);
        setTextMaxLines();