Most visited

Recently visited

VerticalGridFragment

public class VerticalGridFragment
extends BrandedFragment

java.lang.Object
   ↳ android.app.Fragment
     ↳ android.support.v17.leanback.app.BrandedFragment
       ↳ android.support.v17.leanback.app.VerticalGridFragment


A fragment for creating leanback vertical grids.

Renders a vertical grid of objects given a VerticalGridPresenter and an ObjectAdapter.

Summary

Inherited XML attributes

From class android.app.Fragment

Inherited constants

From interface android.content.ComponentCallbacks2

Public constructors

VerticalGridFragment()

Public methods

ObjectAdapter getAdapter()

Returns the object adapter.

VerticalGridPresenter getGridPresenter()

Returns the grid presenter.

OnItemViewClickedListener getOnItemViewClickedListener()

Returns the item clicked listener.

final ProgressBarManager getProgressBarManager()

Returns the ProgressBarManager.

View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

Called to have the fragment instantiate its user interface view.

void onDestroyView()

Called when the view previously created by onCreateView(LayoutInflater, ViewGroup, Bundle) has been detached from the fragment.

void onStart()

Called when the Fragment is visible to the user.

void onViewCreated(View view, Bundle savedInstanceState)

Called immediately after onCreateView(LayoutInflater, ViewGroup, Bundle) has returned, but before any saved state has been restored in to the view.

void prepareEntranceTransition()

Enables entrance transition.

void setAdapter(ObjectAdapter adapter)

Sets the object adapter for the fragment.

void setGridPresenter(VerticalGridPresenter gridPresenter)

Sets the grid presenter.

void setOnItemViewClickedListener(OnItemViewClickedListener listener)

Sets an item clicked listener.

void setOnItemViewSelectedListener(OnItemViewSelectedListener listener)

Sets an item selection listener.

void setSelectedPosition(int position)

Sets the selected item position.

void startEntranceTransition()

When fragment finishes loading data, it should call startEntranceTransition() to execute the entrance transition.

Protected methods

Object createEntranceTransition()

Create entrance transition.

void onEntranceTransitionEnd()

Callback when entrance transition is ended.

void onEntranceTransitionPrepare()

Callback when entrance transition is prepared.

void onEntranceTransitionStart()

Callback when entrance transition is started.

void runEntranceTransition(Object entranceTransition)

Run entrance transition.

Inherited methods

From class android.support.v17.leanback.app.BrandedFragment
From class android.app.Fragment
From class java.lang.Object
From interface android.content.ComponentCallbacks2
From interface android.view.View.OnCreateContextMenuListener
From interface android.content.ComponentCallbacks

Public constructors

VerticalGridFragment

VerticalGridFragment ()

Public methods

getAdapter

ObjectAdapter getAdapter ()

Returns the object adapter.

Returns
ObjectAdapter

getGridPresenter

VerticalGridPresenter getGridPresenter ()

Returns the grid presenter.

Returns
VerticalGridPresenter

getOnItemViewClickedListener

OnItemViewClickedListener getOnItemViewClickedListener ()

Returns the item clicked listener.

Returns
OnItemViewClickedListener

getProgressBarManager

ProgressBarManager getProgressBarManager ()

Returns the ProgressBarManager.

Returns
ProgressBarManager

onCreateView

View onCreateView (LayoutInflater inflater, 
                ViewGroup container, 
                Bundle savedInstanceState)

Called to have the fragment instantiate its user interface view. This is optional, and non-graphical fragments can return null (which is the default implementation). This will be called between onCreate(Bundle) and onActivityCreated(Bundle).

If you return a View from here, you will later be called in onDestroyView() when the view is being released.

Parameters
inflater LayoutInflater: The LayoutInflater object that can be used to inflate any views in the fragment,
container ViewGroup: If non-null, this is the parent view that the fragment's UI should be attached to. The fragment should not add the view itself, but this can be used to generate the LayoutParams of the view.
savedInstanceState Bundle: If non-null, this fragment is being re-constructed from a previous saved state as given here.
Returns
View Return the View for the fragment's UI, or null.

onDestroyView

void onDestroyView ()

Called when the view previously created by onCreateView(LayoutInflater, ViewGroup, Bundle) has been detached from the fragment. The next time the fragment needs to be displayed, a new view will be created. This is called after onStop() and before onDestroy(). It is called regardless of whether onCreateView(LayoutInflater, ViewGroup, Bundle) returned a non-null view. Internally it is called after the view's state has been saved but before it has been removed from its parent.

onStart

void onStart ()

Called when the Fragment is visible to the user. This is generally tied to Activity.onStart of the containing Activity's lifecycle.

onViewCreated

void onViewCreated (View view, 
                Bundle savedInstanceState)

Called immediately after onCreateView(LayoutInflater, ViewGroup, Bundle) has returned, but before any saved state has been restored in to the view. This gives subclasses a chance to initialize themselves once they know their view hierarchy has been completely created. The fragment's view hierarchy is not however attached to its parent at this point.

Parameters
view View: The View returned by onCreateView(LayoutInflater, ViewGroup, Bundle).
savedInstanceState Bundle: If non-null, this fragment is being re-constructed from a previous saved state as given here.

prepareEntranceTransition

void prepareEntranceTransition ()

Enables entrance transition.

Entrance transition is the standard slide-in transition that shows rows of data in browse screen and details screen.

The method is ignored before LOLLIPOP (API21).

This method must be called in or before onCreate(). Typically entrance transition should be enabled when savedInstance is null so that fragment restored from instanceState does not run an extra entrance transition. When the entrance transition is enabled, the fragment will make headers and content hidden initially. When data of rows are ready, app must call startEntranceTransition() to kick off the transition, otherwise the rows will be invisible forever.

It is similar to android:windowsEnterTransition and can be considered a late-executed android:windowsEnterTransition controlled by app. There are two reasons that app needs it:

  • Workaround the problem that activity transition is not available between launcher and app. Browse activity must programmatically start the slide-in transition.
  • Separates DetailsOverviewRow transition from other rows transition. So that the DetailsOverviewRow transition can be executed earlier without waiting for all rows to be loaded.
  • Transition object is returned by createEntranceTransition(). Typically the app does not need override the default transition that browse and details provides.

    setAdapter

    void setAdapter (ObjectAdapter adapter)

    Sets the object adapter for the fragment.

    Parameters
    adapter ObjectAdapter

    setGridPresenter

    void setGridPresenter (VerticalGridPresenter gridPresenter)

    Sets the grid presenter.

    Parameters
    gridPresenter VerticalGridPresenter

    setOnItemViewClickedListener

    void setOnItemViewClickedListener (OnItemViewClickedListener listener)

    Sets an item clicked listener.

    Parameters
    listener OnItemViewClickedListener

    setOnItemViewSelectedListener

    void setOnItemViewSelectedListener (OnItemViewSelectedListener listener)

    Sets an item selection listener.

    Parameters
    listener OnItemViewSelectedListener

    setSelectedPosition

    void setSelectedPosition (int position)

    Sets the selected item position.

    Parameters
    position int

    startEntranceTransition

    void startEntranceTransition ()

    When fragment finishes loading data, it should call startEntranceTransition() to execute the entrance transition. startEntranceTransition() will start transition only if both two conditions are satisfied:

  • prepareEntranceTransition() was called.
  • has not executed entrance transition yet.
  • If startEntranceTransition() is called before onViewCreated(), it will be pending and executed when view is created.

    Protected methods

    createEntranceTransition

    Object createEntranceTransition ()

    Create entrance transition. Subclass can override to load transition from resource or construct manually. Typically app does not need to override the default transition that browse and details provides.

    Returns
    Object

    onEntranceTransitionEnd

    void onEntranceTransitionEnd ()

    Callback when entrance transition is ended.

    onEntranceTransitionPrepare

    void onEntranceTransitionPrepare ()

    Callback when entrance transition is prepared. This is when fragment should stop user input and animations.

    onEntranceTransitionStart

    void onEntranceTransitionStart ()

    Callback when entrance transition is started. This is when fragment should stop processing layout.

    runEntranceTransition

    void runEntranceTransition (Object entranceTransition)

    Run entrance transition. Subclass may use TransitionManager to perform go(Scene) or beginDelayedTransition(). App should not override the default implementation of browse and details fragment.

    Parameters
    entranceTransition Object

    Hooray!