Class DynamicThemeResolver

java.lang.Object
com.pranavpandey.android.dynamic.support.theme.DynamicThemeResolver
All Implemented Interfaces:
DynamicResolver

public class DynamicThemeResolver extends Object implements DynamicResolver
A DynamicResolver to resolve the theme.
  • Constructor Details

    • DynamicThemeResolver

      public DynamicThemeResolver(@Nullable DynamicTheme theme)
      Constructor to initialize an object of this class.
      Parameters:
      theme - The dynamic theme instance for this resolver.

      If null, then it will try to use the default instance.

    • DynamicThemeResolver

      public DynamicThemeResolver(@Nullable DynamicTheme theme, @Nullable DynamicColors colors, @Nullable DynamicColors colorsLocal)
      Constructor to initialize an object of this class.
      Parameters:
      theme - The dynamic theme instance for this resolver.

      If null, then it will try to use the default instance.

      colors - The dynamic colors for this resolver.

      Pass null, to use the default implementation.

      colorsLocal - The local dynamic colors for this resolver.

      Pass null, to use the default implementation.

  • Method Details

    • getTheme

      @NonNull public DynamicTheme getTheme()
      Description copied from interface: DynamicResolver
      Get the dynamic theme instance used by this resolver.
      Specified by:
      getTheme in interface DynamicResolver
      Returns:
      The dynamic theme instance used by this resolver.
    • getColors

      @NonNull public DynamicColors getColors(boolean resolve)
      Description copied from interface: DynamicResolver
      Get the dynamic colors used by this resolver.
      Specified by:
      getColors in interface DynamicResolver
      Parameters:
      resolve - true to resolve the dynamic colors.
      Returns:
      The dynamic colors used by this resolver.
    • getColors

      @NonNull public DynamicColors getColors()
      Description copied from interface: DynamicResolver
      Get the dynamic colors used by this resolver.
      Specified by:
      getColors in interface DynamicResolver
      Returns:
      The dynamic colors used by this resolver.
    • isSystemNightMode

      public boolean isSystemNightMode()
      Description copied from interface: DynamicResolver
      Checks whether the system night mode is enabled.
      Specified by:
      isSystemNightMode in interface DynamicResolver
      Returns:
      true if the system night mode is enabled.
    • resolveSystemColor

      public int resolveSystemColor(boolean isNight)
      Description copied from interface: DynamicResolver
      Resolves system color according to the API level and night mode.
      Specified by:
      resolveSystemColor in interface DynamicResolver
      Parameters:
      isNight - true to resolve the night color.
      Returns:
      The system UI color according to the Android version and night mode.
    • isNight

      public boolean isNight()
      Description copied from interface: DynamicResolver
      Checks for the night time.

      Useful to apply themes based on the day and night.

      Specified by:
      isNight in interface DynamicResolver
      Returns:
      true if it is night.
    • isNight

      public boolean isNight(int theme)
      Description copied from interface: DynamicResolver
      Checks for the night time according to the supplied value.

      Useful to apply themes based on the day and night.

      Specified by:
      isNight in interface DynamicResolver
      Parameters:
      theme - The integer value of the theme.
      Returns:
      true if it is night.
    • isNight

      public boolean isNight(String theme)
      Description copied from interface: DynamicResolver
      Checks for the night time according to the supplied value.

      Useful to apply themes based on the day and night.

      Specified by:
      isNight in interface DynamicResolver
      Parameters:
      theme - The string value of the theme.
      Returns:
      true if it is night.
    • getNightTimeStart

      @NonNull public Date getNightTimeStart()
      Description copied from interface: DynamicResolver
      Returns start time for the night theme.
      Specified by:
      getNightTimeStart in interface DynamicResolver
      Returns:
      The start time for the night theme.
    • getNightTimeEnd

      @NonNull public Date getNightTimeEnd()
      Description copied from interface: DynamicResolver
      Returns end time for the night theme.
      Specified by:
      getNightTimeEnd in interface DynamicResolver
      Returns:
      The end time for the night theme.
    • resolveNightTheme

      public boolean resolveNightTheme(int theme, int implementation, boolean data)
      Description copied from interface: DynamicResolver
      Resolves night theme according to the selected implementation.
      Specified by:
      resolveNightTheme in interface DynamicResolver
      Parameters:
      theme - The app theme to resolve the auto night theme.
      implementation - The implementation for the night theme.
      data - true to resolve based on the theme data.
      Returns:
      true if the night theme is enabled according to the selected implementation.
    • resolveNightTheme

      public boolean resolveNightTheme(String theme, String implementation, boolean data)
      Description copied from interface: DynamicResolver
      Resolves night theme according to the selected implementation.
      Specified by:
      resolveNightTheme in interface DynamicResolver
      Parameters:
      theme - The app theme to resolve the auto night theme.
      implementation - The implementation for the night theme.
      data - true to resolve based on the theme data.
      Returns:
      true if the night theme is enabled according to the selected implementation.
    • resolveAppTheme

      public int resolveAppTheme(int theme, int night, boolean data)
      Description copied from interface: DynamicResolver
      Resolves current theme according to the supplied implementation.
      Specified by:
      resolveAppTheme in interface DynamicResolver
      Parameters:
      theme - The theme to be resolved.
      night - The implementation for the night theme.
      data - true to resolve based on the theme data.
      Returns:
      The resolved theme constant according to the supplied implementation.
      See Also:
    • resolveAppTheme

      public int resolveAppTheme(String theme, String night, boolean data)
      Description copied from interface: DynamicResolver
      Resolves current theme according to the supplied implementation.
      Specified by:
      resolveAppTheme in interface DynamicResolver
      Parameters:
      theme - The theme to be resolved.
      night - The implementation for the night theme.
      data - true to resolve based on the theme data.
      Returns:
      The resolved theme constant according to the supplied implementation.
      See Also: