GuidedActionsStylist

public class GuidedActionsStylist
extends Object implements FragmentAnimationProvider

java.lang.Object
   ↳ androidx.leanback.widget.GuidedActionsStylist


GuidedActionsStylist is used within a GuidedStepFragment to supply the right-side panel where users can take actions. It consists of a container for the list of actions, and a stationary selector view that indicates visually the location of focus. GuidedActionsStylist has two different layouts: default is for normal actions including text, radio, checkbox, DatePicker, etc, the other when setAsButtonActions() is called is recommended for button actions such as "yes", "no".

Many aspects of the base GuidedActionsStylist can be customized through theming; see the theme attributes below. Note that these attributes are not set on individual elements in layout XML, but instead would be set in a custom theme. See Styles and Themes for more information.

If these hooks are insufficient, this class may also be subclassed. Subclasses may wish to override the onProvideLayoutId() method to change the layout used to display the list container and selector; override onProvideItemLayoutId(int) and getItemViewType(GuidedAction) method to change the layout used to display each action.

To support a "click to activate" view similar to DatePicker, app needs:

Note: If an alternate list layout is provided, the following view IDs must be supplied:

These view IDs must be present in order for the stylist to function. The list ID must correspond to a VerticalGridView or subclass.

If an alternate item layout is provided, the following view IDs should be used to refer to base elements:

These view IDs are allowed to be missing, in which case the corresponding views in GuidedActionsStylist.ViewHolder will be null.

In order to support editable actions, the view associated with guidedactions_item_title should be a subclass of EditText, and should satisfy the ImeKeyMonitor interface and GuidedActionAutofillSupport interface. R.attr.guidedStepImeAppearingAnimation R.attr.guidedStepImeDisappearingAnimation R.attr.guidedActionsSelectorDrawable R.attr.guidedActionsListStyle R.attr.guidedSubActionsListStyle R.attr.guidedButtonActionsListStyle R.attr.guidedActionItemContainerStyle R.attr.guidedActionItemCheckmarkStyle R.attr.guidedActionItemIconStyle R.attr.guidedActionItemContentStyle R.attr.guidedActionItemTitleStyle R.attr.guidedActionItemDescriptionStyle R.attr.guidedActionItemChevronStyle R.attr.guidedActionPressedAnimation R.attr.guidedActionUnpressedAnimation R.attr.guidedActionEnabledChevronAlpha R.attr.guidedActionDisabledChevronAlpha R.attr.guidedActionTitleMinLines R.attr.guidedActionTitleMaxLines R.attr.guidedActionDescriptionMinLines R.attr.guidedActionVerticalPadding

Summary

Nested classes

class GuidedActionsStylist.ViewHolder

ViewHolder caches information about the action item layouts' subviews. 

Constants

int VIEW_TYPE_DATE_PICKER

ViewType for DatePicker.

int VIEW_TYPE_DEFAULT

Default viewType that associated with default layout Id for the action item.

Public constructors

GuidedActionsStylist()

Public methods

void collapseAction(boolean withTransition)

Collapse expanded action.

void expandAction(GuidedAction action, boolean withTransition)

Expand an action.

VerticalGridView getActionsGridView()

Returns the VerticalGridView that displays the list of GuidedActions.

GuidedAction getExpandedAction()
int getItemViewType(GuidedAction action)

Return view type of action, each different type can have differently associated layout Id.

VerticalGridView getSubActionsGridView()

Returns the VerticalGridView that displays the sub actions list of an expanded action.

final boolean isBackKeyToCollapseActivatorView()
final boolean isBackKeyToCollapseSubActions()
boolean isButtonActions()

Returns true if it is button actions list, false for normal actions list.

boolean isExpandTransitionSupported()

Returns if expand/collapse animation is supported.

boolean isExpanded()
boolean isInExpandTransition()

Returns true if it is running an expanding or collapsing transition, false otherwise.

boolean isSubActionsExpanded()
void onAnimateItemChecked(GuidedActionsStylist.ViewHolder vh, boolean checked)

Animates the view holder's view (or subviews thereof) when the action has had its check state changed.

void onAnimateItemFocused(GuidedActionsStylist.ViewHolder vh, boolean focused)

Animates the view holder's view (or subviews thereof) when the action has had its focus state changed.

void onAnimateItemPressed(GuidedActionsStylist.ViewHolder vh, boolean pressed)

Animates the view holder's view (or subviews thereof) when the action has had its press state changed.

void onAnimateItemPressedCancelled(GuidedActionsStylist.ViewHolder vh)

Resets the view holder's view to unpressed state.

void onBindActivatorView(GuidedActionsStylist.ViewHolder vh, GuidedAction action)

Performs binding activator view value to action.

void onBindCheckMarkView(GuidedActionsStylist.ViewHolder vh, GuidedAction action)

Sets states of check mark view, called by onBindViewHolder(ViewHolder, GuidedAction) when action's checkset Id is other than GuidedAction.NO_CHECK_SET.

void onBindChevronView(GuidedActionsStylist.ViewHolder vh, GuidedAction action)

Sets states of chevron view, called by onBindViewHolder(ViewHolder, GuidedAction).

void onBindViewHolder(GuidedActionsStylist.ViewHolder vh, GuidedAction action)

Binds a GuidedActionsStylist.ViewHolder to a particular GuidedAction.

View onCreateView(LayoutInflater inflater, ViewGroup container)

Creates a view appropriate for displaying a list of GuidedActions, using the provided inflater and container.

GuidedActionsStylist.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)

Constructs a GuidedActionsStylist.ViewHolder capable of representing GuidedActions.

GuidedActionsStylist.ViewHolder onCreateViewHolder(ViewGroup parent)

Constructs a GuidedActionsStylist.ViewHolder capable of representing GuidedActions.

void onDestroyView()

Called when destroy the View created by GuidedActionsStylist.

void onImeAppearing(List<Animator> animators)

Animates the fragment in response to the IME appearing.

void onImeDisappearing(List<Animator> animators)

Animates the fragment in response to the IME disappearing.

int onProvideItemLayoutId()

Provides the resource ID of the layout defining the view for an individual guided actions.

int onProvideItemLayoutId(int viewType)

Provides the resource ID of the layout defining the view for an individual guided actions.

int onProvideLayoutId()

Provides the resource ID of the layout defining the host view for the list of guided actions.

boolean onUpdateActivatorView(GuidedActionsStylist.ViewHolder vh, GuidedAction action)

Performs updating GuidedAction from activator view.

void onUpdateExpandedViewHolder(GuidedActionsStylist.ViewHolder avh)

Expand or collapse GuidedActionStylist.

void openInEditMode(GuidedAction action)

Switches action to edit mode and pops up the keyboard.

void setAsButtonActions()

Choose the layout resource for button actions in onProvideLayoutId().

final void setBackKeyToCollapseActivatorView(boolean backToCollapse)

Enable or disable using BACK key to collapse GuidedAction with editable activator view.

final void setBackKeyToCollapseSubActions(boolean backToCollapse)

Enable or disable using BACK key to collapse sub actions list.

void setEditingMode(GuidedActionsStylist.ViewHolder vh, GuidedAction action, boolean editing)

This method is deprecated. This method is for internal library use only and should not be called directly.

void setExpandedViewHolder(GuidedActionsStylist.ViewHolder avh)

This method is deprecated. use expandAction(GuidedAction, boolean) and collapseAction(boolean)

void startExpandedTransition(GuidedActionsStylist.ViewHolder avh)

This method is deprecated. use expandAction(GuidedAction, boolean) and collapseAction(boolean)

Protected methods

void onEditingModeChange(GuidedActionsStylist.ViewHolder vh, boolean editing, boolean withTransition)

Called when editing mode of an ViewHolder is changed.

void onEditingModeChange(GuidedActionsStylist.ViewHolder vh, GuidedAction action, boolean editing)

This method is deprecated. Use onEditingModeChange(ViewHolder, boolean, boolean).

void setupImeOptions(GuidedActionsStylist.ViewHolder vh, GuidedAction action)

Called by onBindViewHolder(ViewHolder, GuidedAction) to setup IME options.

Inherited methods

Constants

VIEW_TYPE_DATE_PICKER

public static final int VIEW_TYPE_DATE_PICKER

ViewType for DatePicker.

Constant Value: 1 (0x00000001)

VIEW_TYPE_DEFAULT

public static final int VIEW_TYPE_DEFAULT

Default viewType that associated with default layout Id for the action item.

Constant Value: 0 (0x00000000)

Public constructors

GuidedActionsStylist

public GuidedActionsStylist ()

Public methods

collapseAction

public void collapseAction (boolean withTransition)

Collapse expanded action. Do nothing if it is in animation or there is no action expanded.

Parameters
withTransition boolean: True to run transition animation, false otherwsie.

expandAction

public void expandAction (GuidedAction action, 
                boolean withTransition)

Expand an action. Do nothing if it is in animation or there is action expanded.

Parameters
action GuidedAction: Action to expand.

withTransition boolean: True to run transition animation, false otherwsie.

getActionsGridView

public VerticalGridView getActionsGridView ()

Returns the VerticalGridView that displays the list of GuidedActions.

Returns
VerticalGridView The VerticalGridView for this presenter.

getExpandedAction

public GuidedAction getExpandedAction ()

Returns
GuidedAction Current expanded GuidedAction or null if not expanded.

getItemViewType

public int getItemViewType (GuidedAction action)

Return view type of action, each different type can have differently associated layout Id. Default implementation returns VIEW_TYPE_DEFAULT.

Parameters
action GuidedAction: The action object.

Returns
int View type that used in