java.lang.Object
com.pranavpandey.android.dynamic.support.Dynamic

public class Dynamic extends Object
Helper class to manipulate DynamicActivity and inflated views at runtime according to their implemented types.

These methods are provided to avoid any exceptions when views are replaced by the DynamicLayoutInflater or not using the DynamicActivity. So, this is the recommended way to modify the activity or any of the following view types at runtime.

See Also:
  • Constructor Details

    • Dynamic

      public Dynamic()
  • Method Details

    • loadThemeVersion

      public static String loadThemeVersion(boolean resolve)
      Load the theme styles version from the shared preferences.
      Parameters:
      resolve - true to resolve the auto theme version.
      Returns:
      The theme styles version from the shared preferences.
    • loadThemeVersion

      public static String loadThemeVersion()
      Load the theme styles version from the shared preferences.
      Returns:
      The theme styles version from the shared preferences.
      See Also:
    • saveThemeVersion

      public static void saveThemeVersion(String version)
      Save the theme styles version into the shared preferences.
      Parameters:
      version - The version to be saved.
    • isLegacyVersion

      public static boolean isLegacyVersion(int version)
      Checks whether the supplied theme styles version is legacy.
      Parameters:
      version - The version to be checked.
      Returns:
      true if the supplied theme styles version is legacy.
    • isLegacyVersion

      public static boolean isLegacyVersion(String version)
      Checks whether the supplied theme styles version is legacy.
      Parameters:
      version - The version to be checked.
      Returns:
      true if the supplied theme styles version is legacy.
    • isLegacyVersion

      public static boolean isLegacyVersion()
      Checks whether the theme styles version is legacy.
      Returns:
      true if the theme styles version is legacy.
      See Also:
    • isLegacyVersionRemote

      public static boolean isLegacyVersionRemote()
      Checks whether the application theme styles version is legacy.
      Returns:
      true if the application theme styles version is legacy.
      See Also:
    • setAllCapsIfRequired

      public static void setAllCapsIfRequired(@Nullable TextView textView, boolean allCaps)
      Set the text view all caps according to the theme styles version.
      Parameters:
      textView - The text view to be used.
      allCaps - true to set the all caps.
      See Also:
    • resolveColor

      @ColorInt public static int resolveColor(@ColorInt int background, @ColorInt int color, @ColorInt int tint, boolean backgroundAware)
      Resolves a color based on the supplied parameters.
      Parameters:
      background - The background color to be considered.
      color - The color to be resolved.
      tint - The tint color to be resolved.
      backgroundAware - true if the background aware is enabled.
      Returns:
      The resolved color based on the supplied parameters.
    • resolveTintColor

      @ColorInt public static int resolveTintColor(@ColorInt int background, @ColorInt int color, @ColorInt int tint, boolean backgroundAware)
      Resolves a color based on the supplied parameters.
      Parameters:
      background - The background color to be considered.
      color - The color to be resolved.
      tint - The tint color to be resolved.
      backgroundAware - true if the background aware is enabled.
      Returns:
      The resolved color based on the supplied parameters.
    • setColorType

      public static <T> void setColorType(@Nullable T dynamic, int colorType)
      Sets the color type for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      colorType - The color type to be set.
      See Also:
    • setBackgroundColorType

      public static <T> void setBackgroundColorType(@Nullable T dynamic, int colorType)
      Sets the background color type for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      colorType - The color type to be set.
      See Also:
    • setContrastWithColorType

      public static <T> void setContrastWithColorType(@Nullable T dynamic, int colorType)
      Sets the contrast with color type for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      colorType - The color type to be set.
      See Also:
    • setTextColorType

      public static <T> void setTextColorType(@Nullable T dynamic, int colorType)
      Sets the text color type for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      colorType - The color type to be set.
      See Also:
    • setLinkColorType

      public static <T> void setLinkColorType(@Nullable T dynamic, int colorType)
      Sets the link color type for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      colorType - The color type to be set.
      See Also:
    • setStateNormalColorType

      public static <T> void setStateNormalColorType(@Nullable T dynamic, int colorType)
      Sets the normal state color type for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      colorType - The color type to be set.
      See Also:
    • setStateSelectedColorType

      public static <T> void setStateSelectedColorType(@Nullable T dynamic, int colorType)
      Sets the selected state color type for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      colorType - The color type to be set.
      See Also:
    • setScrollBarColorType

      public static <T> void setScrollBarColorType(@Nullable T dynamic, int colorType)
      Sets the scroll bar color type for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      colorType - The color type to be set.
      See Also:
    • getColor

      @ColorInt public static <T> int getColor(@Nullable T dynamic, @ColorInt int defaultColor)
      Returns the color for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      defaultColor - The default color to be used.
      Returns:
      The color for the supplied dynamic object.
      See Also:
    • setColor

      public static <T> void setColor(@Nullable T dynamic, @ColorInt int color)
      Sets the color for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      color - The color to be set.
      See Also:
    • setColor

      public static <T> void setColor(@Nullable T dynamic)
      Refresh the color for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      See Also:
    • setBackgroundColor

      public static <T> void setBackgroundColor(@Nullable T dynamic, @ColorInt int color)
      Sets the background color for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      color - The color to be set.
      See Also:
    • setStrokeColor

      public static <T> void setStrokeColor(@Nullable T dynamic, @ColorInt int color)
      Sets the stroke color for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      color - The stroke color to be set.
    • getContrastWithColor

      @ColorInt public static <T> int getContrastWithColor(@Nullable T dynamic, @ColorInt int defaultColor)
      Returns the contrast with color for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      defaultColor - The default color to be used.
      Returns:
      The contrast color for the supplied dynamic object.
      See Also:
    • setContrastWithColor

      public static <T> void setContrastWithColor(@Nullable T dynamic, @ColorInt int color)
      Sets the contrast with color for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      color - The color to be set.
      See Also:
    • setTextColor

      public static <T> void setTextColor(@Nullable T dynamic, @ColorInt int color)
      Sets the text color for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      color - The color to be set.
      See Also:
    • setTextColor

      public static <T> void setTextColor(@Nullable T dynamic)
      Refresh the text color for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      See Also:
    • setLinkColor

      public static <T> void setLinkColor(@Nullable T dynamic, @ColorInt int color)
      Sets the link color for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      color - The color to be set.
      See Also:
    • setLinkColor

      public static <T> void setLinkColor(@Nullable T dynamic)
      Refresh the link color for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      See Also:
    • setStateNormalColor

      public static <T> void setStateNormalColor(@Nullable T dynamic, @ColorInt int color)
      Sets the normal state color for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      color - The color to be set.
      See Also:
    • setStateSelectedColor

      public static <T> void setStateSelectedColor(@Nullable T dynamic, @ColorInt int color)
      Sets the selected state color for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      color - The color to be set.
      See Also:
    • setScrollBarColor

      public static <T> void setScrollBarColor(@Nullable T dynamic, @ColorInt int color)
      Sets the scroll bar color for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      color - The color to be set.
      See Also:
    • setScrollBarColor

      public static <T> void setScrollBarColor(@Nullable T dynamic)
      Refresh the scroll bar color for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      See Also:
    • isStroke

      public static <T extends StrokeTheme<?>> boolean isStroke(@Nullable T theme)
      Checks whether the stroke is required for the supplied theme.
      Type Parameters:
      T - The type of the dynamic theme.
      Parameters:
      theme - The theme object to be used.
      Returns:
      true if the stroke is required for the supplied theme.
    • isStroke

      public static boolean isStroke()
      Checks whether the stroke is required for the current theme.
      Returns:
      true if the stroke is required for the current theme.
    • isBackgroundAware

      public static boolean isBackgroundAware(int backgroundAware)
      Checks whether the background aware functionality is enabled for the supplied value.
      Parameters:
      backgroundAware - The value to be checked.
      Returns:
      true if the supplied value changes color according to the background.
      See Also:
    • isBackgroundAware

      public static <T> boolean isBackgroundAware(@Nullable T dynamic)
      Checks whether the background aware functionality is enabled for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be checked.
      Returns:
      true if the supplied dynamic object changes color according to the background.
      See Also:
    • setBackgroundAware

      public static <T> void setBackgroundAware(@Nullable T dynamic, int backgroundAware, int contrast)
      Sets the background aware and contrast for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      backgroundAware - The background aware option to be set.
      contrast - The contrast to be set.
      See Also:
    • setBackgroundAware

      public static <V, T extends BackgroundAware<?>> void setBackgroundAware(@Nullable V dynamic, @Nullable T theme)
      Sets the background aware and contrast for the dynamic object according to the supplied theme.
      Type Parameters:
      V - The type of the dynamic object.
      T - The type of the dynamic theme.
      Parameters:
      dynamic - The dynamic object to be used.
      theme - The theme object to be used.
      See Also:
    • setBackgroundAware

      public static <T> void setBackgroundAware(@Nullable T dynamic, int backgroundAware)
      Sets the background aware for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      backgroundAware - The background aware option to be set
      See Also:
    • getContrast

      public static int getContrast(int contrast)
      Returns the resolved contrast for the supplied value.
      Parameters:
      contrast - The contrast to be resolved.
      Returns:
      The resolved contrast for the supplied value.
      See Also:
    • getContrast

      public static <T> int getContrast(@Nullable T dynamic)
      Returns the contrast for the supplied dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      Returns:
      The contrast for the supplied dynamic object.
      See Also:
    • withContrastRatio

      @ColorInt public static int withContrastRatio(@ColorInt int color, @ColorInt int contrastWith, float visibleContrast)
      Returns the contrast color according to the supplied visible contrast.
      Parameters:
      color - The color to be used.
      contrastWith - The contrast with color to be used.
      visibleContrast - The minimum ratio for the visible contrast.
      Returns:
      The contrast color according to the supplied visible contrast.
      See Also:
    • withContrastRatio

      @ColorInt public static <T extends BackgroundAware<?>> int withContrastRatio(@ColorInt int color, @ColorInt int contrastWith, @Nullable T theme)
      Returns the contrast color according to the supplied theme.
      Type Parameters:
      T - The type of the theme.
      Parameters:
      color - The color to be used.
      contrastWith - The contrast with color to be used.
      theme - The theme object to be used.
      Returns:
      The contrast color according to the supplied theme.
      See Also:
    • withContrastRatio

      @ColorInt public static int withContrastRatio(@ColorInt int color, @ColorInt int contrastWith)
      Returns the contrast color according to the applied theme.
      Parameters:
      color - The color to be used.
      contrastWith - The contrast with color to be used.
      Returns:
      The contrast color according to the applied theme.
      See Also:
    • withContrastRatio

      @ColorInt public static <T> int withContrastRatio(@ColorInt int color, @ColorInt int contrastWith, @Nullable T view)
      Returns the contrast color according to the supplied dynamic widget.
      Type Parameters:
      T - The type of the dynamic widget.
      Parameters:
      color - The color to be used.
      contrastWith - The contrast with color to be used.
      view - The view object to be used.
      Returns:
      The contrast color according to the supplied dynamic widget.
      See Also:
    • getTintColor

      @ColorInt public static int getTintColor(@ColorInt int color, float visibleContrast)
      Returns the tint color according to the supplied visible contrast.
      Parameters:
      color - The color to be used.
      visibleContrast - The minimum ratio for the visible contrast.
      Returns:
      The tint color according to the supplied visible contrast.
      See Also:
    • getTintColor

      @ColorInt public static <T extends BackgroundAware<?>> int getTintColor(@ColorInt int color, @Nullable T theme)
      Returns the tint color according to the supplied theme.
      Type Parameters:
      T - The type of the theme.
      Parameters:
      color - The color to be used.
      theme - The theme object to be used.
      Returns:
      The tint color according to the supplied theme.
      See Also:
    • getTintColor

      @ColorInt public static int getTintColor(@ColorInt int color)
      Returns the tint color according to the applied theme.
      Parameters:
      color - The color to be used.
      Returns:
      The tint color according to the applied theme.
      See Also:
    • getTintColor

      @ColorInt public static <T> int getTintColor(@ColorInt int color, @Nullable T view)
      Returns the tint color according to the supplied dynamic widget.
      Type Parameters:
      T - The type of the dynamic widget.
      Parameters:
      color - The color to be used.
      view - The view object to be used.
      Returns:
      The tint color according to the supplied dynamic widget.
      See Also:
    • withThemeOpacity

      @ColorInt public static <T extends TranslucentTheme<?>> int withThemeOpacity(@ColorInt int color, @Nullable T theme, @IntRange(from=0L,to=255L) int min)
      Sets the translucent theme opacity for the supplied color.
      Type Parameters:
      T - The type of the dynamic theme.
      Parameters:
      color - The color to be used.
      theme - The theme object to be used.
      min - The minimum opacity to be used.
      Returns:
      The color after applying the theme opacity.
      See Also:
    • withThemeOpacity

      @ColorInt public static <T extends TranslucentTheme<?>> int withThemeOpacity(@ColorInt int color, @Nullable T theme)
      Sets the translucent theme opacity for the supplied color.
      Type Parameters:
      T - The type of the dynamic theme.
      Parameters:
      color - The color to be used.
      theme - The theme object to be used.
      Returns:
      The color after applying the theme opacity.
      See Also:
    • withThemeOpacity

      @ColorInt public static int withThemeOpacity(@ColorInt int color, @IntRange(from=0L,to=255L) int min)
      Sets the translucent theme opacity for the supplied color.
      Parameters:
      color - The color to be used.
      min - The minimum opacity to be used.
      Returns:
      The color after applying the theme opacity.
      See Also:
    • withThemeOpacity

      @ColorInt public static int withThemeOpacity(@ColorInt int color)
      Sets the translucent theme opacity for the supplied color.
      Parameters:
      color - The color to be used.
      Returns:
      The color after applying the theme opacity.
      See Also:
    • withThemeOpacity

      @Nullable public static <T extends TranslucentTheme<?>> Drawable withThemeOpacity(@Nullable Drawable drawable, @Nullable T theme, @IntRange(from=0L,to=255L) int min)
      Sets the translucent theme opacity for the supplied drawable.
      Type Parameters:
      T - The type of the dynamic theme.
      Parameters:
      drawable - The drawable to be used.
      theme - The theme object to be used.
      min - The minimum opacity to be used.
      Returns:
      The drawable after applying the theme opacity.
      See Also:
    • withThemeOpacity

      @Nullable public static <T extends TranslucentTheme<?>> Drawable withThemeOpacity(@Nullable Drawable drawable, @Nullable T theme)
      Sets the translucent theme opacity for the supplied drawable.
      Type Parameters:
      T - The type of the dynamic theme.
      Parameters:
      drawable - The drawable to be used.
      theme - The theme object to be used.
      Returns:
      The drawable after applying the theme opacity.
      See Also:
    • withThemeOpacity

      @Nullable public static Drawable withThemeOpacity(@Nullable Drawable drawable, @IntRange(from=0L,to=255L) int min)
      Sets the translucent theme opacity for the supplied drawable.
      Parameters:
      drawable - The drawable to be used.
      min - The minimum opacity to be used.
      Returns:
      The drawable after applying the theme opacity.
      See Also:
    • withThemeOpacity

      @Nullable public static Drawable withThemeOpacity(@Nullable Drawable drawable)
      Sets the translucent theme opacity for the supplied drawable.
      Parameters:
      drawable - The drawable to be used.
      Returns:
      The drawable after applying the theme opacity.
      See Also:
    • setThemeType

      public static <T extends TypeTheme<?>> T setThemeType(@Nullable T theme, int type)
      Sets the type for the supplied dynamic theme object.
      Type Parameters:
      T - The type of the theme object.
      Parameters:
      theme - The theme object to be used.
      type - The theme type to be set.
      Returns:
      The theme object after setting the type.
      See Also:
    • setThemeType

      public static <T extends TypeTheme<?>> T setThemeType(@Nullable T theme, @Nullable T parent)
      Sets the type for the supplied dynamic theme object.
      Type Parameters:
      T - The type of the theme object.
      Parameters:
      theme - The theme object to be used.
      parent - The parent theme to be used.
      Returns:
      The theme object after setting the type.
      See Also:
    • setColorTypeOrColor

      public static <T> void setColorTypeOrColor(@Nullable T dynamic, int colorType, @ColorInt int color)
      Sets the color type or color for the supplied dynamic object after doing the appropriate checks.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      colorType - The color type to be set.
      color - The color to be set.
      See Also:
    • setContrastWithColorTypeOrColor

      public static <T> void setContrastWithColorTypeOrColor(@Nullable T dynamic, int colorType, @ColorInt int color)
      Sets the contrast with color type or color for the supplied dynamic object after doing the appropriate checks.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      colorType - The color type to be set.
      color - The color to be set.
      See Also:
    • setBackgroundAwareSafe

      public static <T> void setBackgroundAwareSafe(@Nullable T dynamic, int backgroundAware, int contrast)
      Sets the background aware and contrast for the supplied dynamic object after doing appropriate checks.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      backgroundAware - The background aware option to be set.
      contrast - The contrast to be set.
      See Also:
    • setBackgroundAwareSafe

      public static <T> void setBackgroundAwareSafe(@Nullable T dynamic, int backgroundAware)
      Sets the background aware for the supplied dynamic object after doing appropriate checks.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      backgroundAware - The background aware option to be set.
      See Also:
    • isDynamicColor

      public static <T extends DynamicColor<T>> boolean isDynamicColor(@Nullable T theme)
      Checks whether the dynamic theme object has dynamic colors enabled.
      Type Parameters:
      T - The type of the theme object.
      Parameters:
      theme - The theme object to be used.
      Returns:
      true if the dynamic theme object has dynamic colors enabled.
      See Also:
    • tint

      public static <T> void tint(@Nullable T dynamic, @ColorInt int color, @ColorInt int contrastWithColor)
      Tint dynamic object according to the supplied colors.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be tinted.
      color - The color to be set.
      contrastWithColor - The contrast with color to be set.
      See Also:
    • tint

      public static <T> void tint(@Nullable T dynamic, @ColorInt int color)
      Tint dynamic object according to the supplied colors.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be tinted.
      color - The color to be set.
      See Also:
    • tintBackground

      public static <T> void tintBackground(@Nullable T dynamic, @ColorInt int contrastWithColor, @ColorInt int color, boolean borderless)
      Tint background according to the supplied colors.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be tinted.
      contrastWithColor - The contrast with color to be considered.
      color - The tint color to be applied.
      borderless - true if the view is borderless.
      See Also:
    • tintBackground

      public static <T> void tintBackground(@Nullable T dynamic, @ColorInt int contrastWithColor, boolean borderless)
      Tint background according to the supplied contrast with color.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be tinted.
      contrastWithColor - The contrast with color to be considered.
      borderless - true if the view is borderless.
      See Also:
    • tintBackground

      public static <T> void tintBackground(@Nullable T dynamic, @ColorInt int contrastWithColor)
      Tint background according to the supplied contrast with color.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be tinted.
      contrastWithColor - The contrast with color to be considered.
      See Also:
    • tintBackground

      public static <T> void tintBackground(@Nullable T dynamic)
      Tint background according to the default contrast with color.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be tinted.
      See Also:
    • tintForeground

      public static <T> void tintForeground(@Nullable T dynamic, @ColorInt int contrastWithColor, @ColorInt int color, boolean borderless)
      Tint foreground according to the supplied colors.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be tinted.
      contrastWithColor - The contrast with color to be considered.
      color - The tint color to be applied.
      borderless - true if the view is borderless.
      See Also:
    • tintForeground

      public static <T> void tintForeground(@Nullable T dynamic, @ColorInt int contrastWithColor, boolean borderless)
      Tint foreground according to the supplied contrast with color.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be tinted.
      contrastWithColor - The contrast with color to be considered.
      borderless - true if the view is borderless.
      See Also:
    • tintForeground

      public static <T> void tintForeground(@Nullable T dynamic, @ColorInt int contrastWithColor)
      Tint foreground according to the supplied contrast with color.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be tinted.
      contrastWithColor - The contrast with color to be considered.
      See Also:
    • tintScrollable

      public static <T> void tintScrollable(@Nullable T dynamic, @ColorInt int contrastWithColor)
      Tint scrollable according to the supplied contrast with color.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be tinted.
      contrastWithColor - The contrast with color to be considered.
      See Also:
    • tintScrollable

      public static <T> void tintScrollable(@Nullable T dynamic)
      Tint scrollable according to the default contrast with color.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be tinted.
      See Also:
    • setOnClickListener

      public static <T> void setOnClickListener(@Nullable T dynamic, @Nullable View.OnClickListener onClickListener)
      Set on click listener for the dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      onClickListener - The click listener to be set.
      See Also:
    • setOnLongClickListener

      public static <T> void setOnLongClickListener(@Nullable T dynamic, @Nullable View.OnLongClickListener onLongClickListener)
      Set on long click listener for the dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      onLongClickListener - The long click listener to be set.
      See Also:
    • setClickable

      public static <T> void setClickable(@Nullable T dynamic, boolean clickable)
      Set the clickable property for the dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      clickable - true to make it clickable.
      See Also:
    • setLongClickable

      public static <T> void setLongClickable(@Nullable T dynamic, boolean longClickable)
      Set the long clickable property for the dynamic object.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      longClickable - true to make it long clickable.
      See Also:
    • setPreventCornerOverlap

      public static void setPreventCornerOverlap(@Nullable View view, boolean preventCornerOverlap)
      Sets the prevent corner overlap for the supplied view.
      Parameters:
      view - The view to be used.
      preventCornerOverlap - The value to be set.
      See Also:
    • setCorner

      public static void setCorner(@Nullable View view, float corner)
      Sets the corner for the supplied view.
      Parameters:
      view - The view to be used.
      corner - The corner to be set.
      See Also:
    • setCornerMin

      public static void setCornerMin(@Nullable View view, float cornerMax)
      Sets the minimum corner value for the supplied view.
      Parameters:
      view - The view to be used.
      cornerMax - The maximum corner value.
      See Also:
    • setForceElevation

      public static void setForceElevation(@Nullable View view, boolean forceElevation)
      Sets whether to force elevation for the supplied view.
      Parameters:
      view - The view to be used.
      forceElevation - true to force elevation.
    • getElevation

      public static float getElevation(@Nullable View view, float defaultElevation)
      Returns the elevation for the supplied view.
      Parameters:
      view - The view to be used.
      defaultElevation - The default elevation to be used.
      Returns:
      The elevation for the supplied view.
    • setElevation

      public static void setElevation(@Nullable View view, float elevation)
      Sets elevation for the supplied view.
      Parameters:
      view - The view to be used.
      elevation - The elevation to be set.
    • setRootBackground

      public static <T> void setRootBackground(@Nullable T dynamic, @ColorInt int color)
      Sets the background for the window or root view.
      Type Parameters:
      T - The type of the dynamic object.
      Parameters:
      dynamic - The dynamic object to be used.
      color - The color to be set.
      See Also:
    • setBackground

      public static void setBackground(@Nullable View view, @Nullable Drawable drawable)
      Set background drawable for the view.
      Parameters:
      view - The view to set the background.
      drawable - The drawable to be set.
      See Also:
    • setBackground

      public static void setBackground(@Nullable View view, @DrawableRes int drawableRes)
      Set background drawable resource for the view.
      Parameters:
      view - The view to set the background.
      drawableRes - The drawable resource to be set.
      See Also:
    • set

      public static void set(@Nullable ImageView imageView, @Nullable Drawable drawable)
      Set drawable for the image view and manage its visibility according to the data.
      Parameters:
      imageView - The image view to set the drawable.
      drawable - The drawable to be set.
    • set

      public static void set(@Nullable ImageView imageView, @Nullable Bitmap bitmap)
      Set bitmap for the image view and manage its visibility according to the data.
      Parameters:
      imageView - The image view to set the drawable.
      bitmap - The bitmap to be set.
    • setContentDescription

      public static void setContentDescription(@Nullable ImageView imageView, @Nullable String text)
      Set content description for the image view.
      Parameters:
      imageView - The image view to set the content description.
      text - The content description to be set.
    • set

      public static void set(@Nullable TextView textView, @Nullable String text)
      Set text for the text view and manage its visibility according to the data.
      Parameters:
      textView - The text view to set the text.
      text - The text to be set.
    • set

      public static void set(@Nullable TextView textView, @Nullable CharSequence text)
      Set text for the text view and manage its visibility according to the data.
      Parameters:
      textView - The text view to set the text.
      text - The text to be set.
    • set

      public static void set(@Nullable RatingBar ratingBar, float rating)
      Set rating value for the rating bar.
      Parameters:
      ratingBar - The rating bar to set the rating.
      rating - The rating value to be set.
    • setHtml

      public static void setHtml(@Nullable TextView textView, @Nullable CharSequence text)
      Set HTML text for the text view and manage its visibility according to the data.
      Parameters:
      textView - The text view to set the text.
      text - The text to be set.
    • setResource

      public static void setResource(@Nullable View view, @DrawableRes int drawableRes)
      Set drawable for the image view and manage its visibility according to the data.
      Parameters:
      view - The view to set the drawable.
      drawableRes - The drawable resource id to be set.
    • setText

      public static void setText(@Nullable TextView textView, @StringRes int stringRes)
      Set text for the text view and manage its visibility according to the data.
      Parameters:
      textView - The text view to set the text.
      stringRes - The string resource id to be set.
    • setTooltip

      public static void setTooltip(@Nullable View view, @ColorInt int backgroundColor, @ColorInt int tintColor, @Nullable CharSequence text)
      Set tooltip for the supplied view.
      Parameters:
      view - The view to be used.
      backgroundColor - The background color to be set.
      tintColor - The tint color to be set.
      text - The tooltip text to be set.
      See Also:
    • setTooltip

      public static void setTooltip(@Nullable View view, @ColorInt int backgroundColor, @ColorInt int tintColor)
      Set tooltip for the supplied view.
      Parameters:
      view - The view to be used.
      backgroundColor - The background color to be set.
      tintColor - The tint color to be set.
      See Also:
    • setTooltip

      public static void setTooltip(@Nullable View view, @Nullable CharSequence text)
      Set tooltip for the supplied view.
      Parameters:
      view - The view to be used.
      text - The tooltip text to be set.
      See Also:
    • setTooltip

      public static void setTooltip(@Nullable View view)
      Set tooltip for the supplied view.
      Parameters:
      view - The view to be used.
      See Also:
    • setClickListener

      public static void setClickListener(@Nullable View view, @Nullable View.OnClickListener clickListener, boolean visibility)
      Set click listener for the view and manage its visibility according to the data.
      Parameters:
      view - The view to set the click listener.
      clickListener - The click listener to be set.
      visibility - true to manage the visibility.
    • setClickListener

      public static void setClickListener(@Nullable View view, @Nullable View.OnClickListener clickListener)
      Set click listener for the view and manage its visibility according to the data.
      Parameters:
      view - The view to set the click listener.
      clickListener - The click listener to be set.
    • setVisibility

      public static void setVisibility(@Nullable View view, int visibility)
      Set visibility for the view.
      Parameters:
      view - The view to set the visibility.
      visibility - The visibility to be set.
    • setVisibility

      public static void setVisibility(@Nullable View view, @Nullable View base)
      Set visibility for the view according to the base view.
      Parameters:
      view - The view to set the visibility.
      base - The view to get the visibility.
    • setEnabled

      public static void setEnabled(@Nullable View view, boolean enabled)
      Set a view enabled or disabled.
      Parameters:
      view - The view to be enabled or disabled.
      enabled - true to enable the view.
    • setAlpha

      public static void setAlpha(@Nullable View view, @FloatRange(from=0.0,to=1.0) float alpha)
      Set alpha for the view.
      Parameters:
      view - The view to set the alpha.
      alpha - The alpha to be set.
    • setAppBarProgressVisible

      public static void setAppBarProgressVisible(@Nullable Context activity, boolean visible)
      Set the visibility of app bar progress for the DynamicActivity.
      Parameters:
      activity - The activity to be used.
      visible - true to show the progress bar below the app bar.
    • showSnackbar

      public static void showSnackbar(@Nullable Context activity, @Nullable CharSequence text, int duration)
      Show the snackbar for the DynamicSnackbar.
      Parameters:
      activity - The activity context to be used.
      text - The text for the snackbar.
      duration - The duration of the snackbar.

      BaseTransientBottomBar.LENGTH_SHORT, BaseTransientBottomBar.LENGTH_LONG or BaseTransientBottomBar.LENGTH_INDEFINITE.

    • showSnackbar

      public static void showSnackbar(@Nullable Context activity, @Nullable CharSequence text)
      Show the snackbar for the DynamicSnackbar.
      Parameters:
      activity - The activity context to be used.
      text - The text for the snackbar.D
    • showSnackbar

      public static void showSnackbar(@Nullable Context activity, @StringRes int stringRes, int duration)
      Show the snackbar for the DynamicSnackbar.
      Parameters:
      activity - The activity context to be used.
      stringRes - The string resource for the snackbar.
      duration - The duration of the snackbar.

      BaseTransientBottomBar.LENGTH_SHORT, BaseTransientBottomBar.LENGTH_LONG or BaseTransientBottomBar.LENGTH_INDEFINITE.

    • showSnackbar

      public static void showSnackbar(@Nullable Context activity, @StringRes int stringRes)
      Show the snackbar for the DynamicSnackbar.
      Parameters:
      activity - The activity context to be used.
      stringRes - The string resource for the snackbar.
    • setBottomSheetState

      public static void setBottomSheetState(@Nullable Context activity, int bottomSheetState)
      Sets the bottom sheet state if present for the DynamicActivity.
      Parameters:
      activity - The activity context to be used.
      bottomSheetState - The state to be set.
    • findViewById

      @Nullable public static View findViewById(@Nullable View view, @IdRes int viewId)
      Try to find view for the supplied view id.
      Parameters:
      view - The view to be used.
      viewId - The view id to be found.
      Returns:
      The view for the supplied view id.
    • setTransitionName

      public static void setTransitionName(@Nullable View view, @Nullable String name)
      Sets the transition name for the supplied view.
      Parameters:
      view - The view to be used.
      name - The transition name to be set.
    • setTransitionResultCode

      public static void setTransitionResultCode(@Nullable Context activity, int transitionResultCode)
      Sets the transition result code for the DynamicActivity.
      Parameters:
      activity - The activity context to be used.
      transitionResultCode - The transition result code to be set.
    • setTransitionPosition

      public static void setTransitionPosition(@Nullable Context activity, int transitionPosition)
      Sets the transition position for the DynamicActivity.
      Parameters:
      activity - The activity context to be used.
      transitionPosition - The transition position to be set.
    • setSearchViewListener

      public static void setSearchViewListener(@Nullable Context activity, @Nullable DynamicSearchListener searchListener)
      Sets the listener to listen the search view expand and collapse callbacks for the DynamicActivity.
      Parameters:
      activity - The activity context to be used.
      searchListener - The search listener to be set.
    • addSearchViewTextChangedListener

      public static void addSearchViewTextChangedListener(@Nullable Context activity, @Nullable TextWatcher textWatcher)
      Adds the text watcher to listen search view text changes for the DynamicActivity.
      Parameters:
      activity - The activity context to be used.
      textWatcher - The search listener to be added.
    • removeSearchViewTextChangedListener

      public static void removeSearchViewTextChangedListener(@Nullable Context activity, @Nullable TextWatcher textWatcher)
      Removes the text watcher from the search view to stop listening text changes for the DynamicActivity.
      Parameters:
      activity - The activity context to be used.
      textWatcher - The search listener to be removed.
    • expandSearchView

      public static void expandSearchView(@Nullable Context activity, boolean requestSoftInput)
      Expand search view to start searching for the DynamicActivity.
      Parameters:
      activity - The activity context to be used.
      requestSoftInput - true to request the soft input keyboard.
    • collapseSearchView

      public static void collapseSearchView(@Nullable Context activity)
      Collapse search view to stop searching for the DynamicActivity.
      Parameters:
      activity - The activity context to be used.
    • isSearchViewExpanded

      public static boolean isSearchViewExpanded(@Nullable Context activity)
      Checks whether the search view is expanded for the DynamicActivity.
      Parameters:
      activity - The activity context to be used.
      Returns:
      true if search view is expanded.
    • restoreSearchViewState

      public static void restoreSearchViewState(@Nullable Context activity)
      Restore the search view state after the configuration change for the DynamicActivity.
      Parameters:
      activity - The activity context to be used.
    • addHeader

      public static void addHeader(@Nullable Context activity, @Nullable View view, boolean removePrevious, boolean animate)
      Add header view just below the app bar for the DynamicActivity.

      Useful to add tabs or hints dynamically. Multiple views can be added and the default background will be the app bar background (theme primary color). Please check DynamicViewPagerFragment to add the tabs automatically.

      Parameters:
      activity - The activity context to be used.
      view - The view to be added in the header frame.
      removePrevious - true to remove the previously added views.
      animate - true to animate the changes.
    • addHeader

      public static void addHeader(@Nullable Context activity, @Nullable View view, boolean removePrevious)
      Add header view just below the app bar for the DynamicActivity.

      Useful to add tabs or hints dynamically. Multiple views can be added and the default background will be the app bar background (theme primary color). Please check DynamicViewPagerFragment to add the tabs automatically.

      Parameters:
      activity - The activity context to be used.
      view - The view to be added in the header frame.
      removePrevious - true to remove the previously added views.
    • addHeader

      public static void addHeader(@Nullable Context activity, @LayoutRes int layoutRes, boolean removePrevious, boolean animate)
      Add header view just below the app bar for the DynamicActivity.

      Useful to add tabs or hints dynamically. Multiple views can be added and the default background will be the app bar background (theme primary color). Please check DynamicViewPagerFragment to add the tabs automatically.

      Parameters:
      activity - The activity context to be used.
      layoutRes - The layout resource to be added in the header frame.
      removePrevious - true to remove the previously added views.
      animate - true to animate the changes.
    • addHeader

      public static void addHeader(@Nullable Context activity, @LayoutRes int layoutRes, boolean removePrevious)
      Add header view just below the app bar for the DynamicActivity.

      Useful to add tabs or hints dynamically. Multiple views can be added and the default background will be the app bar background (theme primary color). Please check DynamicViewPagerFragment to add the tabs automatically.

      Parameters:
      activity - The activity context to be used.
      layoutRes - The layout resource to be added in the header frame.
      removePrevious - true to remove the previously added views.
    • addBottomSheet

      public static void addBottomSheet(@Nullable Context activity, @Nullable View view, boolean removePrevious)
      Add view in the bottom sheet frame layout for the DynamicActivity.
      Parameters:
      activity - The activity context to be used.
      view - The view to be added in the bottom sheet.
      removePrevious - true to remove the previously added views.
    • addBottomSheet

      public static void addBottomSheet(@Nullable Context activity, @LayoutRes int layoutRes, boolean removePrevious)
      Add view in the bottom sheet frame layout for the DynamicActivity.
      Parameters:
      activity - The activity context to be used.
      layoutRes - The layout resource to be added in the bottom sheet.
      removePrevious - true to remove the previously added views.
    • startMotionActivityFromFragment

      public static void startMotionActivityFromFragment(@Nullable Context activity, @NonNull Fragment fragment, Intent intent, int requestCode, @Nullable Bundle options, boolean finish, boolean afterTransition)
      Called by Fragment.startActivityForResult() to implement its behavior for the DynamicActivity.

      It will allow Bundle options if DynamicMotion.isMotion() is enabled.

      Parameters:
      activity - The activity context to be used.
      fragment - The calling fragment.
      intent - The intent to be used.
      requestCode - The request code to be set.
      options - The intent to be set.
      finish - true to finish calling activity.
      afterTransition - true to finish the calling activity after transition.
    • startMotionActivityFromFragment

      public static void startMotionActivityFromFragment(@Nullable Context activity, @NonNull Fragment fragment, Intent intent, int requestCode, @Nullable Bundle options)
      Called by Fragment.startActivityForResult() to implement its behavior for the DynamicActivity.

      It will allow Bundle options if DynamicMotion.isMotion() is enabled.

      Parameters:
      activity - The activity context to be used.
      fragment - The calling fragment.
      intent - The intent to be used.
      requestCode - The request code to be set.
      options - The intent to be set.
    • onPageScrolled

      public static void onPageScrolled(@Nullable ViewPager.OnPageChangeListener pager, int position, float positionOffset, @Px int positionOffsetPixels)
      Parameters:
      pager - The view pager to be used.
      position - The position index of the first page currently being displayed.

      Page position+1 will be visible if positionOffset is nonzero.

      positionOffset - The value from [0, 1) indicating the offset from the page at position.
      positionOffsetPixels - The value in pixels indicating the offset from position.
    • onPageSelected

      public static void onPageSelected(@Nullable ViewPager.OnPageChangeListener pager, int position)
      Parameters:
      pager - The view pager to be used.
      position - Position index of the new selected page.
    • onPageScrollStateChanged

      public static void onPageScrollStateChanged(@Nullable ViewPager.OnPageChangeListener pager, int state)
      Parameters:
      pager - The view pager to be used.
      state - The new scroll state.
      See Also:
    • getColor

      @ColorInt public static <T, V> int getColor(@Nullable Tutorial<T,V> tutorial, @ColorInt int defaultColor)
      Call Tutorial.getColor() method for the Tutorial.
      Type Parameters:
      T - The type of the tutorial.
      V - The type of the tutorial fragment.
      Parameters:
      tutorial - The dynamic tutorial to be used.
      defaultColor - The default color for the background.
      Returns:
      The background color for the supplied tutorial.
    • getTintColor

      @ColorInt public static <T, V> int getTintColor(@Nullable Tutorial<T,V> tutorial, @ColorInt int defaultColor)
      Call Tutorial.getTintColor() method for the Tutorial.
      Type Parameters:
      T - The type of the tutorial.
      V - The type of the tutorial fragment.
      Parameters:
      tutorial - The dynamic tutorial to be used.
      defaultColor - The default tint color.
      Returns:
      The tint color for the supplied tutorial.
    • onColorChanged

      public static <T, V> void onColorChanged(@Nullable Tutorial<T,V> tutorial, @ColorInt int color, @ColorInt int tint)
      Type Parameters:
      T - The type of the tutorial.
      V - The type of the tutorial fragment.
      Parameters:
      tutorial - The dynamic tutorial to be used.
      color - The color of the background.
      tint - The tint color used by the tutorial.
    • onSetPadding

      public static <T, V> void onSetPadding(@Nullable Tutorial<T,V> tutorial, int left, int top, int right, int bottom)
      Type Parameters:
      T - The type of the tutorial.
      V - The type of the tutorial fragment.
      Parameters:
      tutorial - The dynamic tutorial to be used.
      left - The left padding supplied by the container.
      top - The top padding supplied by the container.
      right - The right padding supplied by the container.
      bottom - The bottom padding supplied by the container.
    • getAppShortcutIcon

      @Nullable public static Icon getAppShortcutIcon(@NonNull Context context, @DrawableRes int drawableRes, @IdRes int backgroundId, @IdRes int foregroundId, boolean theme)
      Returns the app shortcut icon according to the dynamic theme.
      Parameters:
      context - The context to be used.
      drawableRes - The drawable resource to be used.
      backgroundId - The background id to be used.
      foregroundId - The foreground id to be used.
      theme - true to use Theme.ColorType.PRIMARY as background.
      Returns:
      The app shortcut icon according to the dynamic theme.