diff options
author | Adam Cohen <adamcohen@google.com> | 2010-08-15 18:20:04 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2010-08-17 10:29:35 -0700 |
commit | 2dd2197805edb4d9547b143deef2226413218f4c (patch) | |
tree | 9ac6869e60bc425c276bce8c309aecdb1ebb450e /core/java/android/appwidget/AppWidgetManager.java | |
parent | 0c316eeb437a0ac1d6840690be643d1a553f0b23 (diff) | |
download | frameworks_base-2dd2197805edb4d9547b143deef2226413218f4c.zip frameworks_base-2dd2197805edb4d9547b143deef2226413218f4c.tar.gz frameworks_base-2dd2197805edb4d9547b143deef2226413218f4c.tar.bz2 |
-> Enabled partial updates to app widgets through AppWidgetManager.
Partial updates are not cached by the AppWidgetService.
-> Added the ability to insert commands with no parameters into
RemoteViews objects.
-> Added showNext() and showPrevious() methods to RemoteViews.
-> Made showNext() / showPrevious() of AdapterViewFlipper remotable.
Change-Id: Ic5491bb374424a54728c4ca92b94b1f00dfb87ff
Diffstat (limited to 'core/java/android/appwidget/AppWidgetManager.java')
-rw-r--r-- | core/java/android/appwidget/AppWidgetManager.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/core/java/android/appwidget/AppWidgetManager.java b/core/java/android/appwidget/AppWidgetManager.java index 5ee721f..b83642b 100644 --- a/core/java/android/appwidget/AppWidgetManager.java +++ b/core/java/android/appwidget/AppWidgetManager.java @@ -233,6 +233,10 @@ public class AppWidgetManager { /** * Set the RemoteViews to use for the specified appWidgetIds. * + * Note that the RemoteViews parameter will be cached by the AppWidgetService, and hence should + * contain a complete representation of the widget. For performing partial widget updates, see + * {@link #partiallyUpdateAppWidget(int[], RemoteViews)}. + * * <p> * It is okay to call this method both inside an {@link #ACTION_APPWIDGET_UPDATE} broadcast, * and outside of the handler. @@ -253,6 +257,10 @@ public class AppWidgetManager { /** * Set the RemoteViews to use for the specified appWidgetId. * + * Note that the RemoteViews parameter will be cached by the AppWidgetService, and hence should + * contain a complete representation of the widget. For performing partial widget updates, see + * {@link #partiallyUpdateAppWidget(int, RemoteViews)}. + * * <p> * It is okay to call this method both inside an {@link #ACTION_APPWIDGET_UPDATE} broadcast, * and outside of the handler. @@ -266,6 +274,59 @@ public class AppWidgetManager { } /** + * Perform an incremental update or command on the widget(s) specified by appWidgetIds. + * + * This update differs from {@link #updateAppWidget(int[], RemoteViews)} in that the + * RemoteViews object which is passed is understood to be an incomplete representation of the + * widget, and hence is not cached by the AppWidgetService. Note that because these updates are + * not cached, any state that they modify that is not restored by restoreInstanceState will not + * persist in the case that the widgets are restored using the cached version in + * AppWidgetService. + * + * Use with {@link RemoteViews#showNext(int)}, {@link RemoteViews#showPrevious(int)}, + * {@link RemoteViews#setScrollPosition(int, int)} and similar commands. + * + * <p> + * It is okay to call this method both inside an {@link #ACTION_APPWIDGET_UPDATE} broadcast, + * and outside of the handler. + * This method will only work when called from the uid that owns the AppWidget provider. + * + * @param appWidgetIds The AppWidget instances for which to set the RemoteViews. + * @param views The RemoteViews object containing the incremental update / command. + */ + public void partiallyUpdateAppWidget(int[] appWidgetIds, RemoteViews views) { + try { + sService.partiallyUpdateAppWidgetIds(appWidgetIds, views); + } catch (RemoteException e) { + throw new RuntimeException("system server dead?", e); + } + } + + /** + * Perform an incremental update or command on the widget specified by appWidgetId. + * + * This update differs from {@link #updateAppWidget(int, RemoteViews)} in that the RemoteViews + * object which is passed is understood to be an incomplete representation of the widget, and + * hence is not cached by the AppWidgetService. Note that because these updates are not cached, + * any state that they modify that is not restored by restoreInstanceState will not persist in + * the case that the widgets are restored using the cached version in AppWidgetService. + * + * Use with {@link RemoteViews#showNext(int)}, {@link RemoteViews#showPrevious(int)}, + * {@link RemoteViews#setScrollPosition(int, int)} and similar commands. + * + * <p> + * It is okay to call this method both inside an {@link #ACTION_APPWIDGET_UPDATE} broadcast, + * and outside of the handler. + * This method will only work when called from the uid that owns the AppWidget provider. + * + * @param appWidgetId The AppWidget instance for which to set the RemoteViews. + * @param views The RemoteViews object containing the incremental update / command. + */ + public void partiallyUpdateAppWidget(int appWidgetId, RemoteViews views) { + partiallyUpdateAppWidget(new int[] { appWidgetId }, views); + } + + /** * Set the RemoteViews to use for all AppWidget instances for the supplied AppWidget provider. * * <p> |