Package icyllis.modernui.view

# Interface ActionMode.Callback

All Known Subinterfaces:
  `AbsListView.MultiChoiceModeListener`

Enclosing class:
  `ActionMode`

public static interface ActionMode.Callback
Callback interface for action modes. Supplied to `View.startActionMode(Callback)`, a Callback configures and handles events raised by a user's interaction with an action mode.

An action mode's lifecycle is as follows:

- `onCreateActionMode(ActionMode, Menu)` once on initial creation
- `onPrepareActionMode(ActionMode, Menu)` after creation and any time the `ActionMode` is invalidated
- `onActionItemClicked(ActionMode, MenuItem)` any time a contextual action button is clicked
- `onDestroyActionMode(ActionMode)` when the action mode is closed

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `onActionItemClicked(ActionMode mode, MenuItem item)`
  Called to report a user click on an action button.
  `boolean`
  `onCreateActionMode(ActionMode mode, Menu menu)`
  Called when action mode is first created.
  `void`
  `onDestroyActionMode(ActionMode mode)`
  Called when an action mode is about to be exited and destroyed.
  `default void`
  `onGetContentRect(ActionMode mode, View view, Rect outRect)`
  Extension of `ActionMode.Callback` to provide content rect information.
  `boolean`
  `onPrepareActionMode(ActionMode mode, Menu menu)`
  Called to refresh an action mode's action menu whenever it is invalidated.

- ## Method Details

  - ### onCreateActionMode

    boolean onCreateActionMode(ActionMode mode, Menu menu)
    Called when action mode is first created. The menu supplied will be used to generate action buttons for the action mode.
    Parameters:
      `mode` - ActionMode being created
      `menu` - Menu used to populate action buttons
    Returns:
      true if the action mode should be created, false if entering this mode should be aborted.

  - ### onPrepareActionMode

    boolean onPrepareActionMode(ActionMode mode, Menu menu)
    Called to refresh an action mode's action menu whenever it is invalidated.
    Parameters:
      `mode` - ActionMode being prepared
      `menu` - Menu used to populate action buttons
    Returns:
      true if the menu or action mode was updated, false otherwise.

  - ### onActionItemClicked

    boolean onActionItemClicked(ActionMode mode, MenuItem item)
    Called to report a user click on an action button.
    Parameters:
      `mode` - The current ActionMode
      `item` - The item that was clicked
    Returns:
      true if this callback handled the event, false if the standard MenuItem invocation should continue.

  - ### onDestroyActionMode

    void onDestroyActionMode(ActionMode mode)
    Called when an action mode is about to be exited and destroyed.
    Parameters:
      `mode` - The current ActionMode being destroyed

  - ### onGetContentRect

    default void onGetContentRect(ActionMode mode, View view, Rect outRect)
    Extension of `ActionMode.Callback` to provide content rect information. This is required for ActionModes with dynamic positioning such as the ones with type `ActionMode.TYPE_FLOATING` to ensure the positioning doesn't obscure app content. Called when an ActionMode needs to be positioned on screen, potentially occluding view content. Note this may be called on a per-frame basis.
    Parameters:
      `mode` - The ActionMode that requires positioning.
      `view` - The View that originated the ActionMode, in whose coordinates the Rect should be provided.
      `outRect` - The Rect to be populated with the content position. Use this to specify where the content in your app lives within the given view. This will be used to avoid occluding the given content Rect with the created ActionMode.