diff options
| author | Adam Cohen <adamcohen@google.com> | 2011-07-28 14:59:54 -0700 |
|---|---|---|
| committer | Adam Cohen <adamcohen@google.com> | 2011-07-28 15:00:38 -0700 |
| commit | 2148d43eb23c702e834c93ae427f822f32d280a2 (patch) | |
| tree | d4ea0936890a0b56db11a427030a8bd6a80b462c /core/java/android/appwidget/AppWidgetHostView.java | |
| parent | 6c71b63dc64d35d62a7e0bc3bed4e207ed7cf8b4 (diff) | |
Fixing widget notifyDataSetChanged() not getting called, issue 5092676
Change-Id: I61a034a77c0c9d07aba71bfabe7a0864ce92c2e9
Diffstat (limited to 'core/java/android/appwidget/AppWidgetHostView.java')
| -rw-r--r-- | core/java/android/appwidget/AppWidgetHostView.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/core/java/android/appwidget/AppWidgetHostView.java b/core/java/android/appwidget/AppWidgetHostView.java index d8adc6cc1cc0..960d7fbba7e1 100644 --- a/core/java/android/appwidget/AppWidgetHostView.java +++ b/core/java/android/appwidget/AppWidgetHostView.java @@ -38,6 +38,7 @@ import android.widget.BaseAdapter; import android.widget.FrameLayout; import android.widget.RemoteViews; import android.widget.TextView; +import android.widget.RemoteViewsAdapter.RemoteAdapterConnectionCallback; /** * Provides the glue to show AppWidget views. This class offers automatic animation @@ -276,6 +277,11 @@ public class AppWidgetHostView extends FrameLayout { if (adapter instanceof BaseAdapter) { BaseAdapter baseAdapter = (BaseAdapter) adapter; baseAdapter.notifyDataSetChanged(); + } else if (adapter == null && adapterView instanceof RemoteAdapterConnectionCallback) { + // If the adapter is null, it may mean that the RemoteViewsAapter has not yet + // connected to its associated service, and hence the adapter hasn't been set. + // In this case, we need to defer the notify call until it has been set. + ((RemoteAdapterConnectionCallback) adapterView).deferNotifyDataSetChanged(); } } } |
