FileDocCategorySizeDatePackage
BrowseSupportFragment.javaAPI DocAndroid 5.1 API43370Thu Mar 12 22:22:56 GMT 2015android.support.v17.leanback.app

BrowseSupportFragment

public class BrowseSupportFragment extends BaseSupportFragment
A fragment for creating Leanback browse screens. It is composed of a RowsSupportFragment and a HeadersSupportFragment.

A BrowseSupportFragment renders the elements of its {@link ObjectAdapter} as a set of rows in a vertical list. The elements in this adapter must be subclasses of {@link Row}.

The HeadersSupportFragment can be set to be either shown or hidden by default, or may be disabled entirely. See {@link #setHeadersState} for details.

By default the BrowseSupportFragment includes support for returning to the headers when the user presses Back. For Activities that customize {@link android.support.v4.app.FragmentActivity#onBackPressed()}, you must disable this default Back key support by calling {@link #setHeadersTransitionOnBackEnabled(boolean)} with false and use {@link BrowseSupportFragment.BrowseTransitionListener} and {@link #startHeadersTransition(boolean)}.

Fields Summary
static final String
HEADER_STACK_INDEX
static final String
HEADER_SHOW
static final String
TITLE_SHOW
private static final String
TAG
private static final String
LB_HEADERS_BACKSTACK
private static boolean
DEBUG
public static final int
HEADERS_ENABLED
The headers fragment is enabled and shown by default.
public static final int
HEADERS_HIDDEN
The headers fragment is enabled and hidden by default.
public static final int
HEADERS_DISABLED
The headers fragment is disabled and will never be shown.
private static final float
SLIDE_DISTANCE_FACTOR
private RowsSupportFragment
mRowsSupportFragment
private HeadersSupportFragment
mHeadersSupportFragment
private android.support.v17.leanback.widget.ObjectAdapter
mAdapter
private String
mTitle
private android.graphics.drawable.Drawable
mBadgeDrawable
private int
mHeadersState
private int
mBrandColor
private boolean
mBrandColorSet
private android.support.v17.leanback.widget.BrowseFrameLayout
mBrowseFrame
private android.support.v17.leanback.widget.TitleView
mTitleView
private boolean
mShowingTitle
private boolean
mHeadersBackStackEnabled
private String
mWithHeadersBackStackName
private boolean
mShowingHeaders
private boolean
mCanShowHeaders
private int
mContainerListMarginStart
private int
mContainerListAlignTop
private boolean
mRowScaleEnabled
private SearchOrbView.Colors
mSearchAffordanceColors
private boolean
mSearchAffordanceColorSet
private android.support.v17.leanback.widget.OnItemSelectedListener
mExternalOnItemSelectedListener
private android.view.View.OnClickListener
mExternalOnSearchClickedListener
private android.support.v17.leanback.widget.OnItemClickedListener
mOnItemClickedListener
private android.support.v17.leanback.widget.OnItemViewSelectedListener
mExternalOnItemViewSelectedListener
private android.support.v17.leanback.widget.OnItemViewClickedListener
mOnItemViewClickedListener
private int
mSelectedPosition
private android.support.v17.leanback.widget.PresenterSelector
mHeaderPresenterSelector
private Object
mSceneWithTitle
private Object
mSceneWithoutTitle
private Object
mSceneWithHeaders
private Object
mSceneWithoutHeaders
private Object
mSceneAfterEntranceTransition
private Object
mTitleUpTransition
private Object
mTitleDownTransition
private Object
mHeadersTransition
private BackStackListener
mBackStackChangedListener
private BrowseTransitionListener
mBrowseTransitionListener
private static final String
ARG_TITLE
private static final String
ARG_BADGE_URI
private static final String
ARG_HEADERS_STATE
private final BrowseFrameLayout.OnFocusSearchListener
mOnFocusSearchListener
private final BrowseFrameLayout.OnChildFocusListener
mOnChildFocusListener
private HeadersSupportFragment.OnHeaderClickedListener
mHeaderClickedListener
private android.support.v17.leanback.widget.OnItemViewSelectedListener
mRowViewSelectedListener
private android.support.v17.leanback.widget.OnItemSelectedListener
mRowSelectedListener
private android.support.v17.leanback.widget.OnItemSelectedListener
mHeaderSelectedListener
private final SetSelectionRunnable
mSetSelectionRunnable
Constructors Summary
Methods Summary
public static android.os.BundlecreateArgs(android.os.Bundle args, java.lang.String title, int headersState)
Create arguments for a browse fragment.

param
args The Bundle to place arguments into, or null if the method should return a new Bundle.
param
title The title of the BrowseSupportFragment.
param
headersState The initial state of the headers of the BrowseSupportFragment. Must be one of {@link #HEADERS_ENABLED}, {@link #HEADERS_HIDDEN}, or {@link #HEADERS_DISABLED}.
return
A Bundle with the given arguments for creating a BrowseSupportFragment.


                                                                                              
             
        if (args == null) {
            args = new Bundle();
        }
        args.putString(ARG_TITLE, title);
        args.putInt(ARG_HEADERS_STATE, headersState);
        return args;
    
protected java.lang.ObjectcreateEntranceTransition()

        return sTransitionHelper.loadTransition(getActivity(),
                R.transition.lb_browse_entrance_transition);
    
private voidcreateHeadersTransition()

        mHeadersTransition = sTransitionHelper.loadTransition(getActivity(),
                mShowingHeaders ?
                R.transition.lb_browse_headers_in : R.transition.lb_browse_headers_out);

        sTransitionHelper.setTransitionListener(mHeadersTransition, new TransitionListener() {
            @Override
            public void onTransitionStart(Object transition) {
            }
            @Override
            public void onTransitionEnd(Object transition) {
                mHeadersTransition = null;
                mRowsSupportFragment.onTransitionEnd();
                mHeadersSupportFragment.onTransitionEnd();
                if (mShowingHeaders) {
                    VerticalGridView headerGridView = mHeadersSupportFragment.getVerticalGridView();
                    if (headerGridView != null && !headerGridView.hasFocus()) {
                        headerGridView.requestFocus();
                    }
                } else {
                    VerticalGridView rowsGridView = mRowsSupportFragment.getVerticalGridView();
                    if (rowsGridView != null && !rowsGridView.hasFocus()) {
                        rowsGridView.requestFocus();
                    }
                }
                if (mBrowseTransitionListener != null) {
                    mBrowseTransitionListener.onHeadersTransitionStop(mShowingHeaders);
                }
            }
        });
    
public voidenableRowScaling(boolean enable)
Enables scaling of rows when headers are present. By default enabled to increase density.

param
enable true to enable row scaling

        mRowScaleEnabled = enable;
        if (mRowsSupportFragment != null) {
            mRowsSupportFragment.enableRowScaling(mRowScaleEnabled);
        }
    
public android.support.v17.leanback.widget.ObjectAdaptergetAdapter()
Returns the adapter containing the rows for the fragment.

        return mAdapter;
    
public android.graphics.drawable.DrawablegetBadgeDrawable()
Returns the badge drawable used in the fragment title.

        return mBadgeDrawable;
    
public intgetBrandColor()
Returns the brand color for the browse fragment. The default is transparent.

        return mBrandColor;
    
public intgetHeadersState()
Returns the state of the headers column in the browse fragment.

        return mHeadersState;
    
public android.support.v17.leanback.widget.OnItemClickedListenergetOnItemClickedListener()
Returns the item clicked listener.

deprecated
Use {@link #getOnItemViewClickedListener()}

        return mOnItemClickedListener;
    
public android.support.v17.leanback.widget.OnItemViewClickedListenergetOnItemViewClickedListener()
Returns the item Clicked listener.

        return mOnItemViewClickedListener;
    
public android.support.v17.leanback.widget.OnItemViewSelectedListenergetOnItemViewSelectedListener()
Returns an item selection listener.

        return mExternalOnItemViewSelectedListener;
    
public intgetSearchAffordanceColor()
Returns the color used to draw the search affordance.

        return getSearchAffordanceColors().color;
    
public SearchOrbView.ColorsgetSearchAffordanceColors()
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.StringgetTitle()
Returns the title for the browse fragment.

        return mTitle;
    
public final booleanisHeadersTransitionOnBackEnabled()
Returns true if headers transition on back key support is enabled.

        return mHeadersBackStackEnabled;
    
public booleanisInHeadersTransition()
Returns true if the headers transition is currently running.

        return mHeadersTransition != null;
    
public booleanisShowingHeaders()
Returns true if headers are shown.

        return mShowingHeaders;
    
private booleanisVerticalScrolling()

        // don't run transition
        return mHeadersSupportFragment.getVerticalGridView().getScrollState()
                != HorizontalGridView.SCROLL_STATE_IDLE
                || mRowsSupportFragment.getVerticalGridView().getScrollState()
                != HorizontalGridView.SCROLL_STATE_IDLE;
    
public voidonCreate(android.os.Bundle savedInstanceState)

        super.onCreate(savedInstanceState);
        TypedArray ta = getActivity().obtainStyledAttributes(R.styleable.LeanbackTheme);
        mContainerListMarginStart = (int) ta.getDimension(
                R.styleable.LeanbackTheme_browseRowsMarginStart, 0);
        mContainerListAlignTop = (int) ta.getDimension(
                R.styleable.LeanbackTheme_browseRowsMarginTop, 0);
        ta.recycle();

        readArguments(getArguments());

        if (mCanShowHeaders) {
            if (mHeadersBackStackEnabled) {
                mWithHeadersBackStackName = LB_HEADERS_BACKSTACK + this;
                mBackStackChangedListener = new BackStackListener();
                getFragmentManager().addOnBackStackChangedListener(mBackStackChangedListener);
                mBackStackChangedListener.load(savedInstanceState);
            } else {
                if (savedInstanceState != null) {
                    mShowingHeaders = savedInstanceState.getBoolean(HEADER_SHOW);
                }
            }
        }

    
public android.view.ViewonCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)

        if (getChildFragmentManager().findFragmentById(R.id.browse_container_dock) == null) {
            mRowsSupportFragment = new RowsSupportFragment();
            mHeadersSupportFragment = new HeadersSupportFragment();
            getChildFragmentManager().beginTransaction()
                    .replace(R.id.browse_headers_dock, mHeadersSupportFragment)
                    .replace(R.id.browse_container_dock, mRowsSupportFragment).commit();
        } else {
            mHeadersSupportFragment = (HeadersSupportFragment) getChildFragmentManager()
                    .findFragmentById(R.id.browse_headers_dock);
            mRowsSupportFragment = (RowsSupportFragment) getChildFragmentManager()
                    .findFragmentById(R.id.browse_container_dock);
        }

        mHeadersSupportFragment.setHeadersGone(!mCanShowHeaders);

        mRowsSupportFragment.setAdapter(mAdapter);
        if (mHeaderPresenterSelector != null) {
            mHeadersSupportFragment.setPresenterSelector(mHeaderPresenterSelector);
        }
        mHeadersSupportFragment.setAdapter(mAdapter);

        mRowsSupportFragment.enableRowScaling(mRowScaleEnabled);
        mRowsSupportFragment.setOnItemSelectedListener(mRowSelectedListener);
        mRowsSupportFragment.setOnItemViewSelectedListener(mRowViewSelectedListener);
        mHeadersSupportFragment.setOnItemSelectedListener(mHeaderSelectedListener);
        mHeadersSupportFragment.setOnHeaderClickedListener(mHeaderClickedListener);
        mRowsSupportFragment.setOnItemClickedListener(mOnItemClickedListener);
        mRowsSupportFragment.setOnItemViewClickedListener(mOnItemViewClickedListener);

        View root = inflater.inflate(R.layout.lb_browse_fragment, container, false);

        mBrowseFrame = (BrowseFrameLayout) root.findViewById(R.id.browse_frame);
        mBrowseFrame.setOnFocusSearchListener(mOnFocusSearchListener);
        mBrowseFrame.setOnChildFocusListener(mOnChildFocusListener);

        mTitleView = (TitleView) root.findViewById(R.id.browse_title_group);
        mTitleView.setTitle(mTitle);
        mTitleView.setBadgeDrawable(mBadgeDrawable);
        if (mSearchAffordanceColorSet) {
            mTitleView.setSearchAffordanceColors(mSearchAffordanceColors);
        }
        if (mExternalOnSearchClickedListener != null) {
            mTitleView.setOnSearchClickedListener(mExternalOnSearchClickedListener);
        }

        if (mBrandColorSet) {
            mHeadersSupportFragment.setBackgroundColor(mBrandColor);
        }

        mSceneWithTitle = sTransitionHelper.createScene(mBrowseFrame, new Runnable() {
            @Override
            public void run() {
                mTitleView.setVisibility(View.VISIBLE);
            }
        });
        mSceneWithoutTitle = sTransitionHelper.createScene(mBrowseFrame, new Runnable() {
            @Override
            public void run() {
                mTitleView.setVisibility(View.INVISIBLE);
            }
        });
        mSceneWithHeaders = sTransitionHelper.createScene(mBrowseFrame, new Runnable() {
            @Override
            public void run() {
                showHeaders(true);
            }
        });
        mSceneWithoutHeaders =  sTransitionHelper.createScene(mBrowseFrame, new Runnable() {
            @Override
            public void run() {
                showHeaders(false);
            }
        });
        mSceneAfterEntranceTransition = sTransitionHelper.createScene(mBrowseFrame, new Runnable() {
            @Override
            public void run() {
                setEntranceTransitionEndState();
            }
        });
        Context context = getActivity();
        mTitleUpTransition = LeanbackTransitionHelper.loadTitleOutTransition(context,
                sTransitionHelper);
        mTitleDownTransition = LeanbackTransitionHelper.loadTitleInTransition(context,
                sTransitionHelper);

        if (savedInstanceState != null) {
            mShowingTitle = savedInstanceState.getBoolean(TITLE_SHOW);
        }
        mTitleView.setVisibility(mShowingTitle ? View.VISIBLE: View.INVISIBLE);

        return root;
    
public voidonDestroy()

        if (mBackStackChangedListener != null) {
            getFragmentManager().removeOnBackStackChangedListener(mBackStackChangedListener);
        }
        super.onDestroy();
    
protected voidonEntranceTransitionEnd()

        mRowsSupportFragment.onTransitionEnd();
        mHeadersSupportFragment.onTransitionEnd();
    
protected voidonEntranceTransitionStart()

        mHeadersSupportFragment.onTransitionStart();
        mRowsSupportFragment.onTransitionStart();
    
public voidonPause()

        mTitleView.enableAnimation(false);
        super.onPause();
    
public voidonResume()

        super.onResume();
        mTitleView.enableAnimation(true);
    
private voidonRowSelected(int position)


        
        if (position != mSelectedPosition) {
            mSetSelectionRunnable.mPosition = position;
            mBrowseFrame.getHandler().post(mSetSelectionRunnable);

            if (getAdapter() == null || getAdapter().size() == 0 || position == 0) {
                if (!mShowingTitle) {
                    sTransitionHelper.runTransition(mSceneWithTitle, mTitleDownTransition);
                    mShowingTitle = true;
                }
            } else if (mShowingTitle) {
                sTransitionHelper.runTransition(mSceneWithoutTitle, mTitleUpTransition);
                mShowingTitle = false;
            }
        }
    
public voidonSaveInstanceState(android.os.Bundle outState)


    
        
        if (mBackStackChangedListener != null) {
            mBackStackChangedListener.save(outState);
        } else {
            outState.putBoolean(HEADER_SHOW, mShowingHeaders);
        }
        outState.putBoolean(TITLE_SHOW, mShowingTitle);
    
public voidonStart()

        super.onStart();
        mHeadersSupportFragment.setWindowAlignmentFromTop(mContainerListAlignTop);
        mHeadersSupportFragment.setItemAlignment();
        mRowsSupportFragment.setWindowAlignmentFromTop(mContainerListAlignTop);
        mRowsSupportFragment.setItemAlignment();

        mRowsSupportFragment.setScalePivots(0, mContainerListAlignTop);

        if (mCanShowHeaders && mShowingHeaders && mHeadersSupportFragment.getView() != null) {
            mHeadersSupportFragment.getView().requestFocus();
        } else if ((!mCanShowHeaders || !mShowingHeaders)
                && mRowsSupportFragment.getView() != null) {
            mRowsSupportFragment.getView().requestFocus();
        }
        if (mCanShowHeaders) {
            showHeaders(mShowingHeaders);
        }
        if (isEntranceTransitionEnabled()) {
            setEntranceTransitionStartState();
        }
    
private voidreadArguments(android.os.Bundle args)

        if (args == null) {
            return;
        }
        if (args.containsKey(ARG_TITLE)) {
            setTitle(args.getString(ARG_TITLE));
        }
        if (args.containsKey(ARG_HEADERS_STATE)) {
            setHeadersState(args.getInt(ARG_HEADERS_STATE));
        }
    
protected voidrunEntranceTransition(java.lang.Object entranceTransition)

        sTransitionHelper.runTransition(mSceneAfterEntranceTransition,
                entranceTransition);
    
public voidsetAdapter(android.support.v17.leanback.widget.ObjectAdapter adapter)
Sets the adapter containing the rows for the fragment.

The items referenced by the adapter must be be derived from {@link Row}. These rows will be used by the rows fragment and the headers fragment (if not disabled) to render the browse rows.

param
adapter An ObjectAdapter for the browse rows. All items must derive from {@link Row}.

        mAdapter = adapter;
        if (mRowsSupportFragment != null) {
            mRowsSupportFragment.setAdapter(adapter);
            mHeadersSupportFragment.setAdapter(adapter);
        }
    
public voidsetBadgeDrawable(android.graphics.drawable.Drawable drawable)
Sets the drawable displayed in the browse fragment title.

param
drawable The Drawable to display in the browse fragment title.

        if (mBadgeDrawable != drawable) {
            mBadgeDrawable = drawable;
            if (mTitleView != null) {
                mTitleView.setBadgeDrawable(drawable);
            }
        }
    
public voidsetBrandColor(int color)
Sets the brand color for the browse fragment. The brand color is used as the primary color for UI elements in the browse fragment. For example, the background color of the headers fragment uses the brand color.

param
color The color to use as the brand color of the fragment.

        mBrandColor = color;
        mBrandColorSet = true;

        if (mHeadersSupportFragment != null) {
            mHeadersSupportFragment.setBackgroundColor(mBrandColor);
        }
    
public voidsetBrowseTransitionListener(android.support.v17.leanback.app.BrowseSupportFragment$BrowseTransitionListener listener)
Set a listener for browse fragment transitions.

param
listener The listener to call when a browse headers transition begins or ends.

        mBrowseTransitionListener = listener;
    
voidsetEntranceTransitionEndState()

        setHeadersOnScreen(mShowingHeaders);
        setSearchOrbViewOnScreen(true);
        mRowsSupportFragment.setEntranceTransitionState(true);
    
voidsetEntranceTransitionStartState()

        setHeadersOnScreen(false);
        setSearchOrbViewOnScreen(false);
        mRowsSupportFragment.setEntranceTransitionState(false);
    
public voidsetHeaderPresenterSelector(android.support.v17.leanback.widget.PresenterSelector headerPresenterSelector)
Sets the {@link PresenterSelector} used to render the row headers.

param
headerPresenterSelector The PresenterSelector that will determine the Presenter for each row header.

        mHeaderPresenterSelector = headerPresenterSelector;
        if (mHeadersSupportFragment != null) {
            mHeadersSupportFragment.setPresenterSelector(mHeaderPresenterSelector);
        }
    
private voidsetHeadersOnScreen(boolean onScreen)

        MarginLayoutParams lp;
        View containerList;
        containerList = mHeadersSupportFragment.getView();
        lp = (MarginLayoutParams) containerList.getLayoutParams();
        lp.setMarginStart(onScreen ? 0 : -mContainerListMarginStart);
        containerList.setLayoutParams(lp);
    
public voidsetHeadersState(int headersState)
Sets the state for the headers column in the browse fragment. Must be one of {@link #HEADERS_ENABLED}, {@link #HEADERS_HIDDEN}, or {@link #HEADERS_DISABLED}.

param
headersState The state of the headers for the browse fragment.

        if (headersState < HEADERS_ENABLED || headersState > HEADERS_DISABLED) {
            throw new IllegalArgumentException("Invalid headers state: " + headersState);
        }
        if (DEBUG) Log.v(TAG, "setHeadersState " + headersState);

        if (headersState != mHeadersState) {
            mHeadersState = headersState;
            switch (headersState) {
                case HEADERS_ENABLED:
                    mCanShowHeaders = true;
                    mShowingHeaders = true;
                    break;
                case HEADERS_HIDDEN:
                    mCanShowHeaders = true;
                    mShowingHeaders = false;
                    break;
                case HEADERS_DISABLED:
                    mCanShowHeaders = false;
                    mShowingHeaders = false;
                    break;
                default:
                    Log.w(TAG, "Unknown headers state: " + headersState);
                    break;
            }
            if (mHeadersSupportFragment != null) {
                mHeadersSupportFragment.setHeadersGone(!mCanShowHeaders);
            }
        }
    
public final voidsetHeadersTransitionOnBackEnabled(boolean headersBackStackEnabled)
Enable/disable headers transition on back key support. This is enabled by default. The BrowseSupportFragment will add a back stack entry when headers are showing. Running a headers transition when the back key is pressed only works when the headers state is {@link #HEADERS_ENABLED} or {@link #HEADERS_HIDDEN}.

NOTE: If an Activity has its own onBackPressed() handling, you must disable this feature. You may use {@link #startHeadersTransition(boolean)} and {@link BrowseTransitionListener} in your own back stack handling.

        mHeadersBackStackEnabled = headersBackStackEnabled;
    
public voidsetOnItemClickedListener(android.support.v17.leanback.widget.OnItemClickedListener listener)
Sets an item clicked listener on the fragment.

OnItemClickedListener will override {@link View.OnClickListener} that an item presenter may set during {@link Presenter#onCreateViewHolder(ViewGroup)}. So in general, you should choose to use an {@link OnItemClickedListener} or a {@link View.OnClickListener} on your item views, but not both.

param
listener The listener to call when an item is clicked.
deprecated
Use {@link #setOnItemViewClickedListener(OnItemViewClickedListener)}

        mOnItemClickedListener = listener;
        if (mRowsSupportFragment != null) {
            mRowsSupportFragment.setOnItemClickedListener(listener);
        }
    
public voidsetOnItemSelectedListener(android.support.v17.leanback.widget.OnItemSelectedListener listener)
Sets an item selection listener. This listener will be called when an item or row is selected by a user.

param
listener The listener to call when an item or row is selected.
deprecated
Use {@link #setOnItemViewSelectedListener(OnItemViewSelectedListener)}

        mExternalOnItemSelectedListener = listener;
    
public voidsetOnItemViewClickedListener(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 (mRowsSupportFragment != null) {
            mRowsSupportFragment.setOnItemViewClickedListener(listener);
        }
    
public voidsetOnItemViewSelectedListener(android.support.v17.leanback.widget.OnItemViewSelectedListener listener)
Sets an item selection listener.

        mExternalOnItemViewSelectedListener = listener;
    
public voidsetOnSearchClickedListener(android.view.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 fragment title. When set to non-null, the title will contain an element that a user may click to begin a search.

The listener's {@link View.OnClickListener#onClick onClick} method will be invoked when the user clicks on the search element.

param
listener The listener to call when the search element is clicked.

        mExternalOnSearchClickedListener = listener;
        if (mTitleView != null) {
            mTitleView.setOnSearchClickedListener(listener);
        }
    
private voidsetRowsAlignedLeft(boolean alignLeft)

        MarginLayoutParams lp;
        View containerList;
        containerList = mRowsSupportFragment.getView();
        lp = (MarginLayoutParams) containerList.getLayoutParams();
        lp.setMarginStart(alignLeft ? 0 : mContainerListMarginStart);
        containerList.setLayoutParams(lp);
    
public voidsetSearchAffordanceColor(int color)
Sets the color used to draw the search affordance. A default brighter color will be set by the framework.

param
color The color to use for the search affordance.

        setSearchAffordanceColors(new SearchOrbView.Colors(color));
    
public voidsetSearchAffordanceColors(SearchOrbView.Colors colors)
Sets the {@link SearchOrbView.Colors} used to draw the search affordance.

        mSearchAffordanceColors = colors;
        mSearchAffordanceColorSet = true;
        if (mTitleView != null) {
            mTitleView.setSearchAffordanceColors(mSearchAffordanceColors);
        }
    
voidsetSearchOrbViewOnScreen(boolean onScreen)

        View searchOrbView = mTitleView.getSearchAffordanceView();
        MarginLayoutParams lp = (MarginLayoutParams) searchOrbView.getLayoutParams();
        lp.setMarginStart(onScreen ? 0 : -mContainerListMarginStart);
        searchOrbView.setLayoutParams(lp);
    
public voidsetSelectedPosition(int position)
Sets the selected row position with smooth animation.

        setSelectedPosition(position, true);
    
public voidsetSelectedPosition(int position, boolean smooth)
Sets the selected row position.

        mSetSelectionRunnable.mPosition = position;
        mSetSelectionRunnable.mSmooth = smooth;
        mBrowseFrame.getHandler().post(mSetSelectionRunnable);
    
private voidsetSelection(int position, boolean smooth)


          
        if (position != NO_POSITION) {
            mRowsSupportFragment.setSelectedPosition(position, smooth);
            mHeadersSupportFragment.setSelectedPosition(position, smooth);
        }
        mSelectedPosition = position;
    
public voidsetTitle(java.lang.String title)
Sets a title for the browse fragment.

param
title The title of the browse fragment.

        mTitle = title;
        if (mTitleView != null) {
            mTitleView.setTitle(title);
        }
    
private voidshowHeaders(boolean show)

        if (DEBUG) Log.v(TAG, "showHeaders " + show);
        mHeadersSupportFragment.setHeadersEnabled(show);
        setHeadersOnScreen(show);
        setRowsAlignedLeft(!show);
        mRowsSupportFragment.setExpand(!show);
    
public voidstartHeadersTransition(boolean withHeaders)
Start a headers transition.

This method will begin a transition to either show or hide the headers, depending on the value of withHeaders. If headers are disabled for this browse fragment, this method will throw an exception.

param
withHeaders True if the headers should transition to being shown, false if the transition should result in headers being hidden.

        if (!mCanShowHeaders) {
            throw new IllegalStateException("Cannot start headers transition");
        }
        if (isInHeadersTransition() || mShowingHeaders == withHeaders) {
            return;
        }
        startHeadersTransitionInternal(withHeaders);
    
private voidstartHeadersTransitionInternal(boolean withHeaders)

        if (getFragmentManager().isDestroyed()) {
            return;
        }
        mShowingHeaders = withHeaders;
        mRowsSupportFragment.onExpandTransitionStart(!withHeaders, new Runnable() {
            @Override
            public void run() {
                mHeadersSupportFragment.onTransitionStart();
                createHeadersTransition();
                if (mBrowseTransitionListener != null) {
                    mBrowseTransitionListener.onHeadersTransitionStart(withHeaders);
                }
                sTransitionHelper.runTransition(withHeaders ? mSceneWithHeaders : mSceneWithoutHeaders,
                        mHeadersTransition);
                if (mHeadersBackStackEnabled) {
                    if (!withHeaders) {
                        getFragmentManager().beginTransaction()
                                .addToBackStack(mWithHeadersBackStackName).commit();
                    } else {
                        int index = mBackStackChangedListener.mIndexOfHeadersBackStack;
                        if (index >= 0) {
                            BackStackEntry entry = getFragmentManager().getBackStackEntryAt(index);
                            getFragmentManager().popBackStackImmediate(entry.getId(),
                                    FragmentManager.POP_BACK_STACK_INCLUSIVE);
                        }
                    }
                }
            }
        });