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

BaseRowFragment

public abstract class BaseRowFragment extends android.app.Fragment
An internal base class for a fragment containing a list of rows.

Fields Summary
private android.support.v17.leanback.widget.ObjectAdapter
mAdapter
private android.support.v17.leanback.widget.VerticalGridView
mVerticalGridView
private android.support.v17.leanback.widget.PresenterSelector
mPresenterSelector
private android.support.v17.leanback.widget.ItemBridgeAdapter
mBridgeAdapter
private int
mSelectedPosition
private final android.support.v17.leanback.widget.OnChildSelectedListener
mRowSelectedListener
Constructors Summary
Methods Summary
android.support.v17.leanback.widget.VerticalGridViewfindGridViewFromRoot(android.view.View view)

        return (VerticalGridView) view;
    
public final android.support.v17.leanback.widget.ObjectAdaptergetAdapter()
Returns the list of rows.

        return mAdapter;
    
final android.support.v17.leanback.widget.ItemBridgeAdaptergetBridgeAdapter()
Returns the bridge adapter.

        return mBridgeAdapter;
    
java.lang.ObjectgetItem(android.support.v17.leanback.widget.Row row, int position)

        if (row instanceof ListRow) {
            return ((ListRow) row).getAdapter().get(position);
        } else {
            return null;
        }
    
abstract intgetLayoutResourceId()

public final android.support.v17.leanback.widget.PresenterSelectorgetPresenterSelector()
Get the presenter selector used to create and bind views.

        return mPresenterSelector;
    
final android.support.v17.leanback.widget.VerticalGridViewgetVerticalGridView()

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

        View view = inflater.inflate(getLayoutResourceId(), container, false);
        mVerticalGridView = findGridViewFromRoot(view);
        return view;
    
public voidonDestroyView()

        super.onDestroyView();
        mVerticalGridView = null;
    
voidonRowSelected(android.view.ViewGroup parent, android.view.View view, int position, long id)


             
    
voidonTransitionEnd()

        if (mVerticalGridView != null) {
            mVerticalGridView.setAnimateChildLayout(true);
            mVerticalGridView.setPruneChild(true);
            mVerticalGridView.setFocusSearchDisabled(false);
        }
    
voidonTransitionStart()

        if (mVerticalGridView != null) {
            mVerticalGridView.setAnimateChildLayout(false);
            mVerticalGridView.setPruneChild(false);
            mVerticalGridView.setFocusSearchDisabled(true);
        }
    
public voidonViewCreated(android.view.View view, android.os.Bundle savedInstanceState)

        if (mBridgeAdapter != null) {
            mVerticalGridView.setAdapter(mBridgeAdapter);
            if (mSelectedPosition != -1) {
                mVerticalGridView.setSelectedPosition(mSelectedPosition);
            }
        }
        mVerticalGridView.setOnChildSelectedListener(mRowSelectedListener);
    
public final voidsetAdapter(android.support.v17.leanback.widget.ObjectAdapter rowsAdapter)
Sets the adapter for the fragment.

        mAdapter = rowsAdapter;
        updateAdapter();
    
voidsetItemAlignment()

        if (mVerticalGridView != null) {
            // align the top edge of item
            mVerticalGridView.setItemAlignmentOffset(0);
            mVerticalGridView.setItemAlignmentOffsetPercent(
                    VerticalGridView.ITEM_ALIGN_OFFSET_PERCENT_DISABLED);
        }
    
public final voidsetPresenterSelector(android.support.v17.leanback.widget.PresenterSelector presenterSelector)
Set the presenter selector used to create and bind views.

        mPresenterSelector = presenterSelector;
        updateAdapter();
    
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.

        mSelectedPosition = position;
        if(mVerticalGridView != null && mVerticalGridView.getAdapter() != null) {
            if (smooth) {
                mVerticalGridView.setSelectedPositionSmooth(position);
            } else {
                mVerticalGridView.setSelectedPosition(position);
            }
        }
    
voidsetWindowAlignmentFromTop(int alignedTop)

        if (mVerticalGridView != null) {
            // align to a fixed position from top
            mVerticalGridView.setWindowAlignmentOffset(alignedTop);
            mVerticalGridView.setWindowAlignmentOffsetPercent(
                    VerticalGridView.WINDOW_ALIGN_OFFSET_PERCENT_DISABLED);
            mVerticalGridView.setWindowAlignment(VerticalGridView.WINDOW_ALIGN_NO_EDGE);
        }
    
voidupdateAdapter()

        mBridgeAdapter = null;

        if (mAdapter != null) {
            // If presenter selector is null, adapter ps will be used
            mBridgeAdapter = new ItemBridgeAdapter(mAdapter, mPresenterSelector);
        }
        if (mVerticalGridView != null) {
            mVerticalGridView.setAdapter(mBridgeAdapter);
            if (mBridgeAdapter != null && mSelectedPosition != -1) {
                mVerticalGridView.setSelectedPosition(mSelectedPosition);
            }
        }