Class DynamicAppWidgetUtils
java.lang.Object
com.pranavpandey.android.dynamic.support.util.DynamicAppWidgetUtils
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault alpha value for disabled or inactive views.static final intDefault alpha value for enabled or active views. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcleanupPreferences(String preferences) Cleanup preferences for an app widget provider when all of its widget instances have been deleted.static voiddeleteWidgetSettings(String preferences, int appWidgetId) Remove a preference for an app widget widget provider according to the widget id.static StringloadWidgetSettings(String preferences, int appWidgetId, String value) Load a string preference for an app widget widget provider according to the widget id.static voidsaveWidgetSettings(String preferences, int appWidgetId, String value) Save a string preference for an app widget widget provider according to the widget id.
-
Field Details
-
ALPHA_ACTION_ENABLED
public static final int ALPHA_ACTION_ENABLEDDefault alpha value for enabled or active views.- See Also:
-
ALPHA_ACTION_DISABLED
public static final int ALPHA_ACTION_DISABLEDDefault 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
ClassCastExceptionif there is a preference with this name that is not a string.
-
deleteWidgetSettings
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
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.
-