Fields Summary |
---|
private static final String | TAG |
private static final boolean | DEBUG |
private ItemBridgeAdapter.ViewHolder | mSelectedViewHolder |
private boolean | mExpand |
private boolean | mViewsCreated |
private float | mRowScaleFactor |
private int | mAlignedTop |
private boolean | mRowScaleEnabled |
private android.support.v17.leanback.widget.ScaleFrameLayout | mScaleFrameLayout |
private boolean | mInTransition |
private boolean | mAfterEntranceTransition |
private android.support.v17.leanback.widget.OnItemSelectedListener | mOnItemSelectedListener |
private android.support.v17.leanback.widget.OnItemViewSelectedListener | mOnItemViewSelectedListener |
private android.support.v17.leanback.widget.OnItemClickedListener | mOnItemClickedListener |
private android.support.v17.leanback.widget.OnItemViewClickedListener | mOnItemViewClickedListener |
int | mSelectAnimatorDuration |
android.view.animation.Interpolator | mSelectAnimatorInterpolator |
private RecyclerView.RecycledViewPool | mRecycledViewPool |
private ArrayList | mPresenterMapper |
private ItemBridgeAdapter.AdapterListener | mExternalAdapterListener |
private final ItemBridgeAdapter.AdapterListener | mBridgeAdapterListener |
Methods Summary |
---|
public void | enableRowScaling(boolean enable)Enables scaling of rows.
mRowScaleEnabled = enable;
|
protected android.support.v17.leanback.widget.VerticalGridView | findGridViewFromRoot(android.view.View view)
return (VerticalGridView) view.findViewById(R.id.container_list);
|
private void | freezeRows(boolean freeze)
VerticalGridView verticalView = getVerticalGridView();
if (verticalView != null) {
final int count = verticalView.getChildCount();
for (int i = 0; i < count; i++) {
ItemBridgeAdapter.ViewHolder ibvh = (ItemBridgeAdapter.ViewHolder)
verticalView.getChildViewHolder(verticalView.getChildAt(i));
RowPresenter rowPresenter = (RowPresenter) ibvh.getPresenter();
RowPresenter.ViewHolder vh = rowPresenter.getRowViewHolder(ibvh.getViewHolder());
rowPresenter.freeze(vh, freeze);
}
}
|
int | getLayoutResourceId()
return R.layout.lb_rows_fragment;
|
public android.support.v17.leanback.widget.OnItemClickedListener | getOnItemClickedListener()Returns the item clicked listener.
return mOnItemClickedListener;
|
public android.support.v17.leanback.widget.OnItemViewClickedListener | getOnItemViewClickedListener()Returns the item clicked listener.
return mOnItemViewClickedListener;
|
public android.support.v17.leanback.widget.OnItemViewSelectedListener | getOnItemViewSelectedListener()Returns an item selection listener.
return mOnItemViewSelectedListener;
|
android.view.View | getScaleView()Get the view that will change scale.
return getVerticalGridView();
|
private boolean | needsScale()
return mRowScaleEnabled && !mExpand;
|
public void | onCreate(android.os.Bundle savedInstanceState)
super.onCreate(savedInstanceState);
mSelectAnimatorDuration = getResources().getInteger(
R.integer.lb_browse_rows_anim_duration);
mRowScaleFactor = getResources().getFraction(
R.fraction.lb_browse_rows_scale, 1, 1);
|
public android.view.View | onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)
View view = super.onCreateView(inflater, container, savedInstanceState);
mScaleFrameLayout = (ScaleFrameLayout) view.findViewById(R.id.scale_frame);
return view;
|
public void | onDestroyView()
mViewsCreated = false;
super.onDestroyView();
|
void | onExpandTransitionStart(boolean expand, java.lang.Runnable callback)
onTransitionStart();
if (expand) {
callback.run();
return;
}
// Run a "pre" layout when we go non-expand, in order to get the initial
// positions of added rows.
new ExpandPreLayout(callback).execute();
|
void | onRowSelected(android.view.ViewGroup parent, android.view.View view, int position, long id)
VerticalGridView listView = getVerticalGridView();
if (listView == null) {
return;
}
ItemBridgeAdapter.ViewHolder vh = (view == null) ? null :
(ItemBridgeAdapter.ViewHolder) listView.getChildViewHolder(view);
if (mSelectedViewHolder != vh) {
if (DEBUG) Log.v(TAG, "new row selected position " + position + " view " + view);
if (mSelectedViewHolder != null) {
setRowViewSelected(mSelectedViewHolder, false, false);
}
mSelectedViewHolder = vh;
if (mSelectedViewHolder != null) {
setRowViewSelected(mSelectedViewHolder, true, false);
}
}
|
void | onTransitionEnd()
super.onTransitionEnd();
mInTransition = false;
freezeRows(false);
|
void | onTransitionStart()
super.onTransitionStart();
mInTransition = true;
freezeRows(true);
|
public void | onViewCreated(android.view.View view, android.os.Bundle savedInstanceState)
if (DEBUG) Log.v(TAG, "onViewCreated");
super.onViewCreated(view, savedInstanceState);
// Align the top edge of child with id row_content.
// Need set this for directly using RowsFragment.
getVerticalGridView().setItemAlignmentViewId(R.id.row_content);
getVerticalGridView().setSaveChildrenPolicy(VerticalGridView.SAVE_LIMITED_CHILD);
mRecycledViewPool = null;
mPresenterMapper = null;
|
void | setEntranceTransitionState(boolean afterTransition)For rows that willing to participate entrance transition, this function
hide views if afterTransition is true, show views if afterTransition is false.
mAfterEntranceTransition = afterTransition;
VerticalGridView verticalView = getVerticalGridView();
if (verticalView != null) {
final int count = verticalView.getChildCount();
for (int i = 0; i < count; i++) {
ItemBridgeAdapter.ViewHolder ibvh = (ItemBridgeAdapter.ViewHolder)
verticalView.getChildViewHolder(verticalView.getChildAt(i));
RowPresenter rowPresenter = (RowPresenter) ibvh.getPresenter();
RowPresenter.ViewHolder vh = rowPresenter.getRowViewHolder(ibvh.getViewHolder());
rowPresenter.setEntranceTransitionState(vh, mAfterEntranceTransition);
}
}
|
public void | setExpand(boolean expand)Set the visibility of titles/hovercard of browse rows.
mExpand = expand;
VerticalGridView listView = getVerticalGridView();
if (listView != null) {
updateRowScaling();
final int count = listView.getChildCount();
if (DEBUG) Log.v(TAG, "setExpand " + expand + " count " + count);
for (int i = 0; i < count; i++) {
View view = listView.getChildAt(i);
ItemBridgeAdapter.ViewHolder vh = (ItemBridgeAdapter.ViewHolder) listView.getChildViewHolder(view);
setRowViewExpanded(vh, mExpand);
}
}
|
void | setExternalAdapterListener(ItemBridgeAdapter.AdapterListener listener)
mExternalAdapterListener = listener;
|
void | setItemAlignment()
super.setItemAlignment();
if (getVerticalGridView() != null) {
getVerticalGridView().setItemAlignmentOffsetWithPadding(true);
}
|
public void | setOnItemClickedListener(android.support.v17.leanback.widget.OnItemClickedListener listener)Sets an item clicked listener on the fragment.
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;
if (mViewsCreated) {
throw new IllegalStateException(
"Item clicked listener must be set before views are created");
}
|
private static void | setOnItemSelectedListener(ItemBridgeAdapter.ViewHolder vh, android.support.v17.leanback.widget.OnItemSelectedListener listener)
((RowPresenter) vh.getPresenter()).setOnItemSelectedListener(listener);
|
public void | setOnItemSelectedListener(android.support.v17.leanback.widget.OnItemSelectedListener listener)Sets an item selection listener.
mOnItemSelectedListener = listener;
VerticalGridView listView = getVerticalGridView();
if (listView != null) {
final int count = listView.getChildCount();
for (int i = 0; i < count; i++) {
View view = listView.getChildAt(i);
ItemBridgeAdapter.ViewHolder vh = (ItemBridgeAdapter.ViewHolder)
listView.getChildViewHolder(view);
setOnItemSelectedListener(vh, mOnItemSelectedListener);
}
}
|
public void | setOnItemViewClickedListener(android.support.v17.leanback.widget.OnItemViewClickedListener listener)Sets an item clicked listener on the fragment.
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;
if (mViewsCreated) {
throw new IllegalStateException(
"Item clicked listener must be set before views are created");
}
|
private static void | setOnItemViewSelectedListener(ItemBridgeAdapter.ViewHolder vh, android.support.v17.leanback.widget.OnItemViewSelectedListener listener)
((RowPresenter) vh.getPresenter()).setOnItemViewSelectedListener(listener);
|
public void | setOnItemViewSelectedListener(android.support.v17.leanback.widget.OnItemViewSelectedListener listener)Sets an item selection listener.
mOnItemViewSelectedListener = listener;
VerticalGridView listView = getVerticalGridView();
if (listView != null) {
final int count = listView.getChildCount();
for (int i = 0; i < count; i++) {
View view = listView.getChildAt(i);
ItemBridgeAdapter.ViewHolder vh = (ItemBridgeAdapter.ViewHolder)
listView.getChildViewHolder(view);
setOnItemViewSelectedListener(vh, mOnItemViewSelectedListener);
}
}
|
private static void | setRowViewExpanded(ItemBridgeAdapter.ViewHolder vh, boolean expanded)
((RowPresenter) vh.getPresenter()).setRowViewExpanded(vh.getViewHolder(), expanded);
|
private static void | setRowViewSelected(ItemBridgeAdapter.ViewHolder vh, boolean selected, boolean immediate)
RowViewHolderExtra extra = (RowViewHolderExtra) vh.getExtraObject();
extra.animateSelect(selected, immediate);
((RowPresenter) vh.getPresenter()).setRowViewSelected(vh.getViewHolder(), selected);
|
void | setScalePivots(float pivotX, float pivotY)Set pivots to scale rows fragment.
// set pivot on ScaleFrameLayout, it will be propagated to its child VerticalGridView
// where we actually change scale.
mScaleFrameLayout.setPivotX(pivotX);
mScaleFrameLayout.setPivotY(pivotY);
|
void | setWindowAlignmentFromTop(int alignedTop)
mAlignedTop = alignedTop;
final VerticalGridView gridView = getVerticalGridView();
if (gridView != null) {
updateWindowAlignOffset();
// align to a fixed position from top
gridView.setWindowAlignmentOffsetPercent(
VerticalGridView.WINDOW_ALIGN_OFFSET_PERCENT_DISABLED);
gridView.setWindowAlignment(VerticalGridView.WINDOW_ALIGN_NO_EDGE);
}
|
private void | setupSharedViewPool(ItemBridgeAdapter.ViewHolder bridgeVh)
RowPresenter rowPresenter = (RowPresenter) bridgeVh.getPresenter();
RowPresenter.ViewHolder rowVh = rowPresenter.getRowViewHolder(bridgeVh.getViewHolder());
if (rowVh instanceof ListRowPresenter.ViewHolder) {
HorizontalGridView view = ((ListRowPresenter.ViewHolder) rowVh).getGridView();
// Recycled view pool is shared between all list rows
if (mRecycledViewPool == null) {
mRecycledViewPool = view.getRecycledViewPool();
} else {
view.setRecycledViewPool(mRecycledViewPool);
}
ItemBridgeAdapter bridgeAdapter =
((ListRowPresenter.ViewHolder) rowVh).getBridgeAdapter();
if (mPresenterMapper == null) {
mPresenterMapper = bridgeAdapter.getPresenterMapper();
} else {
bridgeAdapter.setPresenterMapper(mPresenterMapper);
}
}
|
void | updateAdapter()
super.updateAdapter();
mSelectedViewHolder = null;
mViewsCreated = false;
ItemBridgeAdapter adapter = getBridgeAdapter();
if (adapter != null) {
adapter.setAdapterListener(mBridgeAdapterListener);
}
|
private void | updateRowScaling()
final float scaleFactor = needsScale() ? mRowScaleFactor : 1f;
mScaleFrameLayout.setLayoutScaleY(scaleFactor);
getScaleView().setScaleY(scaleFactor);
getScaleView().setScaleX(scaleFactor);
updateWindowAlignOffset();
|
private void | updateWindowAlignOffset()
int alignOffset = mAlignedTop;
if (needsScale()) {
alignOffset = (int) (alignOffset / mRowScaleFactor + 0.5f);
}
getVerticalGridView().setWindowAlignmentOffset(alignOffset);
|