Methods Summary |
---|
protected RowPresenter.ViewHolder | createRowViewHolder(android.view.ViewGroup parent)
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.lb_details_overview, parent, false);
ViewHolder vh = new ViewHolder(v, mDetailsPresenter);
initDetailsOverview(vh);
return vh;
|
public int | getBackgroundColor()Returns the background color. If no background color was set, transparent
is returned.
return mBackgroundColor;
|
private int | getCardHeight(android.content.Context context)
int resId = mIsStyleLarge ? R.dimen.lb_details_overview_height_large :
R.dimen.lb_details_overview_height_small;
return context.getResources().getDimensionPixelSize(resId);
|
private int | getDefaultBackgroundColor(android.content.Context context)
TypedValue outValue = new TypedValue();
context.getTheme().resolveAttribute(R.attr.defaultBrandColor, outValue, true);
return context.getResources().getColor(outValue.resourceId);
|
private static int | getNonNegativeHeight(android.graphics.drawable.Drawable drawable)
final int height = (drawable == null) ? 0 : drawable.getIntrinsicHeight();
return (height > 0 ? height : 0);
|
private static int | getNonNegativeWidth(android.graphics.drawable.Drawable drawable)
final int width = (drawable == null) ? 0 : drawable.getIntrinsicWidth();
return (width > 0 ? width : 0);
|
public OnActionClickedListener | getOnActionClickedListener()Gets the listener for Action click events.
return mActionClickedListener;
|
private void | initDetailsOverview(android.support.v17.leanback.widget.DetailsOverviewRowPresenter$ViewHolder vh)
final View overview = vh.mOverviewFrame;
ViewGroup.LayoutParams lp = overview.getLayoutParams();
lp.height = getCardHeight(overview.getContext());
overview.setLayoutParams(lp);
if (!getSelectEffectEnabled()) {
vh.mOverviewFrame.setForeground(null);
}
|
public boolean | isStyleLarge()Returns true if the layout style is large.
return mIsStyleLarge;
|
public final boolean | isUsingDefaultSelectEffect()
return false;
|
protected void | onBindRowViewHolder(RowPresenter.ViewHolder holder, java.lang.Object item)
super.onBindRowViewHolder(holder, item);
DetailsOverviewRow row = (DetailsOverviewRow) item;
ViewHolder vh = (ViewHolder) holder;
ViewGroup.MarginLayoutParams layoutParams =
(ViewGroup.MarginLayoutParams) vh.mImageView.getLayoutParams();
final int cardHeight = getCardHeight(vh.mImageView.getContext());
final int verticalMargin = vh.mImageView.getResources().getDimensionPixelSize(
R.dimen.lb_details_overview_image_margin_vertical);
final int horizontalMargin = vh.mImageView.getResources().getDimensionPixelSize(
R.dimen.lb_details_overview_image_margin_horizontal);
final int drawableWidth = getNonNegativeWidth(row.getImageDrawable());
final int drawableHeight = getNonNegativeHeight(row.getImageDrawable());
boolean scaleImage = row.isImageScaleUpAllowed();
boolean useMargin = false;
if (row.getImageDrawable() != null) {
boolean landscape = false;
// If large style and landscape image we always use margin.
if (drawableWidth > drawableHeight) {
landscape = true;
if (mIsStyleLarge) {
useMargin = true;
}
}
// If long dimension bigger than the card height we scale down.
if ((landscape && drawableWidth > cardHeight) ||
(!landscape && drawableHeight > cardHeight)) {
scaleImage = true;
}
// If we're not scaling to fit the card height then we always use margin.
if (!scaleImage) {
useMargin = true;
}
// If using margin than may need to scale down.
if (useMargin && !scaleImage) {
if (landscape && drawableWidth > cardHeight - horizontalMargin) {
scaleImage = true;
} else if (!landscape && drawableHeight > cardHeight - 2 * verticalMargin) {
scaleImage = true;
}
}
}
final int bgColor = mBackgroundColorSet ? mBackgroundColor :
getDefaultBackgroundColor(vh.mOverviewView.getContext());
if (useMargin) {
layoutParams.setMarginStart(horizontalMargin);
layoutParams.topMargin = layoutParams.bottomMargin = verticalMargin;
RoundedRectHelper.getInstance().setRoundedRectBackground(vh.mOverviewFrame, bgColor);
vh.mRightPanel.setBackground(null);
vh.mImageView.setBackground(null);
} else {
layoutParams.leftMargin = layoutParams.topMargin = layoutParams.bottomMargin = 0;
vh.mRightPanel.setBackgroundColor(bgColor);
vh.mImageView.setBackgroundColor(bgColor);
RoundedRectHelper.getInstance().setRoundedRectBackground(vh.mOverviewFrame,
Color.TRANSPARENT);
}
if (scaleImage) {
vh.mImageView.setScaleType(ImageView.ScaleType.FIT_START);
vh.mImageView.setAdjustViewBounds(true);
vh.mImageView.setMaxWidth(cardHeight);
layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
} else {
vh.mImageView.setScaleType(ImageView.ScaleType.CENTER);
vh.mImageView.setAdjustViewBounds(false);
layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
// Limit width to the card height
layoutParams.width = Math.min(cardHeight, drawableWidth);
}
vh.mImageView.setLayoutParams(layoutParams);
vh.mImageView.setImageDrawable(row.getImageDrawable());
mDetailsPresenter.onBindViewHolder(vh.mDetailsDescriptionViewHolder, row.getItem());
ArrayObjectAdapter aoa = new ArrayObjectAdapter(mActionPresenterSelector);
aoa.addAll(0, (Collection)row.getActions());
vh.bind(aoa);
if (row.getImageDrawable() != null && mSharedElementHelper != null) {
mSharedElementHelper.onBindToDrawable(vh);
}
|
protected void | onRowViewAttachedToWindow(RowPresenter.ViewHolder vh)
super.onRowViewAttachedToWindow(vh);
if (mDetailsPresenter != null) {
mDetailsPresenter.onViewAttachedToWindow(
((ViewHolder) vh).mDetailsDescriptionViewHolder);
}
|
protected void | onRowViewDetachedFromWindow(RowPresenter.ViewHolder vh)
super.onRowViewDetachedFromWindow(vh);
if (mDetailsPresenter != null) {
mDetailsPresenter.onViewDetachedFromWindow(
((ViewHolder) vh).mDetailsDescriptionViewHolder);
}
|
protected void | onRowViewSelected(RowPresenter.ViewHolder vh, boolean selected)
super.onRowViewSelected(vh, selected);
if (selected) {
((ViewHolder) vh).dispatchItemSelection(null);
}
|
protected void | onSelectLevelChanged(RowPresenter.ViewHolder holder)
super.onSelectLevelChanged(holder);
if (getSelectEffectEnabled()) {
ViewHolder vh = (ViewHolder) holder;
int dimmedColor = vh.mColorDimmer.getPaint().getColor();
((ColorDrawable) vh.mOverviewFrame.getForeground().mutate()).setColor(dimmedColor);
}
|
protected void | onUnbindRowViewHolder(RowPresenter.ViewHolder holder)
super.onUnbindRowViewHolder(holder);
ViewHolder vh = (ViewHolder) holder;
if (vh.mDetailsDescriptionViewHolder != null) {
mDetailsPresenter.onUnbindViewHolder(vh.mDetailsDescriptionViewHolder);
}
|
public void | setBackgroundColor(int color)Sets the background color. If not set, a default from the theme will be used.
mBackgroundColor = color;
mBackgroundColorSet = true;
|
public void | setOnActionClickedListener(OnActionClickedListener listener)Sets the listener for Action click events.
mActionClickedListener = listener;
|
public final void | setSharedElementEnterTransition(android.app.Activity activity, java.lang.String sharedElementName, long timeoutMs)Set enter transition of target activity (typically a DetailActivity) to be
transiting into overview row created by this presenter. The transition will
be cancelled if overview image is not loaded in the timeout period.
It assumes shared element passed from calling activity is an ImageView;
the shared element transits to overview image on the left of detail
overview row, while bounds of overview row grows and reveals text
and buttons on the right.
The method must be invoked in target Activity's onCreate().
if (mSharedElementHelper == null) {
mSharedElementHelper = new DetailsOverviewSharedElementHelper();
}
mSharedElementHelper.setSharedElementEnterTransition(activity, sharedElementName,
timeoutMs);
|
public final void | setSharedElementEnterTransition(android.app.Activity activity, java.lang.String sharedElementName)Set enter transition of target activity (typically a DetailActivity) to be
transiting into overview row created by this presenter. The transition will
be cancelled if overview image is not loaded in a default timeout period.
It assumes shared element passed from calling activity is an ImageView;
the shared element transits to overview image on the left of detail
overview row, while bounds of overview row grows and reveals text
and buttons on the right.
The method must be invoked in target Activity's onCreate().
setSharedElementEnterTransition(activity, sharedElementName, DEFAULT_TIMEOUT);
|
public void | setStyleLarge(boolean large)Sets the layout style to be large or small. This affects the height of
the overview, including the text description. The default is large.
mIsStyleLarge = large;
|