GuidedStepSupportFragment

open class GuidedStepSupportFragment
kotlin.Any
   ↳ androidx.leanback.app.GuidedStepSupportFragment

A GuidedStepSupportFragment is used to guide the user through a decision or series of decisions. It is composed of a guidance view on the left and a view on the right containing a list of possible actions.

Basic Usage

Clients of GuidedStepSupportFragment 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:

Clients use following helper functions to add GuidedStepSupportFragment to Activity or FragmentManager:

Theming and Stylists

GuidedStepSupportFragment delegates its visual styling to classes called stylists. The is responsible for the left guidance view, while the 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.

GuidedStepSupportFragments must have access to an appropriate theme in order for the stylists to function properly. Specifically, the fragment must receive androidx.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:

  • The simplest way is to set the theme for the host Activity to the GuidedStep theme or a theme that derives from it.
  • If the Activity already has a theme and setting its parent theme is inconvenient, the existing Activity theme can have an entry added for the attribute androidx.leanback.R.styleable#LeanbackGuidedStepTheme_guidedStepTheme. If present, this theme will be used by GuidedStepSupportFragment as an overlay to the Activity's theme.
  • Finally, custom subclasses of GuidedStepSupportFragment may provide a theme through the 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 GuidedStepSupportFragment through the #onCreateGuidanceStylist and methods. The stylists have simple hooks so that subclasses may override layout files; subclasses may also have more complex logic to determine styling.

Guided sequences

GuidedStepSupportFragments can be grouped together to provide a guided sequence. GuidedStepSupportFragments grouped as a sequence use custom animations provided by GuidanceStylist and GuidedActionsStylist (or subclasses) during transitions between steps. Clients should use #add 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 GuidedStepSupportFragments grouped in this way must all be defined programmatically, rather than in XML. This restriction may be removed in the future.

Summary

Constants
static String

Fragment argument name for UI style.

static Int

One possible value of argument #EXTRA_UI_STYLE.

static Int

static Int

Default value for argument #EXTRA_UI_STYLE.

static Int

This is the case that we use GuidedStepSupportFragment to replace another existing GuidedStepSupportFragment when moving forward to next step.

Public constructors

Public methods
open Unit

Callback invoked when an action's title or description has been edited, this happens either when user clicks confirm button in IME or user closes IME window by BACK key.

open Unit
setUiStyle(style: Int)

Set UI style to fragment arguments.

open Unit

open Boolean

open Int

Find button GuidedAction position in array by Id.

open GuidedActionsStylist!

Creates the presenter used to style a sided actions panel for button only.

open Unit
onCreateButtonActions(actions: MutableList<GuidedAction!>, savedInstanceState: Bundle!)

Fills out the set of actions shown at right available to the user.

open MutableList<GuidedAction!>!

Returns the list of button GuidedActions that the user may take in this fragment.

open Unit

open Unit

Notify an action has changed and update its UI.

open Unit
collapseAction(withTransition: Boolean)

Collapse action which either has a sub actions list or action with GuidedAction#hasEditableActivatorView() is true.

open GuidanceStylist.Guidance
onCreateGuidance(savedInstanceState: Bundle!)

Returns the information required to provide guidance to the user.

open GuidedAction!

Find GuidedAction by Id.

open Unit

Collapse sub actions list.

open Int

Returns the position if the currently selected button GuidedAction.

open Unit

Convenient method to close GuidedStepSupportFragments on top of other content or finish Activity if GuidedStepSupportFragments were started in a separate activity.

open Boolean

open Int

Returns the position if the currently selected GuidedAction.

open View!
onCreateView(inflater: LayoutInflater!, container: ViewGroup!, savedInstanceState: Bundle!)

open Unit

Expand a given action's sub actions list.

open Int

Returns the theme used for styling the fragment.

open Unit

Callback invoked when an action is focused (made to be the current selection) by the user.

open Unit

Sets the list of button GuidedActions that the user may take in this fragment.

open Unit
popBackStackToGuidedStepSupportFragment(guidedStepFragmentClass: Class<Any!>!, flags: Int)

Convenient method to pop to fragment with Given class.

open Long

Callback invoked when an action has been edited, for example when user clicks confirm button in IME window.

open Unit

Notify an button action has changed and update its UI.

open Unit

Opens the provided action in edit mode and raises ime.

open Unit

Callback invoked when an action has been canceled editing, for example when user closes IME window by BACK key.

open MutableList<GuidedAction!>!

Returns the list of GuidedActions that the user may take in this fragment.

open Int

Find GuidedAction position in array by Id.

open GuidanceStylist!

Returns the GuidanceStylist that displays guidance information for the user.

open Unit

Scrolls the action list to the position indicated, selecting that action's view.

open Unit
expandAction(action: GuidedAction!, withTransition: Boolean)

Expand a given action with sub actions list or GuidedAction#hasEditableActivatorView() is true.

open Boolean

Returns true if allows focus out of start edge of GuidedStepSupportFragment, false otherwise.

open Unit

open Unit

Callback invoked when an action is taken by the user.

open GuidanceStylist!

Creates the presenter used to style the guidance panel.

open GuidedAction!

Find button GuidedAction by Id.

open View!

Returns the view corresponding to the action at the indicated position in the list of actions for this fragment.

open GuidedActionsStylist!

Returns the GuidedActionsStylist that displays the button actions the user may take.

open Unit

Sets the RecyclerView DiffCallback used when #setActions(List) is called.

open Unit
onCreate(savedInstanceState: Bundle!)

open View!

Returns the view corresponding to the button action at the indicated position in the list of actions for this fragment.

open View!
onCreateBackgroundView(inflater: LayoutInflater!, container: ViewGroup!, savedInstanceState: Bundle!)

Called by onCreateView to inflate background view.

open Unit

Scrolls the action list to the position indicated, selecting that button action's view.

open Boolean

Callback invoked when an action in sub actions is taken by the user.

open GuidedActionsStylist!

Returns the GuidedActionsStylist that displays the actions the user may take.

open Unit
onCreateActions(actions: MutableList<GuidedAction!>, savedInstanceState: Bundle!)

Fills out the set of actions available to the user.

open Boolean

Returns true if allows focus out of end edge of GuidedStepSupportFragment, false otherwise.

open Int

Read UI style from fragment arguments.

open GuidedActionsStylist!

Creates the presenter used to style the guided actions panel.

open Unit

Sets the list of GuidedActions that the user may take in this fragment.

open static Int
add(fragmentManager: FragmentManager!, fragment: GuidedStepSupportFragment!)

Adds the specified GuidedStepSupportFragment to the fragment stack, replacing any existing GuidedStepSupportFragments in the stack, and configuring the fragment-to-fragment custom transitions.

open static Int
add(fragmentManager: FragmentManager!, fragment: GuidedStepSupportFragment!, id: Int)

Adds the specified GuidedStepSupportFragment to the fragment stack, replacing any existing GuidedStepSupportFragments in the stack, and configuring the fragment-to-fragment custom transitions.

open static Int
addAsRoot(activity: FragmentActivity!, fragment: GuidedStepSupportFragment!, id: Int)

Adds the specified GuidedStepSupportFragment as content of Activity; no backstack entry is added so the activity will be dismissed when BACK key is pressed.

open static GuidedStepSupportFragment!

Returns the current GuidedStepSupportFragment on the fragment transaction stack.

Protected methods
open Unit
onAddSharedElementTransition(ft: FragmentTransaction!, disappearing: GuidedStepSupportFragment!)

Called when this fragment is added to FragmentTransaction with #UI_STYLE_REPLACE (aka when the GuidedStepSupportFragment replacing an existing GuidedStepSupportFragment).

open Unit

Called by Constructor to provide fragment transitions.

Constants

EXTRA_UI_STYLE

static val EXTRA_UI_STYLE: String

Fragment argument name for UI style. The argument value is persisted in fragment state and used to select fragment transition. The value is initially #UI_STYLE_ENTRANCE and might be changed in one of the three helper functions:

Argument value can be either:

Value: "uiStyle"

UI_STYLE_ACTIVITY_ROOT

static val UI_STYLE_ACTIVITY_ROOT: Int

One possible value of argument #EXTRA_UI_STYLE. This is the case that we show first GuidedStepSupportFragment in a separate activity. The default behavior of this style:

  • Enter transition is assigned null (will rely on activity transition), exit transition is same as #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().

Value: 2

UI_STYLE_DEFAULT

static val UI_STYLE_DEFAULT: Int
Value: 0

UI_STYLE_ENTRANCE

static val UI_STYLE_ENTRANCE: Int

Default value for argument #EXTRA_UI_STYLE. The default value is assigned in GuidedStepSupportFragment constructor. This is the case that we show GuidedStepSupportFragment on top of other content. The default behavior of this style:

  • Enter transition slides in from two sides, exit transition slide out to START(left). Background will be faded in. 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().
When popping multiple GuidedStepSupportFragment, #finishGuidedStepSupportFragments() also changes the top GuidedStepSupportFragment to UI_STYLE_ENTRANCE in order to run the return transition (reverse of enter transition) of UI_STYLE_ENTRANCE.

Value: 1

UI_STYLE_REPLACE

static val UI_STYLE_REPLACE: Int

This is the case that we use GuidedStepSupportFragment to replace another existing GuidedStepSupportFragment when moving forward to next step. Default behavior of this style is:

Value: 0

Public constructors

<init>

GuidedStepSupportFragment()

Public methods

onGuidedActionEdited

open fun onGuidedActionEdited(action: GuidedAction!): Unit

Callback invoked when an action's title or description has been edited, this happens either when user clicks confirm button in IME or user closes IME window by BACK key.

setUiStyle

open fun setUiStyle(style: Int): Unit

Set UI style to fragment arguments. Default value is #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 GuidedStepSupportFragment on backstack. In most cases app does not directly call this method, app calls helper function #add(FragmentManager, GuidedStepSupportFragment, 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.

Parameters
style Int: #UI_STYLE_ACTIVITY_ROOT #UI_STYLE_REPLACE or #UI_STYLE_ENTRANCE.

onResume

open fun onResume(): Unit

isSubActionsExpanded

open fun isSubActionsExpanded(): Boolean
Return
Boolean: True if the sub actions list is expanded, false otherwise.

findButtonActionPositionById

open fun findButtonActionPositionById(id: Long): Int

Find button GuidedAction position in array by Id.

Parameters
id Long: Id of the button action to search.
Return
Int: position of GuidedAction object in array or -1 if not found.

onCreateButtonActionsStylist

open fun onCreateButtonActionsStylist(): GuidedActionsStylist!

Creates the presenter used to style a sided actions panel for button only. The default implementation returns a basic GuidedActionsStylist.

Return
GuidedActionsStylist!: The GuidedActionsStylist used in this fragment.

onCreateButtonActions

open fun onCreateButtonActions(actions: MutableList<GuidedAction!>, savedInstanceState: Bundle!): Unit

Fills out the set of actions shown at right available to the user. This hook is called during #onCreate. The default leaves the list of actions empty; subclasses may override.

Parameters
actions MutableList<GuidedAction!>: A non-null, empty list ready to be populated.
savedInstanceState MutableList<GuidedAction!>: The saved instance state from onCreate.

getButtonActions

open fun getButtonActions(): MutableList<GuidedAction!>!

Returns the list of button GuidedActions that the user may take in this fragment.

Return
MutableList<GuidedAction!>!: The list of button GuidedActions for this fragment.

onSaveInstanceState

open fun onSaveInstanceState(outState: Bundle!): Unit

notifyActionChanged

open fun notifyActionChanged(position: Int): Unit

Notify an action has changed and update its UI.

Parameters
position Int: Position of the GuidedAction in array.

collapseAction

open fun collapseAction(withTransition: Boolean): Unit

Collapse action which either has a sub actions list or action with GuidedAction#hasEditableActivatorView() is true.

Parameters
withTransition Boolean: True to run transition animation, false otherwise.

onCreateGuidance

open fun onCreateGuidance(savedInstanceState: Bundle!): GuidanceStylist.Guidance

Returns the information required to provide guidance to the user. This hook is called during #onCreateView. May be overridden to return a custom subclass of for use in a subclass of GuidanceStylist. The default returns a Guidance object with empty fields; subclasses should override.

Parameters
savedInstanceState Bundle!: The saved instance state from onCreateView.
Return
GuidanceStylist.Guidance: The Guidance object representing the information used to guide the user.

findActionById

open fun findActionById(id: Long): GuidedAction!

Find GuidedAction by Id.

Parameters
id Long: Id of the action to search.
Return
GuidedAction!: GuidedAction object or null if not found.

collapseSubActions

open fun collapseSubActions(): Unit

Collapse sub actions list.

getSelectedButtonActionPosition

open fun getSelectedButtonActionPosition(): Int

Returns the position if the currently selected button GuidedAction.

Return
Int: position The integer position of the currently selected button action.

finishGuidedStepSupportFragments

open fun finishGuidedStepSupportFragments(): Unit

Convenient method to close GuidedStepSupportFragments on top of other content or finish Activity if GuidedStepSupportFragments were started in a separate activity. Pops all stack entries including #UI_STYLE_ENTRANCE; if #UI_STYLE_ENTRANCE is not found, finish the activity. Note that this method must be paired with #add(FragmentManager, GuidedStepSupportFragment, * int) which sets up the stack entry name for finding which fragment we need to pop back to.

isExpanded

open fun isExpanded(): Boolean
Return
Boolean: True if is current expanded including subactions list or action with GuidedAction#hasEditableActivatorView() is true.

getSelectedActionPosition

open fun getSelectedActionPosition(): Int

Returns the position if the currently selected GuidedAction.

Return
Int: position The integer position of the currently selected action.

onCreateView

open fun onCreateView(inflater: LayoutInflater!, container: ViewGroup!, savedInstanceState: Bundle!): View!

expandSubActions

open fun expandSubActions(action: GuidedAction!): Unit

Expand a given action's sub actions list.

Parameters
action GuidedAction!: GuidedAction to expand.

onProvideTheme

open fun onProvideTheme(): Int

Returns the theme used for styling the fragment. The default returns -1, indicating that the host Activity's theme should be used.

Return
Int: The theme resource ID of the theme to use in this fragment, or -1 to use the host Activity's theme.

onGuidedActionFocused

open fun onGuidedActionFocused(action: GuidedAction!): Unit

Callback invoked when an action is focused (made to be the current selection) by the user.

setButtonActions

open fun setButtonActions(actions: MutableList<GuidedAction!>!): Unit

Sets the list of button GuidedActions that the user may take in this fragment.

Parameters
actions MutableList<GuidedAction!>!: The list of button GuidedActions for this fragment.

popBackStackToGuidedStepSupportFragment

open fun popBackStackToGuidedStepSupportFragment(guidedStepFragmentClass: Class<Any!>!, flags: Int): Unit

Convenient method to pop to fragment with Given class.

Parameters
guidedStepFragmentClass Class<Any!>!: Name of the Class of GuidedStepSupportFragment to pop to.
flags Class<Any!>!: Either 0 or FragmentManager#POP_BACK_STACK_INCLUSIVE.

onGuidedActionEditedAndProceed

open fun onGuidedActionEditedAndProceed(action: GuidedAction!): Long

Callback invoked when an action has been edited, for example when user clicks confirm button in IME window. Default implementation calls deprecated method #onGuidedActionEdited(GuidedAction) and returns GuidedAction#ACTION_ID_NEXT.

Parameters
action GuidedAction!: The action that has been edited.
Return
Long: ID of the action will be focused or GuidedAction#ACTION_ID_NEXT, GuidedAction#ACTION_ID_CURRENT.

notifyButtonActionChanged

open fun notifyButtonActionChanged(position: Int): Unit

Notify an button action has changed and update its UI.

Parameters
position Int: Position of the button GuidedAction in array.

openInEditMode

open fun openInEditMode(action: GuidedAction!): Unit

Opens the provided action in edit mode and raises ime. This can be used to programmatically skip the extra click required to go into edit mode. This method can be invoked in #onCreateView(LayoutInflater, ViewGroup, Bundle).

onGuidedActionEditCanceled

open fun onGuidedActionEditCanceled(action: GuidedAction!): Unit

Callback invoked when an action has been canceled editing, for example when user closes IME window by BACK key. Default implementation calls deprecated method #onGuidedActionEdited(GuidedAction).

Parameters
action GuidedAction!: The action which has been canceled editing.

getActions

open fun getActions(): MutableList<GuidedAction!>!

Returns the list of GuidedActions that the user may take in this fragment.

Return
MutableList<GuidedAction!>!: The list of GuidedActions for this fragment.

findActionPositionById

open fun findActionPositionById(id: Long): Int

Find GuidedAction position in array by Id.

Parameters
id Long: Id of the action to search.
Return
Int: position of GuidedAction object in array or -1 if not found.

getGuidanceStylist

open fun getGuidanceStylist(): GuidanceStylist!

Returns the GuidanceStylist that displays guidance information for the user.

Return
GuidanceStylist!: The GuidanceStylist for this fragment.

setSelectedActionPosition

open fun setSelectedActionPosition(position: Int): Unit

Scrolls the action list to the position indicated, selecting that action's view.

Parameters
position Int: The integer position of the action of interest.

expandAction

open fun expandAction(action: GuidedAction!, withTransition: Boolean): Unit

Expand a given action with sub actions list or GuidedAction#hasEditableActivatorView() is true. The method must be called after #onCreateView(LayoutInflater, ViewGroup, Bundle) creates fragment view.

Parameters
action GuidedAction!: GuidedAction to expand.
withTransition GuidedAction!: True to run transition animation, false otherwise.

isFocusOutStartAllowed

open fun isFocusOutStartAllowed(): Boolean

Returns true if allows focus out of start edge of GuidedStepSupportFragment, false otherwise. Default value is false, the reason is to disable FocusFinder to find focusable views beneath content of GuidedStepSupportFragment. Subclass may override.

Return
Boolean: True if allows focus out of start edge of GuidedStepSupportFragment.

onDestroyView

open fun onDestroyView(): Unit

onGuidedActionClicked

open fun onGuidedActionClicked(action: GuidedAction!): Unit

Callback invoked when an action is taken by the user. Subclasses should override in order to act on the user's decisions.

Parameters
action GuidedAction!: The chosen action.

onCreateGuidanceStylist

open fun onCreateGuidanceStylist(): GuidanceStylist!

Creates the presenter used to style the guidance panel. The default implementation returns a basic GuidanceStylist.

Return
GuidanceStylist!: The GuidanceStylist used in this fragment.

findButtonActionById

open fun findButtonActionById(id: Long): GuidedAction!

Find button GuidedAction by Id.

Parameters
id Long: Id of the button action to search.
Return
GuidedAction!: GuidedAction object or null if not found.

getActionItemView

open fun getActionItemView(position: Int): View!

Returns the view corresponding to the action at the indicated position in the list of actions for this fragment.

Parameters
position Int: The integer position of the action of interest.
Return
View!: The View corresponding to the action at the indicated position, or null if that action is not currently onscreen.

getGuidedButtonActionsStylist

open fun getGuidedButtonActionsStylist(): GuidedActionsStylist!

Returns the GuidedActionsStylist that displays the button actions the user may take.

Return
GuidedActionsStylist!: The GuidedActionsStylist for this fragment.

setActionsDiffCallback

open fun setActionsDiffCallback(diffCallback: DiffCallback<GuidedAction!>!): Unit

Sets the RecyclerView DiffCallback used when #setActions(List) is called. By default GuidedStepSupportFragment uses androidx.leanback.widget.GuidedActionDiffCallback. Sets it to null if app wants to refresh the whole list.

Parameters
diffCallback DiffCallback<GuidedAction!>!: DiffCallback used in #setActions(List).

onCreate

open fun onCreate(savedInstanceState: Bundle!): Unit

getButtonActionItemView

open fun getButtonActionItemView(position: Int): View!

Returns the view corresponding to the button action at the indicated position in the list of actions for this fragment.

Parameters
position Int: The integer position of the button action of interest.
Return
View!: The View corresponding to the button action at the indicated position, or null if that action is not currently onscreen.

onCreateBackgroundView

open fun onCreateBackgroundView(inflater: LayoutInflater!, container: ViewGroup!, savedInstanceState: Bundle!): View!

Called by onCreateView to inflate background view. Default implementation loads view from R.layout#lb_guidedstep_background which holds a reference to guidedStepBackground.

Parameters
inflater LayoutInflater!: LayoutInflater to load background view.
container LayoutInflater!: Parent view of background view.
savedInstanceState LayoutInflater!:
Return
View!: Created background view or null if no background.

setSelectedButtonActionPosition

open fun setSelectedButtonActionPosition(position: Int): Unit

Scrolls the action list to the position indicated, selecting that button action's view.

Parameters
position Int: The integer position of the button action of interest.

onSubGuidedActionClicked

open fun onSubGuidedActionClicked(action: GuidedAction!): Boolean

Callback invoked when an action in sub actions is taken by the user. Subclasses should override in order to act on the user's decisions. Default return value is true to close the sub actions list.

Parameters
action GuidedAction!: The chosen action.
Return
Boolean: true to collapse the sub actions list, false to keep it expanded.

getGuidedActionsStylist

open fun getGuidedActionsStylist(): GuidedActionsStylist!

Returns the GuidedActionsStylist that displays the actions the user may take.

Return
GuidedActionsStylist!: The GuidedActionsStylist for this fragment.

onCreateActions

open fun onCreateActions(actions: MutableList<GuidedAction!>, savedInstanceState: Bundle!): Unit

Fills out the set of actions available to the user. This hook is called during . The default leaves the list of actions empty; subclasses should override.

Parameters
actions MutableList<GuidedAction!>: A non-null, empty list ready to be populated.
savedInstanceState MutableList<GuidedAction!>: The saved instance state from onCreate.

isFocusOutEndAllowed

open fun isFocusOutEndAllowed(): Boolean

Returns true if allows focus out of end edge of GuidedStepSupportFragment, false otherwise. Default value is false, the reason is to disable FocusFinder to find focusable views beneath content of GuidedStepSupportFragment. Subclass may override.

Return
Boolean: True if allows focus out of end edge of GuidedStepSupportFragment.

getUiStyle

open fun getUiStyle(): Int

Read UI style from fragment arguments. Default value is #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 GuidedStepSupportFragment on backstack.

Return
Int: #UI_STYLE_ACTIVITY_ROOT #UI_STYLE_REPLACE or #UI_STYLE_ENTRANCE.

onCreateActionsStylist

open fun onCreateActionsStylist(): GuidedActionsStylist!

Creates the presenter used to style the guided actions panel. The default implementation returns a basic GuidedActionsStylist.

Return
GuidedActionsStylist!: The GuidedActionsStylist used in this fragment.

setActions

open fun setActions(actions: MutableList<GuidedAction!>!): Unit

Sets the list of GuidedActions that the user may take in this fragment. Uses DiffCallback set by #setActionsDiffCallback(DiffCallback).

Parameters
actions MutableList<GuidedAction!>!: The list of GuidedActions for this fragment.

add

open static fun add(fragmentManager: FragmentManager!, fragment: GuidedStepSupportFragment!): Int

Adds the specified GuidedStepSupportFragment to the fragment stack, replacing any existing GuidedStepSupportFragments in the stack, and configuring the fragment-to-fragment custom transitions. A backstack entry is added, so the fragment will be dismissed when BACK key is pressed.

  • If current fragment on stack is GuidedStepSupportFragment: assign #UI_STYLE_REPLACE
  • If current fragment on stack is not GuidedStepSupportFragment: assign #UI_STYLE_ENTRANCE

    Note: currently fragments added using this method must be created programmatically rather than via XML.

  • Parameters
    fragmentManager FragmentManager!: The FragmentManager to be used in the transaction.
    fragment FragmentManager!: The GuidedStepSupportFragment to be inserted into the fragment stack.
    Return
    Int: The ID returned by the call FragmentTransaction.commit.

    add

    open static fun add(fragmentManager: FragmentManager!, fragment: GuidedStepSupportFragment!, id: Int): Int

    Adds the specified GuidedStepSupportFragment to the fragment stack, replacing any existing GuidedStepSupportFragments in the stack, and configuring the fragment-to-fragment custom transitions. A backstack entry is added, so the fragment will be dismissed when BACK key is pressed.

  • If current fragment on stack is GuidedStepSupportFragment: assign #UI_STYLE_REPLACE and #onAddSharedElementTransition(FragmentTransaction, GuidedStepSupportFragment) will be called to perform shared element transition between GuidedStepSupportFragments.
  • If current fragment on stack is not GuidedStepSupportFragment: assign #UI_STYLE_ENTRANCE

    Note: currently fragments added using this method must be created programmatically rather than via XML.

  • Parameters
    fragmentManager FragmentManager!: The FragmentManager to be used in the transaction.
    fragment FragmentManager!: The GuidedStepSupportFragment to be inserted into the fragment stack.
    id FragmentManager!: The id of container to add GuidedStepSupportFragment, can be android.R.id.content.
    Return
    Int: The ID returned by the call FragmentTransaction.commit.

    addAsRoot

    open static fun addAsRoot(activity: FragmentActivity!, fragment: GuidedStepSupportFragment!, id: Int): Int

    Adds the specified GuidedStepSupportFragment as content of Activity; no backstack entry is added so the activity will be dismissed when BACK key is pressed. The method is typically called in Activity.onCreate() when savedInstanceState is null. When savedInstanceState is not null, the Activity is being restored, do not call addAsRoot() to duplicate the Fragment restored by FragmentManager. #UI_STYLE_ACTIVITY_ROOT is assigned. Note: currently fragments added using this method must be created programmatically rather than via XML.

    Parameters
    activity FragmentActivity!: The Activity to be used to insert GuidedstepFragment.
    fragment FragmentActivity!: The GuidedStepSupportFragment to be inserted into the fragment stack.
    id FragmentActivity!: The id of container to add GuidedStepSupportFragment, can be android.R.id.content.
    Return
    Int: The ID returned by the call FragmentTransaction.commit, or -1 there is already GuidedStepSupportFragment.

    getCurrentGuidedStepSupportFragment

    open static fun getCurrentGuidedStepSupportFragment(fm: FragmentManager!): GuidedStepSupportFragment!

    Returns the current GuidedStepSupportFragment on the fragment transaction stack.

    Return
    GuidedStepSupportFragment!: The current GuidedStepSupportFragment, if any, on the fragment transaction stack.

    Protected methods

    onAddSharedElementTransition

    protected open fun onAddSharedElementTransition(ft: FragmentTransaction!, disappearing: GuidedStepSupportFragment!): Unit

    Called when this fragment is added to FragmentTransaction with #UI_STYLE_REPLACE (aka when the GuidedStepSupportFragment replacing an existing GuidedStepSupportFragment). Default implementation establishes connections between action background views to morph action background bounds change from disappearing GuidedStepSupportFragment into this GuidedStepSupportFragment. The default implementation heavily relies on GuidedActionsStylist's layout, app may override this method when modifying the default layout of GuidedActionsStylist.

    Parameters
    ft FragmentTransaction!: The FragmentTransaction to add shared element.
    disappearing FragmentTransaction!: The disappearing fragment.

    onProvideFragmentTransitions

    protected open fun onProvideFragmentTransitions(): Unit

    Called by Constructor to provide fragment transitions. The default implementation assigns transitions based on #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).