public class GuidedStepFragment extends Fragment implements GuidedActionAdapter.FocusListener
Clients of GuidedStepFragment must create a custom subclass to attach to their Activities. This custom subclass provides the information necessary to construct the user interface and respond to user actions. At a minimum, subclasses should override:
onCreateGuidance(android.os.Bundle)
, to provide instructions to the useronCreateActions(java.util.List<android.support.v17.leanback.widget.GuidedAction>, android.os.Bundle)
, to provide a set of GuidedAction
s the user can takeonGuidedActionClicked(android.support.v17.leanback.widget.GuidedAction)
, to respond to those actionsClients use following helper functions to add GuidedStepFragment to Activity or FragmentManager:
addAsRoot(Activity, GuidedStepFragment, int)
, to be called during Activity onCreate,
adds GuidedStepFragment as the first Fragment in activity.add(FragmentManager, GuidedStepFragment)
or add(FragmentManager,
GuidedStepFragment, int)
, to add GuidedStepFragment on top of existing Fragments or
replacing existing GuidedStepFragment when moving forward to next step.finishGuidedStepFragments()
can either finish the activity or pop all
GuidedStepFragment from stack.
setUiStyle(int)
to select fragment transition and remember the stack entry where it
need pops to.
GuidedStepFragment delegates its visual styling to classes called stylists. The GuidanceStylist
is responsible for the left guidance view, while the GuidedActionsStylist
is responsible for the right actions view. The stylists use theme
attributes to derive values associated with the presentation, such as colors, animations, etc.
Most simple visual aspects of GuidanceStylist and GuidedActionsStylist can be customized
via theming; see their documentation for more information.
GuidedStepFragments must have access to an appropriate theme in order for the stylists to
function properly. Specifically, the fragment must receive android.support.v17.leanback.R.style#Theme_Leanback_GuidedStep
, or a theme whose parent is
is set to that theme. Themes can be provided in one of three ways:
android.support.v17.leanback.R.styleable#LeanbackGuidedStepTheme_guidedStepTheme
. If present,
this theme will be used by GuidedStepFragment as an overlay to the Activity's theme.onProvideTheme()
method. This can be useful if a subclass is used across multiple
Activities.If the theme is provided in multiple ways, the onProvideTheme override has priority, followed by the Activity's theme. (Themes whose parent theme is already set to the guided step theme do not need to set the guidedStepTheme attribute; if set, it will be ignored.)
If themes do not provide enough customizability, the stylists themselves may be subclassed and
provided to the GuidedStepFragment through the onCreateGuidanceStylist()
and onCreateActionsStylist()
methods. The stylists have simple hooks so that subclasses
may override layout files; subclasses may also have more complex logic to determine styling.
GuidedStepFragments can be grouped together to provide a guided sequence. GuidedStepFragments
grouped as a sequence use custom animations provided by GuidanceStylist
and
GuidedActionsStylist
(or subclasses) during transitions between steps. Clients
should use add(android.app.FragmentManager, android.support.v17.leanback.app.GuidedStepFragment)
to place subsequent GuidedFragments onto the fragment stack so that
custom animations are properly configured. (Custom animations are triggered automatically when
the fragment stack is subsequently popped by any normal mechanism.)
Note: Currently GuidedStepFragments grouped in this way must all be defined programmatically, rather than in XML. This restriction may be removed in the future.
GuidanceStylist
,
GuidanceStylist.Guidance
,
GuidedAction
,
GuidedActionsStylist
Modifier and Type | Class and Description |
---|---|
static class |
GuidedStepFragment.DummyFragment |
Fragment.InstantiationException, Fragment.SavedState
Modifier and Type | Field and Description |
---|---|
static String |
EXTRA_UI_STYLE
Fragment argument name for UI style.
|
static int |
SLIDE_FROM_BOTTOM
Animation to slide the contents from the bottom.
|
static int |
SLIDE_FROM_SIDE
Animation to slide the contents from the side (left/right).
|
static int |
UI_STYLE_ACTIVITY_ROOT
One possible value of argument
EXTRA_UI_STYLE . |
static int |
UI_STYLE_DEFAULT
Deprecated.
Same value as
UI_STYLE_REPLACE . |
static int |
UI_STYLE_ENTRANCE
Default value for argument
EXTRA_UI_STYLE . |
static int |
UI_STYLE_REPLACE
This is the case that we use GuidedStepFragment to replace another existing
GuidedStepFragment when moving forward to next step.
|
TRIM_MEMORY_BACKGROUND, TRIM_MEMORY_COMPLETE, TRIM_MEMORY_MODERATE, TRIM_MEMORY_RUNNING_CRITICAL, TRIM_MEMORY_RUNNING_LOW, TRIM_MEMORY_RUNNING_MODERATE, TRIM_MEMORY_UI_HIDDEN
Constructor and Description |
---|
GuidedStepFragment() |
Modifier and Type | Method and Description |
---|---|
static int |
add(FragmentManager fragmentManager,
GuidedStepFragment fragment)
Adds the specified GuidedStepFragment to the fragment stack, replacing any existing
GuidedStepFragments in the stack, and configuring the fragment-to-fragment custom
transitions.
|
static int |
add(FragmentManager fragmentManager,
GuidedStepFragment fragment,
int id)
Adds the specified GuidedStepFragment to the fragment stack, replacing any existing
GuidedStepFragments in the stack, and configuring the fragment-to-fragment custom
transitions.
|
static int |
addAsRoot(Activity activity,
GuidedStepFragment fragment,
int id)
Adds the specified GuidedStepFragment as content of Activity; no backstack entry is added so
the activity will be dismissed when BACK key is pressed.
|
void |
collapseSubActions()
Collapse sub actions list.
|
void |
expandSubActions(GuidedAction action)
Expand a given action's sub actions list.
|
GuidedAction |
findActionById(long id)
Find GuidedAction by Id.
|
int |
findActionPositionById(long id)
Find GuidedAction position in array by Id.
|
GuidedAction |
findButtonActionById(long id)
Find button GuidedAction by Id.
|
int |
findButtonActionPositionById(long id)
Find button GuidedAction position in array by Id.
|
void |
finishGuidedStepFragments()
Convenient method to close GuidedStepFragments on top of other content or finish Activity if
GuidedStepFragments were started in a separate activity.
|
View |
getActionItemView(int position)
Returns the view corresponding to the action at the indicated position in the list of
actions for this fragment.
|
List<GuidedAction> |
getActions()
Returns the list of GuidedActions that the user may take in this fragment.
|
View |
getButtonActionItemView(int position)
Returns the view corresponding to the button action at the indicated position in the list of
actions for this fragment.
|
List<GuidedAction> |
getButtonActions()
Returns the list of button GuidedActions that the user may take in this fragment.
|
static GuidedStepFragment |
getCurrentGuidedStepFragment(FragmentManager fm)
Returns the current GuidedStepFragment on the fragment transaction stack.
|
GuidanceStylist |
getGuidanceStylist()
Returns the GuidanceStylist that displays guidance information for the user.
|
GuidedActionsStylist |
getGuidedActionsStylist()
Returns the GuidedActionsStylist that displays the actions the user may take.
|
GuidedActionsStylist |
getGuidedButtonActionsStylist()
Returns the GuidedActionsStylist that displays the button actions the user may take.
|
int |
getSelectedActionPosition()
Returns the position if the currently selected GuidedAction.
|
int |
getSelectedButtonActionPosition()
Returns the position if the currently selected button GuidedAction.
|
int |
getUiStyle()
Read UI style from fragment arguments.
|
boolean |
isFocusOutEndAllowed()
Returns true if allows focus out of end edge of GuidedStepFragment, false otherwise.
|
boolean |
isFocusOutStartAllowed()
Returns true if allows focus out of start edge of GuidedStepFragment, false otherwise.
|
boolean |
isSubActionsExpanded() |
void |
notifyActionChanged(int position)
Notify an action has changed and update its UI.
|
void |
notifyButtonActionChanged(int position)
Notify an button action has changed and update its UI.
|
protected void |
onAddSharedElementTransition(FragmentTransaction ft,
GuidedStepFragment disappearing)
Called when this fragment is added to FragmentTransaction with
UI_STYLE_REPLACE (aka
when the GuidedStepFragment replacing an existing GuidedStepFragment). |
void |
onCreate(Bundle savedInstanceState)
Called to do initial creation of a fragment.
|
void |
onCreateActions(List<GuidedAction> actions,
Bundle savedInstanceState)
Fills out the set of actions available to the user.
|
GuidedActionsStylist |
onCreateActionsStylist()
Creates the presenter used to style the guided actions panel.
|
View |
onCreateBackgroundView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState)
Called by onCreateView to inflate background view.
|
void |
onCreateButtonActions(List<GuidedAction> actions,
Bundle savedInstanceState)
Fills out the set of actions shown at right available to the user.
|
GuidedActionsStylist |
onCreateButtonActionsStylist()
Creates the presenter used to style a sided actions panel for button only.
|
GuidanceStylist.Guidance |
onCreateGuidance(Bundle savedInstanceState)
Returns the information required to provide guidance to the user.
|
GuidanceStylist |
onCreateGuidanceStylist()
Creates the presenter used to style the guidance panel.
|
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
Fragment.onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle) has
been detached from the fragment. |
void |
onGuidedActionClicked(GuidedAction action)
Callback invoked when an action is taken by the user.
|
void |
onGuidedActionEditCanceled(GuidedAction action)
Callback invoked when an action has been canceled editing, for example when user closes
IME window by BACK key.
|
void |
onGuidedActionEdited(GuidedAction action)
Deprecated.
|
long |
onGuidedActionEditedAndProceed(GuidedAction action)
Callback invoked when an action has been edited, for example when user clicks confirm button
in IME window.
|
void |
onGuidedActionFocused(GuidedAction action)
Callback invoked when an action is focused (made to be the current selection) by the user.
|
protected void |
onProvideFragmentTransitions()
Called by Constructor to provide fragment transitions.
|
int |
onProvideTheme()
Returns the theme used for styling the fragment.
|
void |
onResume()
Called when the fragment is visible to the user and actively running.
|
void |
onSaveInstanceState(Bundle outState)
Called to ask the fragment to save its current dynamic state, so it
can later be reconstructed in a new instance of its process is
restarted.
|
boolean |
onSubGuidedActionClicked(GuidedAction action)
Callback invoked when an action in sub actions is taken by the user.
|
void |
popBackStackToGuidedStepFragment(Class guidedStepFragmentClass,
int flags)
Convenient method to pop to fragment with Given class.
|
void |
setActions(List<GuidedAction> actions)
Sets the list of GuidedActions that the user may take in this fragment.
|
void |
setButtonActions(List<GuidedAction> actions)
Sets the list of button GuidedActions that the user may take in this fragment.
|
void |
setEntranceTransitionType(int transitionType)
Sets the transition type to be used for
UI_STYLE_ENTRANCE animation. |
void |
setSelectedActionPosition(int position)
Scrolls the action list to the position indicated, selecting that action's view.
|
void |
setSelectedButtonActionPosition(int position)
Scrolls the action list to the position indicated, selecting that button action's view.
|
void |
setUiStyle(int style)
Set UI style to fragment arguments.
|
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, hashCode, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isRemoving, isResumed, isVisible, onActivityCreated, onActivityResult, onAttach, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroy, onDestroyOptionsMenu, onDetach, onHiddenChanged, onInflate, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPrepareOptionsMenu, onRequestPermissionsResult, onStart, onStop, onTrimMemory, onViewCreated, onViewStateRestored, registerForContextMenu, requestPermissions, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterSharedElementTransitionCallback, setEnterTransition, setExitSharedElementCallback, setExitSharedElementTransitionCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, toString, unregisterForContextMenu
public static final String EXTRA_UI_STYLE
UI_STYLE_ENTRANCE
and
might be changed in one of the three helper functions:
addAsRoot(Activity, GuidedStepFragment, int)
sets to
UI_STYLE_ACTIVITY_ROOT
add(FragmentManager, GuidedStepFragment)
or add(FragmentManager,
GuidedStepFragment, int)
sets it to UI_STYLE_REPLACE
if there is already a
GuidedStepFragment on stack.finishGuidedStepFragments()
changes current GuidedStepFragment to
UI_STYLE_ENTRANCE
for the non activity case. This is a special case that changes
the transition settings after fragment has been created, in order to force current
GuidedStepFragment run a return transition of UI_STYLE_ENTRANCE
Argument value can be either:
public static final int UI_STYLE_REPLACE
UI_STYLE_ENTRANCE
.
@Deprecated public static final int UI_STYLE_DEFAULT
UI_STYLE_REPLACE
.public static final int UI_STYLE_ENTRANCE
EXTRA_UI_STYLE
. The default value is assigned in
GuidedStepFragment constructor. This is the case that we show GuidedStepFragment on top of
other content. The default behavior of this style:
finishGuidedStepFragments()
also changes
the top GuidedStepFragment to UI_STYLE_ENTRANCE in order to run the return transition
(reverse of enter transition) of UI_STYLE_ENTRANCE.public static final int UI_STYLE_ACTIVITY_ROOT
EXTRA_UI_STYLE
. This is the case that we show first
GuidedStepFragment in a separate activity. The default behavior of this style:
UI_STYLE_ENTRANCE
. Note: Changing exit transition by UI style is not working
because fragment transition asks for exit transition before UI style is restored in
Fragment.onCreate().public static final int SLIDE_FROM_SIDE
public static final int SLIDE_FROM_BOTTOM
public GuidanceStylist onCreateGuidanceStylist()
public GuidedActionsStylist onCreateActionsStylist()
public GuidedActionsStylist onCreateButtonActionsStylist()
public int onProvideTheme()
@NonNull public GuidanceStylist.Guidance onCreateGuidance(Bundle savedInstanceState)
onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)
. May be overridden to return a custom subclass of GuidanceStylist.Guidance
for use in a subclass of GuidanceStylist
. The default
returns a Guidance object with empty fields; subclasses should override.savedInstanceState
- The saved instance state from onCreateView.public void onCreateActions(@NonNull List<GuidedAction> actions, Bundle savedInstanceState)
onCreate(android.os.Bundle)
. The default leaves the list of actions empty; subclasses should override.actions
- A non-null, empty list ready to be populated.savedInstanceState
- The saved instance state from onCreate.public void onCreateButtonActions(@NonNull List<GuidedAction> actions, Bundle savedInstanceState)
onCreate(android.os.Bundle)
. The default leaves the list of actions empty; subclasses may override.actions
- A non-null, empty list ready to be populated.savedInstanceState
- The saved instance state from onCreate.public void onGuidedActionClicked(GuidedAction action)
action
- The chosen action.public boolean onSubGuidedActionClicked(GuidedAction action)
action
- The chosen action.public boolean isSubActionsExpanded()
public void expandSubActions(GuidedAction action)
action
- GuidedAction to expand.GuidedAction.getSubActions()
public void collapseSubActions()
GuidedAction.getSubActions()
public void onGuidedActionFocused(GuidedAction action)
onGuidedActionFocused
in interface GuidedActionAdapter.FocusListener
@Deprecated public void onGuidedActionEdited(GuidedAction action)
onGuidedActionEditedAndProceed(GuidedAction)
and/or
onGuidedActionEditCanceled(GuidedAction)
.public void onGuidedActionEditCanceled(GuidedAction action)
onGuidedActionEdited(GuidedAction)
.action
- The action which has been canceled editing.public long onGuidedActionEditedAndProceed(GuidedAction action)
onGuidedActionEdited(GuidedAction)
and returns GuidedAction.ACTION_ID_NEXT
.action
- The action that has been edited.GuidedAction.ACTION_ID_NEXT
,
GuidedAction.ACTION_ID_CURRENT
.public static int add(FragmentManager fragmentManager, GuidedStepFragment fragment)
UI_STYLE_REPLACE
UI_STYLE_ENTRANCE
Note: currently fragments added using this method must be created programmatically rather than via XML.
fragmentManager
- The FragmentManager to be used in the transaction.fragment
- The GuidedStepFragment to be inserted into the fragment stack.public static int add(FragmentManager fragmentManager, GuidedStepFragment fragment, int id)
UI_STYLE_REPLACE
and
onAddSharedElementTransition(FragmentTransaction, GuidedStepFragment)
will be called
to perform shared element transition between GuidedStepFragments.
UI_STYLE_ENTRANCE
Note: currently fragments added using this method must be created programmatically rather than via XML.
fragmentManager
- The FragmentManager to be used in the transaction.fragment
- The GuidedStepFragment to be inserted into the fragment stack.id
- The id of container to add GuidedStepFragment, can be android.R.id.content.protected void onAddSharedElementTransition(FragmentTransaction ft, GuidedStepFragment disappearing)
UI_STYLE_REPLACE
(aka
when the GuidedStepFragment replacing an existing GuidedStepFragment). Default implementation
establishes connections between action background views to morph action background bounds
change from disappearing GuidedStepFragment into this GuidedStepFragment. The default
implementation heavily relies on GuidedActionsStylist
's layout, app may override this
method when modifying the default layout of GuidedActionsStylist
.ft
- The FragmentTransaction to add shared element.disappearing
- The disappearing fragment.GuidedActionsStylist
,
onProvideFragmentTransitions()
public static int addAsRoot(Activity activity, GuidedStepFragment fragment, int id)
UI_STYLE_ACTIVITY_ROOT
is assigned.
Note: currently fragments added using this method must be created programmatically rather
than via XML.activity
- The Activity to be used to insert GuidedstepFragment.fragment
- The GuidedStepFragment to be inserted into the fragment stack.id
- The id of container to add GuidedStepFragment, can be android.R.id.content.public static GuidedStepFragment getCurrentGuidedStepFragment(FragmentManager fm)
public GuidanceStylist getGuidanceStylist()
public GuidedActionsStylist getGuidedActionsStylist()
public List<GuidedAction> getButtonActions()
public GuidedAction findButtonActionById(long id)
id
- Id of the button action to search.public int findButtonActionPositionById(long id)
id
- Id of the button action to search.public GuidedActionsStylist getGuidedButtonActionsStylist()
public void setButtonActions(List<GuidedAction> actions)
actions
- The list of button GuidedActions for this fragment.public void notifyButtonActionChanged(int position)
position
- Position of the button GuidedAction in array.public View getButtonActionItemView(int position)
position
- The integer position of the button action of interest.public void setSelectedButtonActionPosition(int position)
position
- The integer position of the button action of interest.public int getSelectedButtonActionPosition()
public List<GuidedAction> getActions()
public GuidedAction findActionById(long id)
id
- Id of the action to search.public int findActionPositionById(long id)
id
- Id of the action to search.public void setActions(List<GuidedAction> actions)
actions
- The list of GuidedActions for this fragment.public void notifyActionChanged(int position)
position
- Position of the GuidedAction in array.public View getActionItemView(int position)
position
- The integer position of the action of interest.public void setSelectedActionPosition(int position)
position
- The integer position of the action of interest.public int getSelectedActionPosition()
protected void onProvideFragmentTransitions()
getUiStyle()
:
UI_STYLE_REPLACE
Slide from/to end(right) for enter transition, slide from/to
start(left) for exit transition, shared element enter transition is set to ChangeBounds.
UI_STYLE_ENTRANCE
Enter transition is set to slide from both sides, exit
transition is same as UI_STYLE_REPLACE
, no shared element enter transition.
UI_STYLE_ACTIVITY_ROOT
Enter transition is set to null and app should rely on
activity transition, exit transition is same as UI_STYLE_REPLACE
, no shared element
enter transition.
The default implementation heavily relies on GuidedActionsStylist
and
GuidanceStylist
layout, app may override this method when modifying the default
layout of GuidedActionsStylist
or GuidanceStylist
.
TIP: because the fragment view is removed during fragment transition, in general app cannot use two Visibility transition together. Workaround is to create your own Visibility transition that controls multiple animators (e.g. slide and fade animation in one Transition class).
public View onCreateBackgroundView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
R.layout#lb_guidedstep_background
which holds a reference to
guidedStepBackground.inflater
- LayoutInflater to load background view.container
- Parent view of background view.savedInstanceState
- public void setUiStyle(int style)
UI_STYLE_ENTRANCE
when fragment
is first initialized. UI style is used to choose different fragment transition animations and
determine if this is the first GuidedStepFragment on backstack. In most cases app does not
directly call this method, app calls helper function
add(FragmentManager, GuidedStepFragment, int)
. However if the app creates Fragment
transaction and controls backstack by itself, it would need call setUiStyle() to select the
fragment transition to use.style
- UI_STYLE_ACTIVITY_ROOT
UI_STYLE_REPLACE
or
UI_STYLE_ENTRANCE
.public int getUiStyle()
UI_STYLE_ENTRANCE
when
fragment is first initialized. UI style is used to choose different fragment transition
animations and determine if this is the first GuidedStepFragment on backstack.UI_STYLE_ACTIVITY_ROOT
UI_STYLE_REPLACE
or
UI_STYLE_ENTRANCE
.onProvideFragmentTransitions()
public void onCreate(Bundle savedInstanceState)
Fragment.onAttach(Activity)
and before
Fragment.onCreateView(LayoutInflater, ViewGroup, Bundle)
, but is not called if the fragment
instance is retained across Activity re-creation (see Fragment.setRetainInstance(boolean)
).
Note that this can be called while the fragment's activity is
still in the process of being created. As such, you can not rely
on things like the activity's content view hierarchy being initialized
at this point. If you want to do work once the activity itself is
created, see Fragment.onActivityCreated(Bundle)
.
If your app's targetSdkVersion
is Build.VERSION_CODES.M
or lower, child fragments being restored from the savedInstanceState are restored after
onCreate
returns. When targeting Build.VERSION_CODES.N
or
above and running on an N or newer platform version
they are restored by Fragment.onCreate
.
public void onDestroyView()
Fragment.onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.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 Fragment.onStop()
and before Fragment.onDestroy()
. It is called
regardless of whether Fragment.onCreateView(android.view.LayoutInflater, android.view.ViewGroup, android.os.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.onDestroyView
in class Fragment
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
Fragment.onCreate(Bundle)
and Fragment.onActivityCreated(Bundle)
.
If you return a View from here, you will later be called in
Fragment.onDestroyView()
when the view is being released.
onCreateView
in class Fragment
inflater
- The LayoutInflater object that can be used to inflate
any views in the fragment,container
- 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
- If non-null, this fragment is being re-constructed
from a previous saved state as given here.public void onResume()
Fragment
Activity.onResume
of the containing
Activity's lifecycle.public void onSaveInstanceState(Bundle outState)
Fragment.onCreate(Bundle)
,
Fragment.onCreateView(LayoutInflater, ViewGroup, Bundle)
, and
Fragment.onActivityCreated(Bundle)
.
This corresponds to Activity.onSaveInstanceState(Bundle)
and most of the discussion there
applies here as well. Note however: this method may be called
at any time before Fragment.onDestroy()
. There are many situations
where a fragment may be mostly torn down (such as when placed on the
back stack with no UI showing), but its state will not be saved until
its owning activity actually needs to save its state.
onSaveInstanceState
in class Fragment
outState
- Bundle in which to place your saved state.public void finishGuidedStepFragments()
UI_STYLE_ENTRANCE
; if UI_STYLE_ENTRANCE
is not found, finish the activity.
Note that this method must be paired with add(FragmentManager, GuidedStepFragment,
int)
which sets up the stack entry name for finding which fragment we need to pop back to.public void popBackStackToGuidedStepFragment(Class guidedStepFragmentClass, int flags)
guidedStepFragmentClass
- Name of the Class of GuidedStepFragment to pop to.flags
- Either 0 or FragmentManager.POP_BACK_STACK_INCLUSIVE
.public boolean isFocusOutStartAllowed()
public boolean isFocusOutEndAllowed()
public void setEntranceTransitionType(int transitionType)
UI_STYLE_ENTRANCE
animation.
Currently we provide 2 different variations for animation - slide in from
side (default) or bottom.
Ideally we can retrieve the screen mode settings from the theme attribute
Theme.Leanback.GuidedStep#guidedStepHeightWeight
and use that to
determine the transition. But the fragment context to retrieve the theme
isn't available on platform v23 or earlier.
For now clients(subclasses) can call this method inside the constructor.