Class ActionMenuFragment

java.lang.Object
androidx.fragment.app.Fragment
com.vuzix.hud.actionmenu.ActionMenuFragment
All Implemented Interfaces:
android.content.ComponentCallbacks, android.view.View.OnCreateContextMenuListener, android.view.View.OnKeyListener, android.view.View.OnTouchListener, androidx.activity.result.ActivityResultCaller, androidx.lifecycle.HasDefaultViewModelProviderFactory, androidx.lifecycle.LifecycleOwner, androidx.lifecycle.ViewModelStoreOwner, androidx.savedstate.SavedStateRegistryOwner

public class ActionMenuFragment extends androidx.fragment.app.Fragment implements android.view.View.OnKeyListener, android.view.View.OnTouchListener
  • Nested Class Summary

    Nested classes/interfaces inherited from class androidx.fragment.app.Fragment

    androidx.fragment.app.Fragment.InstantiationException, androidx.fragment.app.Fragment.SavedState
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    Determines if the action menu is shown always or only after user interaction.
    protected void
    closeActionMenu(boolean animate)
    Programmatically closes the action menu.
    boolean
    dispatchKeyEvent(android.view.KeyEvent event)
     
    protected int
    Determines the gravity of the action menu.
    android.content.Context
     
    protected int
    Determines the default action item that will be selected when the action menu displays.
    protected int
    Allows subclasses to specify the default item in the menu based on id.
    protected int
    getMenuItemIndex(android.view.MenuItem item, boolean visibleOnly)
    Retrieve the index in the menu for a specific MenuItem
    protected void
    Declare that the action menu has changed, so should be recreated.
    protected void
    onActionItemFocused(android.view.MenuItem item)
    This hook is called whenever the focused item in your action menu changes.
    protected boolean
    onActionItemSelected(android.view.MenuItem item)
    This hook is called whenever an item in your action menu is selected.
    protected void
    Called when the action menu is dismissed via a two-finger tap gesture.
    final boolean
    onActionMenuItemSelected(android.view.MenuItem item)
     
    void
    onCreate(android.os.Bundle savedInstanceState)
     
    protected boolean
    onCreateActionMenu(android.view.Menu menu)
    Initialize the contents of the Activity's action menu.
    void
    onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater)
     
    boolean
    onKey(android.view.View v, int keyCode, android.view.KeyEvent event)
     
    void
     
    protected boolean
    onPrepareActionMenu(android.view.Menu menu)
    Prepare the Screen's action menu to be displayed.
    void
     
    void
    onSaveInstanceState(android.os.Bundle outState)
     
    boolean
    onTouch(android.view.View v, android.view.MotionEvent event)
     
    protected void
    Programmatically opens the action menu.
    protected void
    openActionMenu(boolean animate)
    Programmatically opens the action menu.
    protected void
    setCurrentMenuItem(android.view.MenuItem item, boolean animate)
    Programmatically set a specific MenuItem to be the currently selected item.
    protected void
    setSpeechEnabled(boolean enable)
    Sets whether action menu items will automatically be registered with the speech recognition service.

    Methods inherited from class androidx.fragment.app.Fragment

    dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getDefaultViewModelProviderFactory, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLayoutInflater, getLifecycle, getLoaderManager, getParentFragment, getParentFragmentManager, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSavedStateRegistry, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, getViewLifecycleOwner, getViewLifecycleOwnerLiveData, getViewModelStore, hashCode, hasOptionsMenu, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isMenuVisible, isRemoving, isResumed, isStateSaved, isVisible, onActivityCreated, onActivityResult, onAttach, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateView, onDestroy, onDestroyOptionsMenu, onDestroyView, onDetach, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, onStart, onStop, onViewCreated, onViewStateRestored, postponeEnterTransition, postponeEnterTransition, registerForActivityResult, registerForActivityResult, registerForContextMenu, requestPermissions, requireActivity, requireArguments, requireContext, requireFragmentManager, requireHost, requireParentFragment, requireView, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenu

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ActionMenuFragment

      public ActionMenuFragment()
  • Method Details

    • onCreate

      public void onCreate(@Nullable android.os.Bundle savedInstanceState)
      Overrides:
      onCreate in class androidx.fragment.app.Fragment
    • onResume

      public void onResume()
      Overrides:
      onResume in class androidx.fragment.app.Fragment
    • onPause

      public void onPause()
      Overrides:
      onPause in class androidx.fragment.app.Fragment
    • onSaveInstanceState

      public void onSaveInstanceState(@NonNull android.os.Bundle outState)
      Overrides:
      onSaveInstanceState in class androidx.fragment.app.Fragment
    • onCreateOptionsMenu

      public void onCreateOptionsMenu(@NonNull android.view.Menu menu, @NonNull android.view.MenuInflater inflater)
      Overrides:
      onCreateOptionsMenu in class androidx.fragment.app.Fragment
    • onActionMenuItemSelected

      public final boolean onActionMenuItemSelected(android.view.MenuItem item)
    • setSpeechEnabled

      protected void setSpeechEnabled(boolean enable)
      Sets whether action menu items will automatically be registered with the speech recognition service. By default this is true and subclasses can choose to opt-out by calling setSpeechEnabled(false) during onCreate().
      Parameters:
      enable - true to enable automatic speech recognition registration, false otherwise
    • openActionMenu

      protected void openActionMenu()
      Programmatically opens the action menu. If the action menu is already open, this method does nothing.
    • openActionMenu

      protected void openActionMenu(boolean animate)
      Programmatically opens the action menu. If the action menu is already open, this method does nothing.
      Parameters:
      animate - true to animate the menu, false to show it without animation
    • onActionItemFocused

      protected void onActionItemFocused(android.view.MenuItem item)
      This hook is called whenever the focused item in your action menu changes. The default implementation does nothing. Subclasses can override to perform logic as the focus changes.
      Parameters:
      item - The menu item that has focus.
    • onActionItemSelected

      protected boolean onActionItemSelected(android.view.MenuItem item)
      This hook is called whenever an item in your action menu is selected. The default implementation simply returns false to have the normal processing happen. You can use this method for any items for which you would like to do processing without those other facilities.

      Derived classes should call through to the base class for it to perform the default menu handling.

      You will need to call this super method in a derived class before checking the state of a checkable ActionMenuItem within this function. This ensures the ActionMenuItem properly animates.

      Parameters:
      item - The menu item that was selected.
      Returns:
      boolean Return false to allow normal menu processing to proceed, true to consume it here.
      See Also:
    • onActionMenuClosed

      protected void onActionMenuClosed()
      Called when the action menu is dismissed via a two-finger tap gesture. This method is called after the action menu pop-up is dismissed. Developers may override this function to receive this callback within their application.
    • invalidateActionMenu

      protected void invalidateActionMenu()
      Declare that the action menu has changed, so should be recreated. The onCreateActionMenu(Menu) method will be called the next time it needs to be displayed. If the action menu is currently being displayed, the menu will be rebuilt immediately.
    • onCreateActionMenu

      protected boolean onCreateActionMenu(android.view.Menu menu)
      Initialize the contents of the Activity's action menu. You should place your menu items in to menu.

      This is only called once, the first time the action menu is displayed. To update the menu every time it is displayed, see onPrepareActionMenu(android.view.Menu).

      The default implementation populates the menu with a back menu item. Deriving classes should always call through to the base implementation.

      You can safely hold on to menu (and any items created from it), making modifications to it as desired, until the next time onCreateOptionsMenu() is called.

      When you add items to the menu, you can implement the Activity's onActionItemSelected(android.view.MenuItem) method to handle them there.

      Parameters:
      menu - The action menu in which you place your items.
      Returns:
      You must return true for the menu to be displayed; if you return false it will not be shown.
      See Also:
    • onPrepareActionMenu

      protected boolean onPrepareActionMenu(android.view.Menu menu)
      Prepare the Screen's action menu to be displayed. This is called right before the menu is shown, every time it is shown. You can use this method to efficiently enable/disable items or otherwise dynamically modify the contents.
      Parameters:
      menu - The options menu as last shown or first initialized by onCreateActionMenu().
      Returns:
      You must return true for the menu to be displayed; if you return false it will not be shown.
      See Also:
    • getDefaultAction

      protected int getDefaultAction()
      Determines the default action item that will be selected when the action menu displays. By default it is the first item in the menu. Override this method to change the behavior.
      Returns:
      the index of the default menu item to select
    • getDefaultActionId

      protected int getDefaultActionId()
      Allows subclasses to specify the default item in the menu based on id. This will be called before getDefaultAction. If this method returns a non-zero value, that will be used as the default ID, otherwise, getDefaultAction will be called as a fallback.
      Returns:
      the id the default menu item to select
    • alwaysShowActionMenu

      protected boolean alwaysShowActionMenu()
      Determines if the action menu is shown always or only after user interaction. Subclasses may override to change behavior
      Returns:
      true to always show action menu, false to only show after user interaction
    • getActionMenuGravity

      protected int getActionMenuGravity()
      Determines the gravity of the action menu. By default, the action menu appears at the bottom of the screen. Override this method to change behavior.
      Returns:
      a Gravity constant
    • setCurrentMenuItem

      protected void setCurrentMenuItem(android.view.MenuItem item, boolean animate)
      Programmatically set a specific MenuItem to be the currently selected item. If the specified item is not found or is not currently visible, nothing will change
      Parameters:
      item - The MenuItem to select
      animate - whether or not to animate the selection change
    • getMenuItemIndex

      protected int getMenuItemIndex(android.view.MenuItem item, boolean visibleOnly)
      Retrieve the index in the menu for a specific MenuItem
      Parameters:
      item - The MenuItem to look for
      visibleOnly - if true, only the currently visible menu items will be searched
      Returns:
      The index of the specified MenuItem. If the item was not found, or visibleOnly was true, and the desired MenuItem is not currently visible, -1 will be returned.
    • closeActionMenu

      protected void closeActionMenu(boolean animate)
      Programmatically closes the action menu. If the action menu is already closed, this method does nothing. If the action menu has been specified to always be shown, this method does nothing.
      Parameters:
      animate - true to animate the menu, false to show it without animation
    • getContext

      public android.content.Context getContext()
      Overrides:
      getContext in class androidx.fragment.app.Fragment
    • dispatchKeyEvent

      public boolean dispatchKeyEvent(android.view.KeyEvent event)
    • onKey

      public boolean onKey(android.view.View v, int keyCode, android.view.KeyEvent event)
      Specified by:
      onKey in interface android.view.View.OnKeyListener
    • onTouch

      public boolean onTouch(android.view.View v, android.view.MotionEvent event)
      Specified by:
      onTouch in interface android.view.View.OnTouchListener