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 void | fadeIn()
mImageView.setAlpha(0f);
if (mAttachedToWindow) {
mImageView.animate().alpha(1f).setDuration(mImageView.getResources().getInteger(
android.R.integer.config_shortAnimTime));
}
|
public android.graphics.drawable.Drawable | getBadgeImage()
if (mBadgeImage == null) {
return null;
}
return mBadgeImage.getDrawable();
|
public java.lang.CharSequence | getContentText()
if (mContentView == null) {
return null;
}
return mContentView.getText();
|
public android.graphics.drawable.Drawable | getInfoAreaBackground()
if (mInfoArea != null) {
return mInfoArea.getBackground();
}
return null;
|
public android.graphics.drawable.Drawable | getMainImage()
if (mImageView == null) {
return null;
}
return mImageView.getDrawable();
|
public final android.widget.ImageView | getMainImageView()
return mImageView;
|
public java.lang.CharSequence | getTitleText()
if (mTitleView == null) {
return null;
}
return mTitleView.getText();
|
public boolean | hasOverlappingRendering()
return false;
|
protected void | onAttachedToWindow()
super.onAttachedToWindow();
mAttachedToWindow = true;
if (mImageView.getAlpha() == 0) {
fadeIn();
}
|
protected void | onDetachedFromWindow()
mAttachedToWindow = false;
mImageView.animate().cancel();
mImageView.setAlpha(1f);
super.onDetachedFromWindow();
|
public void | setBadgeImage(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 void | setContentText(java.lang.CharSequence text)
if (mContentView == null) {
return;
}
mContentView.setText(text);
setTextMaxLines();
|
public void | setInfoAreaBackground(android.graphics.drawable.Drawable drawable)
if (mInfoArea != null) {
mInfoArea.setBackground(drawable);
if (mBadgeImage != null) {
mBadgeImage.setBackground(drawable);
}
}
|
public void | setInfoAreaBackgroundColor(int color)
if (mInfoArea != null) {
mInfoArea.setBackgroundColor(color);
if (mBadgeImage != null) {
mBadgeImage.setBackgroundColor(color);
}
}
|
public void | setMainImage(android.graphics.drawable.Drawable drawable)Set drawable with fade-in animation.
setMainImage(drawable, true);
|
public void | setMainImage(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 void | setMainImageAdjustViewBounds(boolean adjustViewBounds)
if (mImageView != null) {
mImageView.setAdjustViewBounds(adjustViewBounds);
}
|
public void | setMainImageDimensions(int width, int height)
ViewGroup.LayoutParams lp = mImageView.getLayoutParams();
lp.width = width;
lp.height = height;
mImageView.setLayoutParams(lp);
|
public void | setMainImageScaleType(android.widget.ImageView.ScaleType scaleType)
if (mImageView != null) {
mImageView.setScaleType(scaleType);
}
|
private void | setTextMaxLines()
if (TextUtils.isEmpty(getTitleText())) {
mContentView.setMaxLines(2);
} else {
mContentView.setMaxLines(1);
}
if (TextUtils.isEmpty(getContentText())) {
mTitleView.setMaxLines(2);
} else {
mTitleView.setMaxLines(1);
}
|
public void | setTitleText(java.lang.CharSequence text)
if (mTitleView == null) {
return;
}
mTitleView.setText(text);
setTextMaxLines();
|