Most visited

Recently visited

DetailsSupportFragment

public class DetailsSupportFragment
extends BrandedSupportFragment

java.lang.Object
   ↳ android.support.v4.app.Fragment
     ↳ android.support.v17.leanback.app.BrandedSupportFragment
       ↳ android.support.v17.leanback.app.DetailsSupportFragment
Known Direct Subclasses


用于创建Leanback详细信息屏幕的片段。

ObjectAdapter将其 ObjectAdapter的元素呈现为垂直列表中的一组行。适配器 PresenterSelector必须维护 RowPresenter子类。

When FullWidthDetailsOverviewRowPresenter is found in adapter, DetailsSupportFragment will setup default behavior of the DetailsOverviewRow:
  • The alignment of FullWidthDetailsOverviewRowPresenter is setup in setupDetailsOverviewRowPresenter(FullWidthDetailsOverviewRowPresenter).
  • The view status switching of FullWidthDetailsOverviewRowPresenter is done in onSetDetailsOverviewRowStatus(FullWidthDetailsOverviewRowPresenter, FullWidthDetailsOverviewRowPresenter.ViewHolder, int, int, int).
  • 推荐的活动主题与DetailsSupportFragment一起使用

  • Theme_Leanback_Details with activity shared element transition for FullWidthDetailsOverviewRowPresenter.
  • Theme_Leanback_Details_NoSharedElementTransition if shared element transition is not needed, for example if first row is not rendered by FullWidthDetailsOverviewRowPresenter.
  • Summary

    Public constructors

    DetailsSupportFragment()

    Public methods

    ObjectAdapter getAdapter()

    返回行列表。

    BaseOnItemViewClickedListener getOnItemViewClickedListener()

    返回项目点击侦听器。

    final ProgressBarManager getProgressBarManager()

    返回 ProgressBarManager

    RowsSupportFragment getRowsSupportFragment()

    获取为DetailsSupportFragment显示多行的嵌入式RowsSupportFragment。

    void onCreate(Bundle savedInstanceState)

    被调用来做一个片段的初始创建。

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

    调用以使片段实例化其用户界面视图。

    View onInflateTitleView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)

    installTitleView(LayoutInflater, ViewGroup, Bundle)调用来夸大标题视图。

    void onStart()

    当片段对用户可见时调用。

    void onViewCreated(View view, Bundle savedInstanceState)

    onCreateView(LayoutInflater, ViewGroup, Bundle)已经返回之后立即调用,但在任何已保存的状态恢复到视图之前。

    void prepareEntranceTransition()

    启用入口转换。

    void setAdapter(ObjectAdapter adapter)

    设置片段的行列表。

    void setOnItemViewClickedListener(BaseOnItemViewClickedListener listener)

    设置项目点击侦听器。

    void setOnItemViewSelectedListener(BaseOnItemViewSelectedListener listener)

    设置项目选择侦听器。

    void setSelectedPosition(int position)

    用平滑动画设置选定的行位置。

    void setSelectedPosition(int position, boolean smooth)

    设置选定的行位置。

    void startEntranceTransition()

    当fragment完成加载数据时,它应该调用startEntranceTransition()来执行入口转换。

    Protected methods

    Object createEntranceTransition()

    创建入口过渡。

    View inflateTitle(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState)

    此方法已弃用。 改为取代onInflateTitleView(LayoutInflater, ViewGroup, Bundle)

    void onEntranceTransitionEnd()

    入场过渡结束时的回调。

    void onEntranceTransitionPrepare()

    准备入场过渡时回调。

    void onEntranceTransitionStart()

    入口转换开始时的回调。

    void onSetDetailsOverviewRowStatus(FullWidthDetailsOverviewRowPresenter presenter, FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder, int adapterPosition, int selectedPosition, int selectedSubPosition)

    当当前所选行位置或所选子位置改变时,调用以更改DetailsOverviewRow查看状态。

    void onSetRowStatus(RowPresenter presenter, RowPresenter.ViewHolder viewHolder, int adapterPosition, int selectedPosition, int selectedSubPosition)

    当当前所选行位置或所选子位置改变时,调用每个可见行以更改视图状态。

    void runEntranceTransition(Object entranceTransition)

    运行入口转换。

    void setupDetailsOverviewRowPresenter(FullWidthDetailsOverviewRowPresenter presenter)

    打电话设置 FullWidthDetailsOverviewRowPresenter

    void setupPresenter(Presenter rowPresenter)

    调用以设置在 setAdapter(ObjectAdapter)传递的适配器的每个Presenter。

    Inherited methods

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

    Public constructors

    DetailsSupportFragment

    DetailsSupportFragment ()

    Public methods

    getAdapter

    ObjectAdapter getAdapter ()

    返回行列表。

    Returns
    ObjectAdapter

    getOnItemViewClickedListener

    BaseOnItemViewClickedListener getOnItemViewClickedListener ()

    返回项目点击侦听器。

    Returns
    BaseOnItemViewClickedListener

    getProgressBarManager

    ProgressBarManager getProgressBarManager ()

    返回 ProgressBarManager

    Returns
    ProgressBarManager

    getRowsSupportFragment

    RowsSupportFragment getRowsSupportFragment ()

    获取为DetailsSupportFragment显示多行的嵌入式RowsSupportFragment。 如果DetailsSupportFragment的视图未创建,则该方法返回null。

    Returns
    RowsSupportFragment Embedded RowsSupportFragment showing multiple rows for DetailsSupportFragment.

    onCreate

    void onCreate (Bundle savedInstanceState)

    被调用来做一个片段的初始创建。 这是在onAttach(Activity)之后和onCreateView(LayoutInflater, ViewGroup, Bundle)之前onCreateView(LayoutInflater, ViewGroup, Bundle)

    请注意,这可以在片段的活动仍处于创建过程中时调用。 因此,您不能依赖于此时正在初始化活动的内容视图层次结构。 如果您想在创建活动本身后进行工作,请参阅onActivityCreated(Bundle)

    任何已恢复的子片段将在基本 Fragment.onCreate方法返回之前创建。

    Parameters
    savedInstanceState Bundle: If the fragment is being re-created from a previous saved state, this is the state.

    onCreateView

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

    调用以使片段实例化其用户界面视图。 这是可选的,非图形片段可以返回null(这是默认实现)。 这将在onCreate(Bundle)onActivityCreated(Bundle)之间onActivityCreated(Bundle)

    如果你从这里返回一个视图,那么当视图被释放时,你将在以后被调用 onDestroyView()

    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.

    onInflateTitleView

    View onInflateTitleView (LayoutInflater inflater, 
                    ViewGroup parent, 
                    Bundle savedInstanceState)

    installTitleView(LayoutInflater, ViewGroup, Bundle)调用来夸大标题视图。 默认实现使用布局文件lb_browse_title。 子类可以覆盖并使用其自己的布局,该布局必须具有实现TitleViewAdapter.Provider id为browse_title_group的后代。 如果不需要标题,子类可能会返回null。

    Parameters
    inflater LayoutInflater: The LayoutInflater object that can be used to inflate any views in the fragment,
    parent ViewGroup: Parent of title view.
    savedInstanceState Bundle: If non-null, this fragment is being re-constructed from a previous saved state as given here.
    Returns
    View Title view which must have a descendant with id browse_title_group that implements TitleViewAdapter.Provider, or null for no title view.

    onStart

    void onStart ()

    当片段对用户可见时调用。 这通常与包含Activity的生命周期的Activity.onStart相关联。

    onViewCreated

    void onViewCreated (View view, 
                    Bundle savedInstanceState)

    onCreateView(LayoutInflater, ViewGroup, Bundle)已经返回之后立即调用,但在任何保存的状态恢复到视图之前。 这让子类有机会在知道其视图层次已完全创建后自行初始化。 此时片段的视图层次不会附加到其父项。

    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 ()

    启用入口转换。

    入口过渡是标准的滑入式过渡,在浏览屏幕和细节屏幕中显示数据行。

    该方法在LOLLIPOP(API21)之前被忽略。

    必须在onCreate()之前或之前调用此方法。 当savedInstance为空时,通常应启用入口转换,以便从instanceState恢复的片段不会运行额外的入口转换。 当启用入口转换时,片段将首先隐藏标题和内容。 当行数据准备好时,应用程序必须调用startEntranceTransition()才能启动转换,否则行将永远不可见。

    它类似于android:windowsEnterTransition,可以认为是由应用程序控制的后期执行的android:windowsEnterTransition。 该应用需要它的原因有两个:

  • 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.
  • 过渡对象由createEntranceTransition()返回。 通常,应用程序不需要覆盖浏览和详细信息提供的默认转换。

    setAdapter

    void setAdapter (ObjectAdapter adapter)

    设置片段的行列表。

    Parameters
    adapter ObjectAdapter

    setOnItemViewClickedListener

    void setOnItemViewClickedListener (BaseOnItemViewClickedListener listener)

    设置项目点击侦听器。

    Parameters
    listener BaseOnItemViewClickedListener

    setOnItemViewSelectedListener

    void setOnItemViewSelectedListener (BaseOnItemViewSelectedListener listener)

    设置项目选择侦听器。

    Parameters
    listener BaseOnItemViewSelectedListener

    setSelectedPosition

    void setSelectedPosition (int position)

    用平滑动画设置选定的行位置。

    Parameters
    position int

    setSelectedPosition

    void setSelectedPosition (int position, 
                    boolean smooth)

    设置选定的行位置。

    Parameters
    position int
    smooth boolean

    startEntranceTransition

    void startEntranceTransition ()

    当fragment完成加载数据时,它应该调用startEntranceTransition()来执行入口转换。 只有满足以下两个条件,startEntranceTransition()才会开始转换:

  • prepareEntranceTransition() was called.
  • has not executed entrance transition yet.
  • 如果在onViewCreated()之前调用startEntranceTransition(),则在创建视图时它将等待并执行。

    Protected methods

    createEntranceTransition

    Object createEntranceTransition ()

    创建入口过渡。 子类可以重写以手动加载资源或构造的转换。 通常,应用不需要覆盖浏览和详细信息提供的默认转换。

    Returns
    Object

    inflateTitle

    View inflateTitle (LayoutInflater inflater, 
                    ViewGroup parent, 
                    Bundle savedInstanceState)

    此方法已弃用。
    onInflateTitleView(LayoutInflater, ViewGroup, Bundle)代替onInflateTitleView(LayoutInflater, ViewGroup, Bundle)

    Parameters
    inflater LayoutInflater
    parent ViewGroup
    savedInstanceState Bundle
    Returns
    View

    onEntranceTransitionEnd

    void onEntranceTransitionEnd ()

    入场过渡结束时的回调。

    onEntranceTransitionPrepare

    void onEntranceTransitionPrepare ()

    准备入场过渡时回调。 这是片段应该停止用户输入和动画。

    onEntranceTransitionStart

    void onEntranceTransitionStart ()

    入口转换开始时的回调。 这是片段应停止处理布局。

    onSetDetailsOverviewRowStatus

    void onSetDetailsOverviewRowStatus (FullWidthDetailsOverviewRowPresenter presenter, 
                    FullWidthDetailsOverviewRowPresenter.ViewHolder viewHolder, 
                    int adapterPosition, 
                    int selectedPosition, 
                    int selectedSubPosition)

    当当前所选行位置或所选子位置改变时,调用以更改DetailsOverviewRow查看状态。 子类可能会覆盖。 :立足岗位三种状态之间的默认实现开关STATE_HALFSTATE_FULLSTATE_SMALL

    Parameters
    presenter FullWidthDetailsOverviewRowPresenter: The presenter used to create row ViewHolder.
    viewHolder FullWidthDetailsOverviewRowPresenter.ViewHolder: The visible (attached) row ViewHolder, note that it may or may not be selected.
    adapterPosition int: The adapter position of viewHolder inside adapter.
    selectedPosition int: The adapter position of currently selected row.
    selectedSubPosition int: The sub position within currently selected row. This is used When a row has multiple alignment positions.

    onSetRowStatus

    void onSetRowStatus (RowPresenter presenter, 
                    RowPresenter.ViewHolder viewHolder, 
                    int adapterPosition, 
                    int selectedPosition, 
                    int selectedSubPosition)

    当当前所选行位置或所选子位置改变时,调用每个可见行以更改视图状态。 子类可能会覆盖。 默认实现调用onSetDetailsOverviewRowStatus(FullWidthDetailsOverviewRowPresenter, FullWidthDetailsOverviewRowPresenter.ViewHolder, int, int, int)如果主持人是实例FullWidthDetailsOverviewRowPresenter

    Parameters
    presenter RowPresenter: The presenter used to create row ViewHolder.
    viewHolder RowPresenter.ViewHolder: The visible (attached) row ViewHolder, note that it may or may not be selected.
    adapterPosition int: The adapter position of viewHolder inside adapter.
    selectedPosition int: The adapter position of currently selected row.
    selectedSubPosition int: The sub position within currently selected row. This is used When a row has multiple alignment positions.

    runEntranceTransition

    void runEntranceTransition (Object entranceTransition)

    运行入口转换。 子类可以使用TransitionManager执行go(Scene)或beginDelayedTransition()。 应用程序不应重写浏览和细节片段的默认实现。

    Parameters
    entranceTransition Object

    setupDetailsOverviewRowPresenter

    void setupDetailsOverviewRowPresenter (FullWidthDetailsOverviewRowPresenter presenter)

    打电话设置FullWidthDetailsOverviewRowPresenter 默认实现为FullWidthDetailsOverviewRowPresenter的ViewHolder添加两个对齐位置( ItemAlignmentFacet )以在片段中对齐。

    Parameters
    presenter FullWidthDetailsOverviewRowPresenter

    setupPresenter

    void setupPresenter (Presenter rowPresenter)

    调用以设置每个适配器的Presenter通过setAdapter(ObjectAdapter) 请注意,安装程序只应更改DetailsSupportFragment中有意义的Presenter行为。 例如一行如何在细节片段中对齐。 默认实现调用setupDetailsOverviewRowPresenter(FullWidthDetailsOverviewRowPresenter)

    Parameters
    rowPresenter Presenter

    Hooray!