Class DynamicHint


  • public class DynamicHint
    extends java.lang.Object
    Helper class to display themed cheat sheets with icon and text by using Toast.

    If no color is supplied, it will display default hint based on the Android support library.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  DynamicHint.Config
      Configuration class to customise the DynamicHint attributes.
    • Constructor Summary

      Constructors 
      Constructor Description
      DynamicHint()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static android.widget.Toast make​(android.content.Context context, java.lang.CharSequence text)
      Make a standard toast that just contains a text view.
      static android.widget.Toast make​(android.content.Context context, java.lang.CharSequence text, int duration)
      Make a standard toast that just contains a text view.
      static android.widget.Toast make​(android.content.Context context, java.lang.CharSequence text, android.graphics.drawable.Drawable icon)
      Make a error toast with icon and the text.
      static android.widget.Toast make​(android.content.Context context, java.lang.CharSequence text, android.graphics.drawable.Drawable icon, int duration)
      Make a themed toast with icon and the text.
      static android.widget.Toast make​(android.content.Context context, java.lang.CharSequence text, android.graphics.drawable.Drawable icon, java.lang.Integer tintColor, java.lang.Integer backgroundColor)
      Make a themed toast with text, icon, background and the tint color.
      static android.widget.Toast make​(android.content.Context context, java.lang.CharSequence text, android.graphics.drawable.Drawable icon, java.lang.Integer tintColor, java.lang.Integer backgroundColor, int duration)
      Make a themed toast with text, icon, background and the tint color.
      static android.widget.Toast make​(android.content.Context context, java.lang.CharSequence text, java.lang.Integer tintColor, java.lang.Integer backgroundColor)
      Make a themed toast with icon and the text.
      static android.widget.Toast make​(android.content.Context context, java.lang.CharSequence text, java.lang.Integer tintColor, java.lang.Integer backgroundColor, int duration)
      Make a themed toast with text, background and the tint color.
      static android.widget.Toast makeError​(android.content.Context context, java.lang.CharSequence text)
      Make a error toast with icon and the text.
      static android.widget.Toast makeError​(android.content.Context context, java.lang.CharSequence text, int duration)
      Make a error toast with icon and the text.
      static android.widget.Toast makeSuccess​(android.content.Context context, java.lang.CharSequence text)
      Make a success toast with icon and the text.
      static android.widget.Toast makeSuccess​(android.content.Context context, java.lang.CharSequence text, int duration)
      Make a success toast with icon and the text.
      static android.widget.Toast makeWarning​(android.content.Context context, java.lang.CharSequence text)
      Make a warning toast with icon and the text.
      static android.widget.Toast makeWarning​(android.content.Context context, java.lang.CharSequence text, int duration)
      Make a warning toast with icon and the text.
      static void show​(android.view.View anchor, android.widget.Toast toast)
      Show toast above or below according to the anchor view position.
      static void show​(android.view.View anchor, android.widget.Toast toast, int offset)
      Show toast above or below according to the anchor view position.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DynamicHint

        public DynamicHint()
    • Method Detail

      • make

        @NonNull
        public static android.widget.Toast make​(@NonNull
                                                android.content.Context context,
                                                @Nullable
                                                java.lang.CharSequence text)
        Make a standard toast that just contains a text view.

        The toast duration will be Toast.LENGTH_SHORT.

        Parameters:
        context - The context to use.
        text - The text to show. Can be formatted text.
        Returns:
        The toast with the supplied parameters.

        Use Toast.show() to display the toast.

      • make

        @NonNull
        public static android.widget.Toast make​(@NonNull
                                                android.content.Context context,
                                                @Nullable
                                                java.lang.CharSequence text,
                                                int duration)
        Make a standard toast that just contains a text view.
        Parameters:
        context - The context to use.
        text - The text to show. Can be formatted text.
        duration - The duration for the toast, either Toast.LENGTH_SHORT or Toast.LENGTH_LONG.
        Returns:
        The toast with the supplied parameters.

        Use Toast.show() to display the toast.

      • makeError

        @NonNull
        public static android.widget.Toast makeError​(@NonNull
                                                     android.content.Context context,
                                                     @Nullable
                                                     java.lang.CharSequence text)
        Make a error toast with icon and the text.

        The toast duration will be Toast.LENGTH_SHORT.

        Parameters:
        context - The context to use.
        text - The text to show. Can be formatted text.
        Returns:
        The toast with the supplied parameters.

        Use Toast.show() to display the toast.

      • makeError

        @NonNull
        public static android.widget.Toast makeError​(@NonNull
                                                     android.content.Context context,
                                                     @Nullable
                                                     java.lang.CharSequence text,
                                                     int duration)
        Make a error toast with icon and the text.
        Parameters:
        context - The context to use.
        text - The text to show. Can be formatted text.
        duration - The duration for the toast, either Toast.LENGTH_SHORT or Toast.LENGTH_LONG.
        Returns:
        The toast with the supplied parameters.

        Use Toast.show() to display the toast.

      • makeSuccess

        @NonNull
        public static android.widget.Toast makeSuccess​(@NonNull
                                                       android.content.Context context,
                                                       @Nullable
                                                       java.lang.CharSequence text)
        Make a success toast with icon and the text.

        The toast duration will be Toast.LENGTH_SHORT.

        Parameters:
        context - The context to use.
        text - The text to show. Can be formatted text.
        Returns:
        The toast with the supplied parameters.

        Use Toast.show() to display the toast.

      • makeSuccess

        @NonNull
        public static android.widget.Toast makeSuccess​(@NonNull
                                                       android.content.Context context,
                                                       @Nullable
                                                       java.lang.CharSequence text,
                                                       int duration)
        Make a success toast with icon and the text.
        Parameters:
        context - The context to use.
        text - The text to show. Can be formatted text.
        duration - The duration for the toast, either Toast.LENGTH_SHORT or Toast.LENGTH_LONG.
        Returns:
        The toast with the supplied parameters.

        Use Toast.show() to display the toast.

      • makeWarning

        @NonNull
        public static android.widget.Toast makeWarning​(@NonNull
                                                       android.content.Context context,
                                                       @Nullable
                                                       java.lang.CharSequence text)
        Make a warning toast with icon and the text.

        The toast duration will be Toast.LENGTH_SHORT.

        Parameters:
        context - The context to use.
        text - The text to show. Can be formatted text.
        Returns:
        The toast with the supplied parameters.

        Use Toast.show() to display the toast.

      • makeWarning

        @NonNull
        public static android.widget.Toast makeWarning​(@NonNull
                                                       android.content.Context context,
                                                       @Nullable
                                                       java.lang.CharSequence text,
                                                       int duration)
        Make a warning toast with icon and the text.
        Parameters:
        context - The context to use.
        text - The text to show. Can be formatted text.
        duration - The duration for the toast, either Toast.LENGTH_SHORT or Toast.LENGTH_LONG.
        Returns:
        The toast with the supplied parameters.

        Use Toast.show() to display the toast.

      • make

        @NonNull
        public static android.widget.Toast make​(@NonNull
                                                android.content.Context context,
                                                @Nullable
                                                java.lang.CharSequence text,
                                                @Nullable
                                                android.graphics.drawable.Drawable icon)
        Make a error toast with icon and the text.

        The toast duration will be Toast.LENGTH_SHORT.

        Parameters:
        context - The context to use.
        text - The text to show. Can be formatted text.
        icon - The toast icon to show.
        Returns:
        The toast with the supplied parameters.

        Use Toast.show() to display the toast.

      • make

        @NonNull
        public static android.widget.Toast make​(@NonNull
                                                android.content.Context context,
                                                @Nullable
                                                java.lang.CharSequence text,
                                                @Nullable
                                                android.graphics.drawable.Drawable icon,
                                                int duration)
        Make a themed toast with icon and the text.
        Parameters:
        context - The context to use.
        text - The text to show. Can be formatted text.
        icon - The toast icon to show.
        duration - The duration for the toast, either Toast.LENGTH_SHORT or Toast.LENGTH_LONG.
        Returns:
        The toast with the supplied parameters.

        Use Toast.show() to display the toast.

      • make

        @NonNull
        public static android.widget.Toast make​(@NonNull
                                                android.content.Context context,
                                                @Nullable
                                                java.lang.CharSequence text,
                                                @Nullable @ColorInt
                                                java.lang.Integer tintColor,
                                                @Nullable @ColorInt
                                                java.lang.Integer backgroundColor)
        Make a themed toast with icon and the text.

        The toast duration will be Toast.LENGTH_SHORT.

        Parameters:
        context - The context to use.
        text - The text to show. Can be formatted text.
        tintColor - The toast tint color based on the toast background.

        It will automatically check for the contrast to provide best visibility.

        backgroundColor - The toast background color.
        Returns:
        The toast with the supplied parameters.

        Use Toast.show() to display the toast.

      • make

        @NonNull
        public static android.widget.Toast make​(@NonNull
                                                android.content.Context context,
                                                @Nullable
                                                java.lang.CharSequence text,
                                                @Nullable @ColorInt
                                                java.lang.Integer tintColor,
                                                @Nullable @ColorInt
                                                java.lang.Integer backgroundColor,
                                                int duration)
        Make a themed toast with text, background and the tint color.

        The toast duration will be Toast.LENGTH_SHORT.

        Parameters:
        context - The context to use.
        text - The text to show. Can be formatted text.
        tintColor - The toast tint color based on the toast background.

        It will automatically check for the contrast to provide best visibility.

        backgroundColor - The toast background color.
        duration - The duration for the toast, either Toast.LENGTH_SHORT or Toast.LENGTH_LONG.
        Returns:
        The toast with the supplied parameters.

        Use Toast.show() to display the toast.

      • make

        @NonNull
        public static android.widget.Toast make​(@NonNull
                                                android.content.Context context,
                                                @Nullable
                                                java.lang.CharSequence text,
                                                @Nullable
                                                android.graphics.drawable.Drawable icon,
                                                @Nullable @ColorInt
                                                java.lang.Integer tintColor,
                                                @Nullable @ColorInt
                                                java.lang.Integer backgroundColor)
        Make a themed toast with text, icon, background and the tint color.

        The toast duration will be Toast.LENGTH_SHORT.

        Parameters:
        context - The context to use.
        text - The text to show. Can be formatted text.
        icon - The toast icon to show.
        tintColor - The toast tint color based on the toast background.

        It will automatically check for the contrast to provide best visibility.

        backgroundColor - The toast background color.
        Returns:
        The toast with the supplied parameters.

        Use Toast.show() to display the toast.

      • make

        @NonNull
        public static android.widget.Toast make​(@NonNull
                                                android.content.Context context,
                                                @Nullable
                                                java.lang.CharSequence text,
                                                @Nullable
                                                android.graphics.drawable.Drawable icon,
                                                @Nullable @ColorInt
                                                java.lang.Integer tintColor,
                                                @Nullable @ColorInt
                                                java.lang.Integer backgroundColor,
                                                int duration)
        Make a themed toast with text, icon, background and the tint color.
        Parameters:
        context - The context to use.
        text - The text to show. Can be formatted text.
        icon - The toast icon to show.
        tintColor - The toast tint color based on the toast background.

        It will automatically check for the contrast to provide best visibility.

        backgroundColor - The toast background color.
        duration - The duration for the toast, either Toast.LENGTH_SHORT or Toast.LENGTH_LONG.
        Returns:
        The toast with the supplied parameters.

        Use Toast.show() to display the toast.

      • show

        public static void show​(@NonNull
                                android.view.View anchor,
                                @NonNull
                                android.widget.Toast toast)
        Show toast above or below according to the anchor view position.
        Parameters:
        anchor - The anchor view to show the toast.
        toast - The toast to be displayed.
      • show

        public static void show​(@NonNull
                                android.view.View anchor,
                                @NonNull
                                android.widget.Toast toast,
                                int offset)
        Show toast above or below according to the anchor view position.
        Parameters:
        anchor - The anchor view to show the toast.
        toast - The toast to be displayed.
        offset - The toast vertical offset in dips.