Class DynamicAppWidgetUtils

java.lang.Object
com.pranavpandey.android.dynamic.support.util.DynamicAppWidgetUtils

public class DynamicAppWidgetUtils extends Object
Helper class to perform various app widget operations. It will be used internally by the DynamicAppWidgetProvider but can also be used by the other components.
  • Field Details

    • ALPHA_ACTION_ENABLED

      public static final int ALPHA_ACTION_ENABLED
      Default alpha value for enabled or active views.
      See Also:
    • ALPHA_ACTION_DISABLED

      public static final int ALPHA_ACTION_DISABLED
      Default alpha value for disabled or inactive views.
      See Also:
  • Constructor Details

    • DynamicAppWidgetUtils

      public DynamicAppWidgetUtils()
  • Method Details

    • saveWidgetSettings

      public static void saveWidgetSettings(@NonNull String preferences, int appWidgetId, @Nullable String value)
      Save a string preference for an app widget widget provider according to the widget id.
      Parameters:
      preferences - The preference name to store the key.
      appWidgetId - The app widget id to create or find the preference key.
      value - The value for the preference.
    • loadWidgetSettings

      @Nullable public static String loadWidgetSettings(@NonNull String preferences, int appWidgetId, @Nullable String value)
      Load a string preference for an app widget widget provider according to the widget id.
      Parameters:
      preferences - The preference name to store the key.
      appWidgetId - The app widget id to find the preference key.
      value - The default value for the preference.
      Returns:
      Returns the preference value if it exists, or the default value.

      Throws ClassCastException if there is a preference with this name that is not a string.

    • deleteWidgetSettings

      public static void deleteWidgetSettings(@NonNull String preferences, int appWidgetId)
      Remove a preference for an app widget widget provider according to the widget id.
      Parameters:
      preferences - The preference name to remove the key.
      appWidgetId - The app widget id to find the preference key.
    • cleanupPreferences

      public static void cleanupPreferences(@NonNull String preferences)
      Cleanup preferences for an app widget provider when all of its widget instances have been deleted.
      Parameters:
      preferences - The preference name to cleanup the preferences.