summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2010-09-29 18:03:07 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-09-29 18:03:07 -0700
commit4e2affec16d53bd5943c5738233384526a25f915 (patch)
treec077d9c8467bb0832b67b7eb5e2b282752d54c40
parentea7ee3f4d31b92828df005d021cf482f6332514a (diff)
parent6364f2bbe5254b4274f3feffc48f4259eacc205e (diff)
downloadframeworks_base-4e2affec16d53bd5943c5738233384526a25f915.zip
frameworks_base-4e2affec16d53bd5943c5738233384526a25f915.tar.gz
frameworks_base-4e2affec16d53bd5943c5738233384526a25f915.tar.bz2
Merge "Fixing issue where notifyDataSetChanged was not properly being called while not loading items."
-rw-r--r--core/java/android/widget/AdapterViewAnimator.java2
-rw-r--r--core/java/android/widget/RemoteViewsAdapter.java80
-rw-r--r--core/java/android/widget/StackView.java1
3 files changed, 34 insertions, 49 deletions
diff --git a/core/java/android/widget/AdapterViewAnimator.java b/core/java/android/widget/AdapterViewAnimator.java
index f245933..b4efb92 100644
--- a/core/java/android/widget/AdapterViewAnimator.java
+++ b/core/java/android/widget/AdapterViewAnimator.java
@@ -339,7 +339,7 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
return new ViewGroup.LayoutParams(0, 0);
}
- private void refreshChildren() {
+ void refreshChildren() {
for (int i = mCurrentWindowStart; i <= mCurrentWindowEnd; i++) {
int index = modulo(i, mNumActiveViews);
diff --git a/core/java/android/widget/RemoteViewsAdapter.java b/core/java/android/widget/RemoteViewsAdapter.java
index 27f5ad4..23d6758 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() {
diff --git a/core/java/android/widget/StackView.java b/core/java/android/widget/StackView.java
index 56dc5cd..40a5b29 100644
--- a/core/java/android/widget/StackView.java
+++ b/core/java/android/widget/StackView.java
@@ -776,6 +776,7 @@ public class StackView extends AdapterViewAnimator {
mWhichChild = 0;
showOnly(mWhichChild, true, true);
+ refreshChildren();
}
final int childCount = getChildCount();