summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2012-07-23 14:29:15 -0700
committerAdam Cohen <adamcohen@google.com>2012-07-23 14:29:15 -0700
commita13a2f2a7bd0550d1ad973f760ff25e1a4137c43 (patch)
treecd7b43b0015ec0e0692e9deb9f6ad11f6873ac6e /src
parent36e6c5bb232f3a876753b91fb9ec604cda8664a5 (diff)
downloadandroid_packages_apps_Trebuchet-a13a2f2a7bd0550d1ad973f760ff25e1a4137c43.tar.gz
android_packages_apps_Trebuchet-a13a2f2a7bd0550d1ad973f760ff25e1a4137c43.tar.bz2
android_packages_apps_Trebuchet-a13a2f2a7bd0550d1ad973f760ff25e1a4137c43.zip
Fixing issue where defered unbind was running after synchronous bind. (Bug 6858398, Bug 6863181)
Change-Id: I03dc3ae18528901cc88c79638a8495c1ab8d61af
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/DeferredHandler.java12
-rw-r--r--src/com/android/launcher2/LauncherModel.java5
2 files changed, 17 insertions, 0 deletions
diff --git a/src/com/android/launcher2/DeferredHandler.java b/src/com/android/launcher2/DeferredHandler.java
index 930da56aa..b7e48b130 100644
--- a/src/com/android/launcher2/DeferredHandler.java
+++ b/src/com/android/launcher2/DeferredHandler.java
@@ -98,6 +98,18 @@ public class DeferredHandler {
}
}
+ /** Runs all queued Runnables from the calling thread. */
+ public void flush() {
+ LinkedList<Runnable> queue = new LinkedList<Runnable>();
+ synchronized (mQueue) {
+ queue.addAll(mQueue);
+ mQueue.clear();
+ }
+ for (Runnable r : queue) {
+ r.run();
+ }
+ }
+
void scheduleNextLocked() {
if (mQueue.size() > 0) {
Runnable peek = mQueue.getFirst();
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index d4b7f7652..ab29fc688 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -918,6 +918,11 @@ public class LauncherModel extends BroadcastReceiver {
// data structures, we can't allow any other thread to touch that data, but because
// this call is synchronous, we can get away with not locking).
+ // The LauncherModel is static in the LauncherApplication and mHandler may have queued
+ // operations from the previous activity. We need to ensure that all queued operations
+ // are executed before any synchronous binding work is done.
+ mHandler.flush();
+
// Divide the set of loaded items into those that we are binding synchronously, and
// everything else that is to be bound normally (asynchronously).
bindWorkspace(synchronousBindPage);