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

DetailsFragment

public class DetailsFragment extends BaseFragment
Wrapper fragment for leanback details screens.

Fields Summary
private static final String
TAG
private static boolean
DEBUG
private RowsFragment
mRowsFragment
private android.support.v17.leanback.widget.ObjectAdapter
mAdapter
private int
mContainerListAlignTop
private android.support.v17.leanback.widget.OnItemSelectedListener
mExternalOnItemSelectedListener
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 Object
mSceneAfterEntranceTransition
private final SetSelectionRunnable
mSetSelectionRunnable
Constructors Summary
Methods Summary
protected java.lang.ObjectcreateEntranceTransition()

        return sTransitionHelper.loadTransition(getActivity(),
                R.transition.lb_details_enter_transition);
    
public android.support.v17.leanback.widget.ObjectAdaptergetAdapter()
Returns the list of rows.

        return mAdapter;
    
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;
    
RowsFragmentgetRowsFragment()

        return mRowsFragment;
    
android.support.v17.leanback.widget.VerticalGridViewgetVerticalGridView()

        return mRowsFragment == null ? null : mRowsFragment.getVerticalGridView();
    
public voidonCreate(android.os.Bundle savedInstanceState)

        super.onCreate(savedInstanceState);

        mContainerListAlignTop =
            getResources().getDimensionPixelSize(R.dimen.lb_details_rows_align_top);
    
public android.view.ViewonCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)

        View view = inflater.inflate(R.layout.lb_details_fragment, container, false);
        mRowsFragment = (RowsFragment) getChildFragmentManager().findFragmentById(
                R.id.fragment_dock); 
        if (mRowsFragment == null) {
            mRowsFragment = new RowsFragment();
            getChildFragmentManager().beginTransaction()
                    .replace(R.id.fragment_dock, mRowsFragment).commit();
        }
        mRowsFragment.setAdapter(mAdapter);
        mRowsFragment.setOnItemSelectedListener(mExternalOnItemSelectedListener);
        mRowsFragment.setOnItemViewSelectedListener(mExternalOnItemViewSelectedListener);
        mRowsFragment.setOnItemClickedListener(mOnItemClickedListener);
        mRowsFragment.setOnItemViewClickedListener(mOnItemViewClickedListener);
        mSceneAfterEntranceTransition = sTransitionHelper.createScene((ViewGroup) view,
                new Runnable() {
            @Override
            public void run() {
                mRowsFragment.setEntranceTransitionState(true);
            }
        });
        return view;
    
protected voidonEntranceTransitionEnd()

        mRowsFragment.onTransitionEnd();
    
public voidonStart()

        super.onStart();
        setupChildFragmentLayout();
        mRowsFragment.getView().requestFocus();
        if (isEntranceTransitionEnabled()) {
            // make sure recycler view animation is disabled
            mRowsFragment.onTransitionStart();
            mRowsFragment.setEntranceTransitionState(false);
        }
    
protected voidrunEntranceTransition(java.lang.Object entranceTransition)

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


                 
        
        mAdapter = adapter;
        if (mRowsFragment != null) {
            mRowsFragment.setAdapter(adapter);
        }
    
public voidsetOnItemClickedListener(android.support.v17.leanback.widget.OnItemClickedListener listener)
Sets an item Clicked listener.

deprecated
Use {@link #setOnItemViewClickedListener(OnItemViewClickedListener)}

        mOnItemClickedListener = listener;
        if (mRowsFragment != null) {
            mRowsFragment.setOnItemClickedListener(listener);
        }
    
public voidsetOnItemSelectedListener(android.support.v17.leanback.widget.OnItemSelectedListener listener)
Sets an item selection listener.

deprecated
Use {@link #setOnItemViewSelectedListener(OnItemViewSelectedListener)}

        mExternalOnItemSelectedListener = listener;
    
public voidsetOnItemViewClickedListener(android.support.v17.leanback.widget.OnItemViewClickedListener listener)
Sets an item Clicked listener.

        mOnItemViewClickedListener = listener;
        if (mRowsFragment != null) {
            mRowsFragment.setOnItemViewClickedListener(listener);
        }
    
public voidsetOnItemViewSelectedListener(android.support.v17.leanback.widget.OnItemViewSelectedListener listener)
Sets an item selection listener.

        mExternalOnItemViewSelectedListener = listener;
    
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;
        if (getView() != null && getView().getHandler() != null) {
            getView().getHandler().post(mSetSelectionRunnable);
        }
    
voidsetVerticalGridViewLayout(android.support.v17.leanback.widget.VerticalGridView listview)

        // align the top edge of item to a fixed position
        listview.setItemAlignmentOffset(0);
        listview.setItemAlignmentOffsetPercent(VerticalGridView.ITEM_ALIGN_OFFSET_PERCENT_DISABLED);
        listview.setWindowAlignmentOffset(mContainerListAlignTop);
        listview.setWindowAlignmentOffsetPercent(VerticalGridView.WINDOW_ALIGN_OFFSET_PERCENT_DISABLED);
        listview.setWindowAlignment(VerticalGridView.WINDOW_ALIGN_NO_EDGE);
    
private voidsetupChildFragmentLayout()
Setup dimensions that are only meaningful when the child Fragments are inside DetailsFragment.

        setVerticalGridViewLayout(mRowsFragment.getVerticalGridView());