Methods Summary |
---|
public final boolean | areChildRoundedCornersEnabled()Returns true if rounded corners are enabled for children of this row.
return mRoundedCornersEnabled;
|
public boolean | canDrawOutOfBounds()
return needsDefaultShadow();
|
protected android.support.v17.leanback.widget.RowPresenter.ViewHolder | createRowViewHolder(android.view.ViewGroup parent)
initStatics(parent.getContext());
ListRowView rowView = new ListRowView(parent.getContext());
setupFadingEffect(rowView);
if (mRowHeight != 0) {
rowView.getGridView().setRowHeight(mRowHeight);
}
return new ViewHolder(rowView, rowView.getGridView(), this);
|
public final void | enableChildRoundedCorners(boolean enable)Enables or disabled rounded corners on children of this row.
Supported on Android SDK >= L.
mRoundedCornersEnabled = enable;
|
public void | freeze(android.support.v17.leanback.widget.RowPresenter.ViewHolder holder, boolean freeze)
ViewHolder vh = (ViewHolder) holder;
vh.mGridView.setScrollEnabled(!freeze);
|
public int | getExpandedRowHeight()Returns the expanded row height for rows created by this Presenter.
return mExpandedRowHeight != 0 ? mExpandedRowHeight : mRowHeight;
|
public final PresenterSelector | getHoverCardPresenterSelector()Get {@link PresenterSelector} used for showing a select object in a hover card.
return mHoverCardPresenterSelector;
|
public int | getRecycledPoolSize(Presenter presenter)Returns the recycled pool size for the given presenter.
return mRecycledPoolSize.containsKey(presenter) ? mRecycledPoolSize.get(presenter) :
DEFAULT_RECYCLED_POOL_SIZE;
|
public int | getRowHeight()Returns the row height for list rows created by this Presenter.
return mRowHeight;
|
public final boolean | getShadowEnabled()Returns true if child shadow is enabled.
This is not only for enable/disable default shadow implementation but also subclass must
respect this flag.
return mShadowEnabled;
|
private int | getSpaceUnderBaseline(android.support.v17.leanback.widget.ListRowPresenter$ViewHolder vh)
RowHeaderPresenter.ViewHolder headerViewHolder = vh.getHeaderViewHolder();
if (headerViewHolder != null) {
if (getHeaderPresenter() != null) {
return getHeaderPresenter().getSpaceUnderBaseline(headerViewHolder);
}
return headerViewHolder.view.getPaddingBottom();
}
return 0;
|
public final int | getZoomFactor()Returns the zoom factor used for focus highlighting.
return mZoomFactor;
|
private static void | initStatics(android.content.Context context)
if (sSelectedRowTopPadding == 0) {
sSelectedRowTopPadding = context.getResources().getDimensionPixelSize(
R.dimen.lb_browse_selected_row_top_padding);
sExpandedSelectedRowTopPadding = context.getResources().getDimensionPixelSize(
R.dimen.lb_browse_expanded_selected_row_top_padding);
sExpandedRowNoHovercardBottomPadding = context.getResources().getDimensionPixelSize(
R.dimen.lb_browse_expanded_row_no_hovercard_bottom_padding);
}
|
protected void | initializeRowViewHolder(android.support.v17.leanback.widget.RowPresenter.ViewHolder holder)
super.initializeRowViewHolder(holder);
final ViewHolder rowViewHolder = (ViewHolder) holder;
if (needsDefaultListSelectEffect() || needsDefaultShadow()
|| areChildRoundedCornersEnabled()) {
rowViewHolder.mItemBridgeAdapter.setWrapper(mCardWrapper);
}
if (needsDefaultListSelectEffect()) {
ShadowOverlayContainer.prepareParentForShadow(rowViewHolder.mGridView);
}
FocusHighlightHelper.setupBrowseItemFocusHighlight(rowViewHolder.mItemBridgeAdapter,
mZoomFactor, false);
rowViewHolder.mGridView.setFocusDrawingOrderEnabled(!isUsingZOrder());
rowViewHolder.mGridView.setOnChildSelectedListener(
new OnChildSelectedListener() {
@Override
public void onChildSelected(ViewGroup parent, View view, int position, long id) {
selectChildView(rowViewHolder, view);
}
});
rowViewHolder.mItemBridgeAdapter.setAdapterListener(
new ItemBridgeAdapter.AdapterListener() {
@Override
public void onBind(final ItemBridgeAdapter.ViewHolder viewHolder) {
// Only when having an OnItemClickListner, we will attach the OnClickListener.
if (getOnItemClickedListener() != null || getOnItemViewClickedListener() != null) {
viewHolder.mHolder.view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ItemBridgeAdapter.ViewHolder ibh = (ItemBridgeAdapter.ViewHolder)
rowViewHolder.mGridView
.getChildViewHolder(viewHolder.itemView);
if (getOnItemClickedListener() != null) {
getOnItemClickedListener().onItemClicked(ibh.mItem,
(ListRow) rowViewHolder.mRow);
}
if (getOnItemViewClickedListener() != null) {
getOnItemViewClickedListener().onItemClicked(viewHolder.mHolder,
ibh.mItem, rowViewHolder, (ListRow) rowViewHolder.mRow);
}
}
});
}
}
@Override
public void onUnbind(ItemBridgeAdapter.ViewHolder viewHolder) {
if (getOnItemClickedListener() != null || getOnItemViewClickedListener() != null) {
viewHolder.mHolder.view.setOnClickListener(null);
}
}
@Override
public void onAttachedToWindow(ItemBridgeAdapter.ViewHolder viewHolder) {
if (viewHolder.itemView instanceof ShadowOverlayContainer) {
int dimmedColor = rowViewHolder.mColorDimmer.getPaint().getColor();
((ShadowOverlayContainer) viewHolder.itemView).setOverlayColor(dimmedColor);
}
viewHolder.itemView.setActivated(rowViewHolder.mExpanded);
}
@Override
public void onAddPresenter(Presenter presenter, int type) {
rowViewHolder.getGridView().getRecycledViewPool().setMaxRecycledViews(
type, getRecycledPoolSize(presenter));
}
});
|
public boolean | isUsingDefaultListSelectEffect()Returns true so that default select effect is applied to each individual
child of {@link HorizontalGridView}. Subclass may return false to disable
the default implementation.
return true;
|
public final boolean | isUsingDefaultSelectEffect()ListRowPresenter overrides the default select effect of {@link RowPresenter}
and return false.
return false;
|
public boolean | isUsingDefaultShadow()Returns true if SDK >= 18, where default shadow
is applied to each individual child of {@link HorizontalGridView}.
Subclass may return false to disable.
return ShadowOverlayContainer.supportsShadow();
|
public boolean | isUsingZOrder()Returns true if SDK >= L, where Z shadow is enabled so that Z order is enabled
on each child of horizontal list. If subclass returns false in isUsingDefaultShadow()
and does not use Z-shadow on SDK >= L, it should override isUsingZOrder() return false.
return ShadowHelper.getInstance().usesZShadow();
|
final boolean | needsDefaultListSelectEffect()
return isUsingDefaultListSelectEffect() && getSelectEffectEnabled();
|
final boolean | needsDefaultShadow()
return isUsingDefaultShadow() && getShadowEnabled();
|
protected void | onBindRowViewHolder(android.support.v17.leanback.widget.RowPresenter.ViewHolder holder, java.lang.Object item)
super.onBindRowViewHolder(holder, item);
ViewHolder vh = (ViewHolder) holder;
ListRow rowItem = (ListRow) item;
vh.mItemBridgeAdapter.setAdapter(rowItem.getAdapter());
vh.mGridView.setAdapter(vh.mItemBridgeAdapter);
|
protected void | onRowViewExpanded(android.support.v17.leanback.widget.RowPresenter.ViewHolder holder, boolean expanded)
super.onRowViewExpanded(holder, expanded);
ViewHolder vh = (ViewHolder) holder;
if (getRowHeight() != getExpandedRowHeight()) {
int newHeight = expanded ? getExpandedRowHeight() : getRowHeight();
vh.getGridView().setRowHeight(newHeight);
}
setVerticalPadding(vh);
updateFooterViewSwitcher(vh);
|
protected void | onRowViewSelected(android.support.v17.leanback.widget.RowPresenter.ViewHolder holder, boolean selected)
super.onRowViewSelected(holder, selected);
ViewHolder vh = (ViewHolder) holder;
setVerticalPadding(vh);
updateFooterViewSwitcher(vh);
|
protected void | onSelectLevelChanged(android.support.v17.leanback.widget.RowPresenter.ViewHolder holder)Applies select level to header and draw a default color dim over each child
of {@link HorizontalGridView}.
Subclass may override this method. A subclass
needs to call super.onSelectLevelChanged() for applying header select level
and optionally applying a default select level to each child view of
{@link HorizontalGridView} if {@link #isUsingDefaultListSelectEffect()}
is true. Subclass may override {@link #isUsingDefaultListSelectEffect()} to return
false and deal with the individual item select level by itself.
super.onSelectLevelChanged(holder);
if (needsDefaultListSelectEffect()) {
ViewHolder vh = (ViewHolder) holder;
int dimmedColor = vh.mColorDimmer.getPaint().getColor();
for (int i = 0, count = vh.mGridView.getChildCount(); i < count; i++) {
ShadowOverlayContainer wrapper = (ShadowOverlayContainer) vh.mGridView.getChildAt(i);
wrapper.setOverlayColor(dimmedColor);
}
if (vh.mGridView.getFadingLeftEdge()) {
vh.mGridView.invalidate();
}
}
|
protected void | onUnbindRowViewHolder(android.support.v17.leanback.widget.RowPresenter.ViewHolder holder)
ViewHolder vh = (ViewHolder) holder;
vh.mGridView.setAdapter(null);
vh.mItemBridgeAdapter.clear();
super.onUnbindRowViewHolder(holder);
|
private void | selectChildView(android.support.v17.leanback.widget.ListRowPresenter$ViewHolder rowViewHolder, android.view.View view)
ItemBridgeAdapter.ViewHolder ibh = null;
if (view != null) {
ibh = (ItemBridgeAdapter.ViewHolder)
rowViewHolder.mGridView.getChildViewHolder(view);
}
if (view == null) {
if (mHoverCardPresenterSelector != null) {
rowViewHolder.mHoverCardViewSwitcher.unselect();
}
if (getOnItemViewSelectedListener() != null) {
getOnItemViewSelectedListener().onItemSelected(null, null,
rowViewHolder, rowViewHolder.mRow);
}
if (getOnItemSelectedListener() != null) {
getOnItemSelectedListener().onItemSelected(null, rowViewHolder.mRow);
}
} else if (rowViewHolder.mExpanded && rowViewHolder.mSelected) {
if (mHoverCardPresenterSelector != null) {
rowViewHolder.mHoverCardViewSwitcher.select(rowViewHolder.mGridView, view,
ibh.mItem);
}
if (getOnItemViewSelectedListener() != null) {
getOnItemViewSelectedListener().onItemSelected(ibh.mHolder, ibh.mItem,
rowViewHolder, rowViewHolder.mRow);
}
if (getOnItemSelectedListener() != null) {
getOnItemSelectedListener().onItemSelected(ibh.mItem, rowViewHolder.mRow);
}
}
|
public void | setEntranceTransitionState(android.support.v17.leanback.widget.RowPresenter.ViewHolder holder, boolean afterEntrance)
super.setEntranceTransitionState(holder, afterEntrance);
((ViewHolder) holder).mGridView.setChildrenVisibility(
afterEntrance? View.VISIBLE : View.INVISIBLE);
|
public void | setExpandedRowHeight(int rowHeight)Sets the expanded row height for rows created by this Presenter.
If not set, expanded rows have the same height as unexpanded
rows.
mExpandedRowHeight = rowHeight;
|
public final void | setHoverCardPresenterSelector(PresenterSelector selector)Set {@link PresenterSelector} used for showing a select object in a hover card.
mHoverCardPresenterSelector = selector;
|
public void | setRecycledPoolSize(Presenter presenter, int size)Sets the recycled pool size for the given presenter.
mRecycledPoolSize.put(presenter, size);
|
public void | setRowHeight(int rowHeight)Sets the row height for rows created by this Presenter. Rows
created before calling this method will not be updated.
mRowHeight = rowHeight;
|
public final void | setShadowEnabled(boolean enabled)Enable or disable child shadow.
This is not only for enable/disable default shadow implementation but also subclass must
respect this flag.
mShadowEnabled = enabled;
|
private void | setVerticalPadding(android.support.v17.leanback.widget.ListRowPresenter$ViewHolder vh)
int paddingTop, paddingBottom;
// Note: sufficient bottom padding needed for card shadows.
if (vh.isExpanded()) {
int headerSpaceUnderBaseline = getSpaceUnderBaseline(vh);
if (DEBUG) Log.v(TAG, "headerSpaceUnderBaseline " + headerSpaceUnderBaseline);
paddingTop = (vh.isSelected() ? sExpandedSelectedRowTopPadding : vh.mPaddingTop) -
headerSpaceUnderBaseline;
paddingBottom = mHoverCardPresenterSelector == null ?
sExpandedRowNoHovercardBottomPadding : vh.mPaddingBottom;
} else if (vh.isSelected()) {
paddingTop = sSelectedRowTopPadding - vh.mPaddingBottom;
paddingBottom = sSelectedRowTopPadding;
} else {
paddingTop = 0;
paddingBottom = vh.mPaddingBottom;
}
vh.getGridView().setPadding(vh.mPaddingLeft, paddingTop, vh.mPaddingRight,
paddingBottom);
|
private void | setupFadingEffect(ListRowView rowView)
// content is completely faded at 1/2 padding of left, fading length is 1/2 of padding.
HorizontalGridView gridView = rowView.getGridView();
if (mBrowseRowsFadingEdgeLength < 0) {
TypedArray ta = gridView.getContext()
.obtainStyledAttributes(R.styleable.LeanbackTheme);
mBrowseRowsFadingEdgeLength = (int) ta.getDimension(
R.styleable.LeanbackTheme_browseRowsFadingEdgeLength, 0);
ta.recycle();
}
gridView.setFadingLeftEdgeLength(mBrowseRowsFadingEdgeLength);
|
private void | updateFooterViewSwitcher(android.support.v17.leanback.widget.ListRowPresenter$ViewHolder vh)
if (vh.mExpanded && vh.mSelected) {
if (mHoverCardPresenterSelector != null) {
vh.mHoverCardViewSwitcher.init((ViewGroup) vh.view,
mHoverCardPresenterSelector);
}
ItemBridgeAdapter.ViewHolder ibh = (ItemBridgeAdapter.ViewHolder)
vh.mGridView.findViewHolderForPosition(
vh.mGridView.getSelectedPosition());
selectChildView(vh, ibh == null ? null : ibh.itemView);
} else {
if (mHoverCardPresenterSelector != null) {
vh.mHoverCardViewSwitcher.unselect();
}
}
|