summaryrefslogtreecommitdiff
path: root/core/java/android/widget/RemoteViewsAdapter.java
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2010-09-29 11:14:30 -0700
committerWinson Chung <winsonc@google.com>2010-09-29 18:01:15 -0700
commit6364f2bbe5254b4274f3feffc48f4259eacc205e (patch)
treee4d05556c194885f6c71fc5cd409a60bdbc0cb0d /core/java/android/widget/RemoteViewsAdapter.java
parent5f421a56786cf7c71159280c51bd4280f5199cfb (diff)
Fixing issue where notifyDataSetChanged was not properly being called while not loading items.
Change-Id: I46bb30a5a95576891f11873b214f5c760f5d1757
Diffstat (limited to 'core/java/android/widget/RemoteViewsAdapter.java')
-rw-r--r--core/java/android/widget/RemoteViewsAdapter.java80
1 files changed, 32 insertions, 48 deletions
diff --git a/core/java/android/widget/RemoteViewsAdapter.java b/core/java/android/widget/RemoteViewsAdapter.java
index 27f5ad479e12..23d67588ca05 100644
--- a/core/java/android/widget/RemoteViewsAdapter.java
+++ b/core/java/android/widget/RemoteViewsAdapter.java
@@ -601,19 +601,6 @@ public class RemoteViewsAdapter extends BaseAdapter {
mWorkerQueue.post(new Runnable() {
@Override
public void run() {
- boolean isDataDirty = false;
-
- // If the data set has changed, then notify the remote factory so that it can
- // update its internals first.
- final RemoteViewsMetaData metaData = mCache.getMetaData();
- synchronized (metaData) {
- isDataDirty = metaData.isDataDirty;
- metaData.isDataDirty = false;
- }
- if (isDataDirty) {
- completeNotifyDataSetChanged();
- }
-
// Get the next index to load
int position = -1;
synchronized (mCache) {
@@ -843,46 +830,43 @@ public class RemoteViewsAdapter extends BaseAdapter {
}
public void notifyDataSetChanged() {
- final RemoteViewsMetaData metaData = mCache.getMetaData();
- synchronized (metaData) {
- // Set flag to calls the remote factory's onDataSetChanged() on the next worker loop
- metaData.isDataDirty = true;
- }
-
- // Note: we do not call super.notifyDataSetChanged() until the RemoteViewsFactory has had
- // a chance to update itself, and return new meta data associated with the new data. After
- // which completeNotifyDataSetChanged() is called.
- }
-
- private void completeNotifyDataSetChanged() {
- // Complete the actual notifyDataSetChanged() call initiated earlier
- if (mServiceConnection.isConnected()) {
- IRemoteViewsFactory factory = mServiceConnection.getRemoteViewsFactory();
- try {
- factory.onDataSetChanged();
- } catch (Exception e) {
- Log.e(TAG, "Error in updateNotifyDataSetChanged(): " + e.getMessage());
-
- // Return early to prevent from further being notified (since nothing has changed)
- return;
- }
- }
+ mWorkerQueue.post(new Runnable() {
+ @Override
+ public void run() {
+ // Complete the actual notifyDataSetChanged() call initiated earlier
+ if (mServiceConnection.isConnected()) {
+ IRemoteViewsFactory factory = mServiceConnection.getRemoteViewsFactory();
+ try {
+ factory.onDataSetChanged();
+ } catch (Exception e) {
+ Log.e(TAG, "Error in updateNotifyDataSetChanged(): " + e.getMessage());
+
+ // Return early to prevent from further being notified (since nothing has
+ // changed)
+ return;
+ }
+ }
- // Flush the cache so that we can reload new items from the service
- synchronized (mCache) {
- mCache.reset();
- }
+ // Flush the cache so that we can reload new items from the service
+ synchronized (mCache) {
+ mCache.reset();
+ }
- // Re-request the new metadata (only after the notification to the factory)
- updateMetaData();
+ // Re-request the new metadata (only after the notification to the factory)
+ updateMetaData();
- // Propagate the notification back to the base adapter
- mMainQueue.post(new Runnable() {
- @Override
- public void run() {
- superNotifyDataSetChanged();
+ // Propagate the notification back to the base adapter
+ mMainQueue.post(new Runnable() {
+ @Override
+ public void run() {
+ superNotifyDataSetChanged();
+ }
+ });
}
});
+
+ // Note: we do not call super.notifyDataSetChanged() until the RemoteViewsFactory has had
+ // a chance to update itself and return new meta data associated with the new data.
}
private void superNotifyDataSetChanged() {