Methods Summary |
---|
public final boolean | areChildRoundedCornersEnabled()Returns true if rounded corners are enabled for children of this row.
return mRoundedCornersEnabled;
|
protected android.support.v17.leanback.widget.VerticalGridPresenter$ViewHolder | createGridViewHolder(android.view.ViewGroup parent)Subclass may override this to inflate a different layout.
View root = LayoutInflater.from(parent.getContext()).inflate(
R.layout.lb_vertical_grid, parent, false);
return new ViewHolder((VerticalGridView) root.findViewById(R.id.browse_grid));
|
public final void | enableChildRoundedCorners(boolean enable)Enables or disabled rounded corners on children of this row.
Supported on Android SDK >= L.
mRoundedCornersEnabled = enable;
|
public int | getNumberOfColumns()Returns the number of columns in the vertical grid.
return mNumColumns;
|
public final OnItemClickedListener | getOnItemClickedListener()Returns the item clicked listener.
return mOnItemClickedListener;
|
public final OnItemSelectedListener | getOnItemSelectedListener()Returns the item selected listener.
return mOnItemSelectedListener;
|
public final OnItemViewClickedListener | getOnItemViewClickedListener()Returns the item clicked listener.
return mOnItemViewClickedListener;
|
public final OnItemViewSelectedListener | getOnItemViewSelectedListener()Returns the item selected listener.
return mOnItemViewSelectedListener;
|
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;
|
protected void | initializeGridViewHolder(android.support.v17.leanback.widget.VerticalGridPresenter$ViewHolder vh)Called after a {@link VerticalGridPresenter.ViewHolder} is created.
Subclasses may override this method and start by calling
super.initializeGridViewHolder(ViewHolder).
if (mNumColumns == -1) {
throw new IllegalStateException("Number of columns must be set");
}
if (DEBUG) Log.v(TAG, "mNumColumns " + mNumColumns);
vh.getGridView().setNumColumns(mNumColumns);
vh.mInitialized = true;
vh.mItemBridgeAdapter.setWrapper(mWrapper);
if (needsDefaultShadow() || areChildRoundedCornersEnabled()) {
ShadowOverlayContainer.prepareParentForShadow(vh.getGridView());
((ViewGroup) vh.view).setClipChildren(false);
}
vh.getGridView().setFocusDrawingOrderEnabled(!isUsingZOrder());
FocusHighlightHelper.setupBrowseItemFocusHighlight(vh.mItemBridgeAdapter,
mZoomFactor, true);
final ViewHolder gridViewHolder = vh;
vh.getGridView().setOnChildSelectedListener(new OnChildSelectedListener() {
@Override
public void onChildSelected(ViewGroup parent, View view, int position, long id) {
selectChildView(gridViewHolder, view);
}
});
vh.mItemBridgeAdapter.setAdapterListener(new ItemBridgeAdapter.AdapterListener() {
@Override
public void onBind(final ItemBridgeAdapter.ViewHolder itemViewHolder) {
// Only when having an OnItemClickListner, we attach the OnClickListener.
if (getOnItemClickedListener() != null || getOnItemViewClickedListener() != null) {
final View itemView = itemViewHolder.mHolder.view;
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (getOnItemClickedListener() != null) {
// Row is always null
getOnItemClickedListener().onItemClicked(itemViewHolder.mItem,
null);
}
if (getOnItemViewClickedListener() != null) {
// Row is always null
getOnItemViewClickedListener().onItemClicked(
itemViewHolder.mHolder, itemViewHolder.mItem, null, null);
}
}
});
}
}
@Override
public void onUnbind(ItemBridgeAdapter.ViewHolder viewHolder) {
if (getOnItemClickedListener() != null || getOnItemViewClickedListener() != null) {
viewHolder.mHolder.view.setOnClickListener(null);
}
}
@Override
public void onAttachedToWindow(ItemBridgeAdapter.ViewHolder viewHolder) {
viewHolder.itemView.setActivated(true);
}
});
|
public boolean | isUsingDefaultShadow()Returns true if opticalBounds is supported (SDK >= 18) so that default shadow
is applied to each individual child of {@link VerticalGridView}.
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 vertical grid. 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 | needsDefaultShadow()
return isUsingDefaultShadow() && getShadowEnabled();
|
public void | onBindViewHolder(Presenter.ViewHolder viewHolder, java.lang.Object item)
if (DEBUG) Log.v(TAG, "onBindViewHolder " + item);
ViewHolder vh = (ViewHolder) viewHolder;
vh.mItemBridgeAdapter.setAdapter((ObjectAdapter) item);
vh.getGridView().setAdapter(vh.mItemBridgeAdapter);
|
public final android.support.v17.leanback.widget.VerticalGridPresenter$ViewHolder | onCreateViewHolder(android.view.ViewGroup parent)
ViewHolder vh = createGridViewHolder(parent);
vh.mInitialized = false;
initializeGridViewHolder(vh);
if (!vh.mInitialized) {
throw new RuntimeException("super.initializeGridViewHolder() must be called");
}
return vh;
|
public void | onUnbindViewHolder(Presenter.ViewHolder viewHolder)
if (DEBUG) Log.v(TAG, "onUnbindViewHolder");
ViewHolder vh = (ViewHolder) viewHolder;
vh.mItemBridgeAdapter.setAdapter(null);
vh.getGridView().setAdapter(null);
|
private void | selectChildView(android.support.v17.leanback.widget.VerticalGridPresenter$ViewHolder vh, android.view.View view)
if (getOnItemSelectedListener() != null) {
ItemBridgeAdapter.ViewHolder ibh = (view == null) ? null :
(ItemBridgeAdapter.ViewHolder) vh.getGridView().getChildViewHolder(view);
if (ibh == null) {
getOnItemSelectedListener().onItemSelected(null, null);
} else {
getOnItemSelectedListener().onItemSelected(ibh.mItem, null);
}
}
if (getOnItemViewSelectedListener() != null) {
ItemBridgeAdapter.ViewHolder ibh = (view == null) ? null :
(ItemBridgeAdapter.ViewHolder) vh.getGridView().getChildViewHolder(view);
if (ibh == null) {
getOnItemViewSelectedListener().onItemSelected(null, null, null, null);
} else {
getOnItemViewSelectedListener().onItemSelected(ibh.mHolder, ibh.mItem, null, null);
}
}
|
public void | setNumberOfColumns(int numColumns)Sets the number of columns in the vertical grid.
if (numColumns < 0) {
throw new IllegalArgumentException("Invalid number of columns");
}
if (mNumColumns != numColumns) {
mNumColumns = numColumns;
}
|
public final void | setOnItemClickedListener(OnItemClickedListener listener)Sets the item clicked listener.
OnItemClickedListener will override {@link View.OnClickListener} that
item presenter sets during {@link Presenter#onCreateViewHolder(ViewGroup)}.
So in general, developer should choose one of the listeners but not both.
mOnItemClickedListener = listener;
|
public final void | setOnItemSelectedListener(OnItemSelectedListener listener)Sets the item selected listener.
Since this is a grid the row parameter is always null.
mOnItemSelectedListener = listener;
|
public final void | setOnItemViewClickedListener(OnItemViewClickedListener listener)Sets the item clicked listener.
OnItemViewClickedListener will override {@link View.OnClickListener} that
item presenter sets during {@link Presenter#onCreateViewHolder(ViewGroup)}.
So in general, developer should choose one of the listeners but not both.
mOnItemViewClickedListener = listener;
|
public final void | setOnItemViewSelectedListener(OnItemViewSelectedListener listener)Sets the item selected listener.
Since this is a grid the row parameter is always null.
mOnItemViewSelectedListener = listener;
|
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;
|