Methods Summary |
---|
public boolean | canDrawOutOfBounds()Return true if the Row view can draw outside its bounds.
return false;
|
protected abstract android.support.v17.leanback.widget.RowPresenter$ViewHolder | createRowViewHolder(android.view.ViewGroup parent)Called to create a ViewHolder object for a Row. Subclasses will override
this method to return a different concrete ViewHolder object.
|
public void | freeze(android.support.v17.leanback.widget.RowPresenter$ViewHolder holder, boolean freeze)Freeze/Unfreeze the row, typically used when transition starts/ends.
This method is called by fragment, app should not call it directly.
|
public final RowHeaderPresenter | getHeaderPresenter()Get the Presenter used for rendering the header, or null if none has been
set.
return mHeaderPresenter;
|
public final OnItemClickedListener | getOnItemClickedListener()Get the listener for item click events.
return mOnItemClickedListener;
|
public final OnItemSelectedListener | getOnItemSelectedListener()Get the listener for item or row selection.
return mOnItemSelectedListener;
|
public final OnItemViewClickedListener | getOnItemViewClickedListener()Set listener for item click event.
return mOnItemViewClickedListener;
|
public final OnItemViewSelectedListener | getOnItemViewSelectedListener()Get listener for item or row selection.
return mOnItemViewSelectedListener;
|
public final android.support.v17.leanback.widget.RowPresenter$ViewHolder | getRowViewHolder(Presenter.ViewHolder holder)Get the {@link RowPresenter.ViewHolder} from the given Presenter
ViewHolder.
if (holder instanceof ContainerViewHolder) {
return ((ContainerViewHolder) holder).mRowViewHolder;
} else {
return (ViewHolder) holder;
}
|
public final boolean | getSelectEffectEnabled()Returns true if the row selection effect is enabled.
This value not only determines whether the default dim implementation is
used, but subclasses must also respect this flag.
return mSelectEffectEnabled;
|
public final float | getSelectLevel(Presenter.ViewHolder vh)Get the current select level. The value will be between 0 (unselected)
and 1 (selected).
return getRowViewHolder(vh).mSelectLevel;
|
protected void | initializeRowViewHolder(android.support.v17.leanback.widget.RowPresenter$ViewHolder vh)Called after a {@link RowPresenter.ViewHolder} is created for a Row.
Subclasses may override this method and start by calling
super.initializeRowViewHolder(ViewHolder).
vh.mInitialzed = true;
// set clip children to false for slide transition
((ViewGroup) vh.view).setClipChildren(false);
if (vh.mContainerViewHolder != null) {
((ViewGroup) vh.mContainerViewHolder.view).setClipChildren(false);
}
|
public boolean | isUsingDefaultSelectEffect()Return whether this RowPresenter is using the default dimming effect
provided by the library. Subclasses may(most likely) return false and
override {@link #onSelectLevelChanged(ViewHolder)}.
return true;
|
final boolean | needsDefaultSelectEffect()
return isUsingDefaultSelectEffect() && getSelectEffectEnabled();
|
final boolean | needsRowContainerView()
return mHeaderPresenter != null || needsDefaultSelectEffect();
|
protected void | onBindRowViewHolder(android.support.v17.leanback.widget.RowPresenter$ViewHolder vh, java.lang.Object item)
vh.mRow = (Row) item;
if (vh.mHeaderViewHolder != null) {
mHeaderPresenter.onBindViewHolder(vh.mHeaderViewHolder, item);
}
|
public final void | onBindViewHolder(Presenter.ViewHolder viewHolder, java.lang.Object item)
onBindRowViewHolder(getRowViewHolder(viewHolder), item);
|
public final Presenter.ViewHolder | onCreateViewHolder(android.view.ViewGroup parent)
ViewHolder vh = createRowViewHolder(parent);
vh.mInitialzed = false;
Presenter.ViewHolder result;
if (needsRowContainerView()) {
RowContainerView containerView = new RowContainerView(parent.getContext());
if (mHeaderPresenter != null) {
vh.mHeaderViewHolder = (RowHeaderPresenter.ViewHolder)
mHeaderPresenter.onCreateViewHolder((ViewGroup) vh.view);
}
result = new ContainerViewHolder(containerView, vh);
} else {
result = vh;
}
initializeRowViewHolder(vh);
if (!vh.mInitialzed) {
throw new RuntimeException("super.initializeRowViewHolder() must be called");
}
return result;
|
protected void | onRowViewAttachedToWindow(android.support.v17.leanback.widget.RowPresenter$ViewHolder vh)
if (vh.mHeaderViewHolder != null) {
mHeaderPresenter.onViewAttachedToWindow(vh.mHeaderViewHolder);
}
|
protected void | onRowViewDetachedFromWindow(android.support.v17.leanback.widget.RowPresenter$ViewHolder vh)
if (vh.mHeaderViewHolder != null) {
mHeaderPresenter.onViewDetachedFromWindow(vh.mHeaderViewHolder);
}
cancelAnimationsRecursive(vh.view);
|
protected void | onRowViewExpanded(android.support.v17.leanback.widget.RowPresenter$ViewHolder vh, boolean expanded)Subclass may override this to respond to expanded state changes of a Row.
The default implementation will hide/show the header view. Subclasses may
make visual changes to the Row View but must not create animation on the
Row view.
updateHeaderViewVisibility(vh);
vh.view.setActivated(expanded);
|
protected void | onRowViewSelected(android.support.v17.leanback.widget.RowPresenter$ViewHolder vh, boolean selected)Subclass may override this to respond to selected state changes of a Row.
Subclass may make visual changes to Row view but must not create
animation on the Row view.
if (selected) {
if (mOnItemViewSelectedListener != null) {
mOnItemViewSelectedListener.onItemSelected(null, null, vh, vh.getRow());
}
if (mOnItemSelectedListener != null) {
mOnItemSelectedListener.onItemSelected(null, vh.getRow());
}
}
updateHeaderViewVisibility(vh);
|
protected void | onSelectLevelChanged(android.support.v17.leanback.widget.RowPresenter$ViewHolder vh)Callback when select level is changed. The default implementation applies
the select level to {@link RowHeaderPresenter#setSelectLevel(RowHeaderPresenter.ViewHolder, float)}
when {@link #getSelectEffectEnabled()} is true. Subclasses may override
this function and implement a different select effect. In this case, you
should also override {@link #isUsingDefaultSelectEffect()} to disable
the default dimming effect applied by the library.
if (getSelectEffectEnabled()) {
vh.mColorDimmer.setActiveLevel(vh.mSelectLevel);
if (vh.mHeaderViewHolder != null) {
mHeaderPresenter.setSelectLevel(vh.mHeaderViewHolder, vh.mSelectLevel);
}
if (isUsingDefaultSelectEffect()) {
((RowContainerView) vh.mContainerViewHolder.view).setForegroundColor(
vh.mColorDimmer.getPaint().getColor());
}
}
|
protected void | onUnbindRowViewHolder(android.support.v17.leanback.widget.RowPresenter$ViewHolder vh)
if (vh.mHeaderViewHolder != null) {
mHeaderPresenter.onUnbindViewHolder(vh.mHeaderViewHolder);
}
vh.mRow = null;
|
public final void | onUnbindViewHolder(Presenter.ViewHolder viewHolder)
onUnbindRowViewHolder(getRowViewHolder(viewHolder));
|
public final void | onViewAttachedToWindow(Presenter.ViewHolder holder)
onRowViewAttachedToWindow(getRowViewHolder(holder));
|
public final void | onViewDetachedFromWindow(Presenter.ViewHolder holder)
onRowViewDetachedFromWindow(getRowViewHolder(holder));
|
public void | setEntranceTransitionState(android.support.v17.leanback.widget.RowPresenter$ViewHolder holder, boolean afterTransition)Change visibility of views, entrance transition will be run against the views that
change visibilities. Subclass may override and begin with calling
super.setEntranceTransitionState(). This method is called by fragment,
app should not call it directly.
if (holder.mHeaderViewHolder != null) {
holder.mHeaderViewHolder.view.setVisibility(afterTransition ?
View.VISIBLE : View.INVISIBLE);
}
|
public final void | setHeaderPresenter(RowHeaderPresenter headerPresenter)Set the Presenter used for rendering the header. Can be null to disable
header rendering. The method must be called before creating any Row Views.
mHeaderPresenter = headerPresenter;
|
public final void | setOnItemClickedListener(OnItemClickedListener listener)Set the listener for item click events. A RowPresenter does not use this
listener, but a subclass may fire an item click event if it has the concept
of an item. The {@link OnItemClickedListener} will override any
{@link View.OnClickListener} that an item's Presenter sets during
{@link Presenter#onCreateViewHolder(ViewGroup)}. So in general, you
should choose to use an OnItemClickedListener or a {@link
View.OnClickListener}, but not both.
mOnItemClickedListener = listener;
|
public final void | setOnItemSelectedListener(OnItemSelectedListener listener)Set the listener for item or row selection. A RowPresenter fires a row
selection event with a null item. Subclasses (e.g. {@link ListRowPresenter})
can fire a selection event with the selected item.
mOnItemSelectedListener = listener;
|
public final void | setOnItemViewClickedListener(OnItemViewClickedListener listener)Set listener for item click event. RowPresenter does nothing but subclass of
RowPresenter may fire item click event if it does have a concept of item.
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)Set listener for item or row selection. RowPresenter fires row selection
event with null item, subclass of RowPresenter e.g. {@link ListRowPresenter} can
fire a selection event with selected item.
mOnItemViewSelectedListener = listener;
|
public final void | setRowViewExpanded(Presenter.ViewHolder holder, boolean expanded)Set the expanded state of a Row view.
ViewHolder rowViewHolder = getRowViewHolder(holder);
rowViewHolder.mExpanded = expanded;
onRowViewExpanded(rowViewHolder, expanded);
|
public final void | setRowViewSelected(Presenter.ViewHolder holder, boolean selected)Set the selected state of a Row view.
ViewHolder rowViewHolder = getRowViewHolder(holder);
rowViewHolder.mSelected = selected;
onRowViewSelected(rowViewHolder, selected);
|
public final void | setSelectEffectEnabled(boolean applyDimOnSelect)Enables or disables the row selection effect.
This will not only affect the default dim effect, but subclasses must
respect this flag as well.
mSelectEffectEnabled = applyDimOnSelect;
|
public final void | setSelectLevel(Presenter.ViewHolder vh, float level)Set the current select level to a value between 0 (unselected) and 1 (selected).
Subclasses may override {@link #onSelectLevelChanged(ViewHolder)} to
respond to changes in the selected level.
ViewHolder rowViewHolder = getRowViewHolder(vh);
rowViewHolder.mSelectLevel = level;
onSelectLevelChanged(rowViewHolder);
|
private void | updateHeaderViewVisibility(android.support.v17.leanback.widget.RowPresenter$ViewHolder vh)
if (mHeaderPresenter != null && vh.mHeaderViewHolder != null) {
RowContainerView containerView = ((RowContainerView) vh.mContainerViewHolder.view);
containerView.showHeader(vh.isExpanded());
}
|