Class Toaster


  • public final class Toaster
    extends Object
    Utility for displaying toast notifications with progress bars on the page.
    Author:
    Andrea "Stock" Stocchero
    • Field Detail

      • MAXIMUM_OPEN_ITEMS

        public static final int MAXIMUM_OPEN_ITEMS
        Maximum amount of open and shown toasts.
        See Also:
        Constant Field Values
    • Method Detail

      • get

        public static Toaster get()
        Singleton object to get the toaster instance
        Returns:
        toaster instance.
      • getDefaults

        public DefaultToastOptions getDefaults()
        Returns the defaults of toast.
        Returns:
        the defaults of toast
      • show

        public Status show​(String... label)
        Creates and shows a toast configured by the passed options.
        Parameters:
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(List<String> label)
        Creates and shows a toast configured by the passed options.
        Parameters:
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(IsToastType type,
                           String... label)
        Creates and shows a toast configured by the passed options.
        Parameters:
        type - type of the toast
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(IsToastType type,
                           List<String> label)
        Creates and shows a toast configured by the passed options.
        Parameters:
        type - type of the toast
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(ToastOptions options,
                           String... label)
        Creates and shows a toast configured by the passed options.
        Parameters:
        options - configuration of the toast to show
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(ToastOptions options,
                           List<String> label)
        Creates and shows a toast configured by the passed options.
        Parameters:
        options - configuration of the toast to show
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(String title,
                           String label)
        Creates and shows a toast with title and label.
        Parameters:
        title - title of the toast
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(String title,
                           List<String> label)
        Creates and shows a toast with title and label.
        Parameters:
        title - title of the toast
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(IsToastType type,
                           String title,
                           String label)
        Creates and shows a toast with title and label.
        Parameters:
        type - type of the toast
        title - title of the toast
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(IsToastType type,
                           String title,
                           List<String> label)
        Creates and shows a toast with title and label.
        Parameters:
        type - type of the toast
        title - title of the toast
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(ToastOptions options,
                           String title,
                           String label)
        Creates and shows a toast configured by the passed options.
        Parameters:
        options - configuration of the toast to show
        title - title of the toast
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(ToastOptions options,
                           String title,
                           List<String> label)
        Creates and shows a toast configured by the passed options.
        Parameters:
        options - configuration of the toast to show
        title - title of the toast
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(Map<String,​Object> context,
                           String... label)
        Creates and shows a toast configured by the passed options.
        Parameters:
        context - context of toast execution
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(Map<String,​Object> context,
                           List<String> label)
        Creates and shows a toast configured by the passed options.
        Parameters:
        context - context of toast execution
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(Map<String,​Object> context,
                           IsToastType type,
                           String... label)
        Creates and shows a toast configured by the passed options.
        Parameters:
        context - context of toast execution
        type - type of the toast
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(Map<String,​Object> context,
                           IsToastType type,
                           List<String> label)
        Creates and shows a toast configured by the passed options.
        Parameters:
        context - context of toast execution
        type - type of the toast
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(Map<String,​Object> context,
                           ToastOptions options,
                           String... label)
        Creates and shows a toast configured by the passed options.
        Parameters:
        context - context of toast execution
        options - configuration of the toast to show
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(Map<String,​Object> context,
                           ToastOptions options,
                           List<String> label)
        Creates and shows a toast configured by the passed options.
        Parameters:
        context - context of toast execution
        options - configuration of the toast to show
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(Map<String,​Object> context,
                           String title,
                           String label)
        Creates and shows a toast with title and label.
        Parameters:
        context - context of toast execution
        title - title of the toast
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(Map<String,​Object> context,
                           String title,
                           List<String> label)
        Creates and shows a toast with title and label.
        Parameters:
        context - context of toast execution
        title - title of the toast
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(Map<String,​Object> context,
                           IsToastType type,
                           String title,
                           String label)
        Creates and shows a toast with title and label.
        Parameters:
        context - context of toast execution
        type - type of the toast
        title - title of the toast
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(Map<String,​Object> context,
                           IsToastType type,
                           String title,
                           List<String> label)
        Creates and shows a toast with title and label.
        Parameters:
        context - context of toast execution
        type - type of the toast
        title - title of the toast
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(Map<String,​Object> context,
                           ToastOptions options,
                           String title,
                           String label)
        Creates and shows a toast configured by the passed options.
        Parameters:
        context - context of toast execution
        options - configuration of the toast to show
        title - title of the toast
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • show

        public Status show​(Map<String,​Object> context,
                           ToastOptions options,
                           String title,
                           List<String> label)
        Creates and shows a toast configured by the passed options.
        Parameters:
        context - context of toast execution
        options - configuration of the toast to show
        title - title of the toast
        label - label of the toast
        Returns:
        the status if the toast has been shown
      • getMaxHistoryItems

        public int getMaxHistoryItems()
        Returns the maximum amount of toast items you want to maintain in the history.
        Returns:
        the maximum amount of toast items you want to maintain in the history
      • setMaxHistoryItems

        public void setMaxHistoryItems​(int maxHistoryItems)
        Sets the maximum amount of toast items you want to maintain in the history.
        Parameters:
        maxHistoryItems - the maximum amount of toast items you want to maintain in the history
      • getHistoryItems

        public List<ToastItem> getHistoryItems()
        Returns the list of toast items in the history.
        Returns:
        the list of toast items in the history
      • getMaxOpenItemsPolicy

        public MaximumOpenItemsPolicy getMaxOpenItemsPolicy()
        Returns the policy to apply when the maximum amount of open items is reached.
        Returns:
        the policy to apply when the maximum amount of open items is reached
      • setMaxOpenItemsPolicy

        public void setMaxOpenItemsPolicy​(MaximumOpenItemsPolicy policy)
        Sets the policy to apply when the maximum amount of open items is reached.
        Parameters:
        policy - the policy to apply when the maximum amount of open items is reached
      • getMaxOpenItems

        public int getMaxOpenItems()
        Returns the maximum amount of open toast items you want to maintain on DOM.
        Returns:
        the maximum amount of open toast items you want to maintain on DOM
      • setMaxOpenItems

        public void setMaxOpenItems​(int maxOpenItems)
        Sets the maximum amount of open toast items you want to maintain on DOM.
        Maximum value is 100.
        Parameters:
        maxOpenItems - the maximum amount of open toast items you want to maintain on DOM
      • hideOpenItems

        public void hideOpenItems()
        Closes all items which are opened and not closed yet.
        All toast items in queued will be removed.
      • hideOpenItems

        public void hideOpenItems​(boolean clearQueue)
        Closes all items which are opened and not closed yet.
        If the passed argument is true, it clears also the queue, without showing the items.
        Parameters:
        clearQueue - if true, it clears also the queue, without showing the items.