Class NavigationBackStack

  • All Implemented Interfaces:
    android.os.Parcelable

    
    public class NavigationBackStack<T>
     implements Parcelable
                        

    Manages a browser like backstack of items.

    • Constructor Detail

      • NavigationBackStack

        NavigationBackStack()
    • Method Detail

      • removeBackStackListener

         void removeBackStackListener(@NonNull() NavigationBackStack.BackStackListener<T> backStackListener)

        Removes the back stack listener. Upon calling this method the listener will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Adding null is not allowed,and will result in an exception.

        Parameters:
        backStackListener - BackStackListener that should be removed.
      • clearBackStackListeners

         void clearBackStackListeners()

        Removes all previously added back stack listeners. To remove just one listener use removeBackStackListener. Upon calling this method no listeners will be notified of any changes.

      • addItem

         void addItem(@NonNull() T item)

        Adds a new item depending on if we are currently going back or forward.

        Parameters:
        item - The item to add.
      • replaceWith

         void replaceWith(@NonNull() NavigationBackStack<T> navigationHistory)

        Replaces navigation back stack with another instance. Keeps all back stack listeners.

        Parameters:
        navigationHistory - New navigation back stack.
      • goBack

         void goBack()

        Goes back one step, or does nothing if the stack is already empty.

      • goForward

         void goForward()

        Goes forward one step, or does nothing if the stack is already empty.

      • resetForwardList

         void resetForwardList()

        Removes all forward navigation items.