Fields Summary |
---|
private static final String | TAG |
private static boolean | DEBUG |
private android.support.v17.leanback.widget.BrowseFrameLayout | mBrowseFrame |
private String | mTitle |
private android.graphics.drawable.Drawable | mBadgeDrawable |
private android.support.v17.leanback.widget.ObjectAdapter | mAdapter |
private android.support.v17.leanback.widget.VerticalGridPresenter | mGridPresenter |
private VerticalGridPresenter.ViewHolder | mGridViewHolder |
private android.support.v17.leanback.widget.OnItemSelectedListener | mOnItemSelectedListener |
private android.support.v17.leanback.widget.OnItemClickedListener | mOnItemClickedListener |
private android.support.v17.leanback.widget.OnItemViewSelectedListener | mOnItemViewSelectedListener |
private android.support.v17.leanback.widget.OnItemViewClickedListener | mOnItemViewClickedListener |
private View.OnClickListener | mExternalOnSearchClickedListener |
private int | mSelectedPosition |
private android.support.v17.leanback.widget.TitleView | mTitleView |
private SearchOrbView.Colors | mSearchAffordanceColors |
private boolean | mSearchAffordanceColorSet |
private boolean | mShowingTitle |
private static android.support.v17.leanback.transition.TransitionHelper | sTransitionHelper |
private Object | mTitleUpTransition |
private Object | mTitleDownTransition |
private Object | mSceneWithTitle |
private Object | mSceneWithoutTitle |
private final android.support.v17.leanback.widget.OnItemViewSelectedListener | mRowSelectedListener |
private final BrowseFrameLayout.OnFocusSearchListener | mOnFocusSearchListener |
Methods Summary |
---|
public android.support.v17.leanback.widget.ObjectAdapter | getAdapter()Returns the object adapter.
return mAdapter;
|
public android.graphics.drawable.Drawable | getBadgeDrawable()Returns the badge drawable.
return mBadgeDrawable;
|
public android.support.v17.leanback.widget.VerticalGridPresenter | getGridPresenter()Returns the grid presenter.
return mGridPresenter;
|
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 int | getSearchAffordanceColor()Returns the color used to draw the search affordance.
return getSearchAffordanceColors().color;
|
public SearchOrbView.Colors | getSearchAffordanceColors()Returns the {@link SearchOrbView.Colors} used to draw the search affordance.
if (mSearchAffordanceColorSet) {
return mSearchAffordanceColors;
}
if (mTitleView == null) {
throw new IllegalStateException("Fragment views not yet created");
}
return mTitleView.getSearchAffordanceColors();
|
public java.lang.String | getTitle()Returns the title for the fragment.
return mTitle;
|
public android.view.View | onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.lb_vertical_grid_fragment,
container, false);
mBrowseFrame = (BrowseFrameLayout) root.findViewById(R.id.browse_frame);
mBrowseFrame.setOnFocusSearchListener(mOnFocusSearchListener);
mTitleView = (TitleView) root.findViewById(R.id.browse_title_group);
mTitleView.setBadgeDrawable(mBadgeDrawable);
mTitleView.setTitle(mTitle);
if (mSearchAffordanceColorSet) {
mTitleView.setSearchAffordanceColors(mSearchAffordanceColors);
}
if (mExternalOnSearchClickedListener != null) {
mTitleView.setOnSearchClickedListener(mExternalOnSearchClickedListener);
}
mSceneWithTitle = sTransitionHelper.createScene(root, new Runnable() {
@Override
public void run() {
mTitleView.setVisibility(View.VISIBLE);
}
});
mSceneWithoutTitle = sTransitionHelper.createScene(root, new Runnable() {
@Override
public void run() {
mTitleView.setVisibility(View.INVISIBLE);
}
});
Context context = getActivity();
mTitleUpTransition = sTransitionHelper.loadTransition(context, R.transition.lb_title_out);
mTitleDownTransition = sTransitionHelper.loadTransition(context, R.transition.lb_title_in);
return root;
|
public void | onDestroyView()
super.onDestroyView();
mGridViewHolder = null;
|
public void | onPause()
mTitleView.enableAnimation(false);
super.onPause();
|
public void | onResume()
super.onResume();
mTitleView.enableAnimation(true);
|
private void | onRowSelected(int position)
if (position != mSelectedPosition) {
if (!mGridViewHolder.getGridView().hasPreviousViewInSameRow(position)) {
// if has no sibling in front of it, show title
if (!mShowingTitle) {
sTransitionHelper.runTransition(mSceneWithTitle, mTitleDownTransition);
mShowingTitle = true;
}
} else if (mShowingTitle) {
sTransitionHelper.runTransition(mSceneWithoutTitle, mTitleUpTransition);
mShowingTitle = false;
}
mSelectedPosition = position;
}
|
public void | onStart()
super.onStart();
mGridViewHolder.getGridView().requestFocus();
|
public void | onViewCreated(android.view.View view, android.os.Bundle savedInstanceState)
ViewGroup gridDock = (ViewGroup) view.findViewById(R.id.browse_grid_dock);
mGridViewHolder = mGridPresenter.onCreateViewHolder(gridDock);
gridDock.addView(mGridViewHolder.view);
updateAdapter();
|
public void | setAdapter(android.support.v17.leanback.widget.ObjectAdapter adapter)Sets the object adapter for the fragment.
mAdapter = adapter;
updateAdapter();
|
public void | setBadgeDrawable(android.graphics.drawable.Drawable drawable)Sets the badge drawable displayed in the title area.
if (drawable != mBadgeDrawable) {
mBadgeDrawable = drawable;
if (mTitleView != null) {
mTitleView.setBadgeDrawable(drawable);
}
}
|
public void | setGridPresenter(android.support.v17.leanback.widget.VerticalGridPresenter gridPresenter)Sets the grid presenter.
if (gridPresenter == null) {
throw new IllegalArgumentException("Grid presenter may not be null");
}
mGridPresenter = gridPresenter;
mGridPresenter.setOnItemViewSelectedListener(mRowSelectedListener);
if (mOnItemViewClickedListener != null) {
mGridPresenter.setOnItemViewClickedListener(mOnItemViewClickedListener);
}
if (mOnItemClickedListener != null) {
mGridPresenter.setOnItemClickedListener(mOnItemClickedListener);
}
|
public void | setOnItemClickedListener(android.support.v17.leanback.widget.OnItemClickedListener listener)Sets an item clicked listener.
mOnItemClickedListener = listener;
if (mGridPresenter != null) {
mGridPresenter.setOnItemClickedListener(mOnItemClickedListener);
}
|
public void | setOnItemSelectedListener(android.support.v17.leanback.widget.OnItemSelectedListener listener)Sets an item selection listener.
mOnItemSelectedListener = listener;
|
public void | setOnItemViewClickedListener(android.support.v17.leanback.widget.OnItemViewClickedListener listener)Sets an item clicked listener.
mOnItemViewClickedListener = listener;
if (mGridPresenter != null) {
mGridPresenter.setOnItemViewClickedListener(mOnItemViewClickedListener);
}
|
public void | setOnItemViewSelectedListener(android.support.v17.leanback.widget.OnItemViewSelectedListener listener)Sets an item selection listener.
mOnItemViewSelectedListener = listener;
|
public void | setOnSearchClickedListener(View.OnClickListener listener)Sets a click listener for the search affordance.
The presence of a listener will change the visibility of the search
affordance in the title area. When set to non-null, the title area will
contain a call to search action.
The listener's onClick method will be invoked when the user clicks on
the search action.
mExternalOnSearchClickedListener = listener;
if (mTitleView != null) {
mTitleView.setOnSearchClickedListener(listener);
}
|
public void | setSearchAffordanceColor(int color)Sets the color used to draw the search affordance.
A default brighter color will be set by the framework.
setSearchAffordanceColors(new SearchOrbView.Colors(color));
|
public void | setSearchAffordanceColors(SearchOrbView.Colors colors)Sets the {@link SearchOrbView.Colors} used to draw the search affordance.
mSearchAffordanceColors = colors;
mSearchAffordanceColorSet = true;
if (mTitleView != null) {
mTitleView.setSearchAffordanceColors(mSearchAffordanceColors);
}
|
public void | setSelectedPosition(int position)Sets the selected item position.
mSelectedPosition = position;
if(mGridViewHolder != null && mGridViewHolder.getGridView().getAdapter() != null) {
mGridViewHolder.getGridView().setSelectedPositionSmooth(position);
}
|
public void | setTitle(java.lang.String title)Sets a title for the fragment.
mTitle = title;
if (mTitleView != null) {
mTitleView.setTitle(mTitle);
}
|
private void | updateAdapter()
if (mGridViewHolder != null) {
mGridPresenter.onBindViewHolder(mGridViewHolder, mAdapter);
if (mSelectedPosition != -1) {
mGridViewHolder.getGridView().setSelectedPosition(mSelectedPosition);
}
}
|