summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/AllAppsList.java
diff options
context:
space:
mode:
authorJoe Onorato <joeo@android.com>2010-04-20 15:43:37 -0400
committerJoe Onorato <joeo@android.com>2010-04-21 11:43:04 -0400
commitd65d08e709ec0916446100bae0a7276d0800382f (patch)
tree20cbbd198c92e15d617987881764356f98a81111 /src/com/android/launcher2/AllAppsList.java
parentcbe7f20ad7d042bdad893aca9295a4b00aef7f54 (diff)
downloadandroid_packages_apps_Trebuchet-d65d08e709ec0916446100bae0a7276d0800382f.tar.gz
android_packages_apps_Trebuchet-d65d08e709ec0916446100bae0a7276d0800382f.tar.bz2
android_packages_apps_Trebuchet-d65d08e709ec0916446100bae0a7276d0800382f.zip
Fix race in LauncherModel that causes it to show duplicate icons.
Change-Id: I78130d6f237f476bc33a4718ca5ef245fe502857
Diffstat (limited to 'src/com/android/launcher2/AllAppsList.java')
-rw-r--r--src/com/android/launcher2/AllAppsList.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/com/android/launcher2/AllAppsList.java b/src/com/android/launcher2/AllAppsList.java
index ee89e5aca..41aa6ca1c 100644
--- a/src/com/android/launcher2/AllAppsList.java
+++ b/src/com/android/launcher2/AllAppsList.java
@@ -57,8 +57,13 @@ class AllAppsList {
/**
* Add the supplied ApplicationInfo objects to the list, and enqueue it into the
* list to broadcast when notify() is called.
+ *
+ * If the app is already in the list, doesn't add it.
*/
public void add(ApplicationInfo info) {
+ if (findActivity(data, info.componentName)) {
+ return;
+ }
data.add(info);
added.add(info);
}
@@ -190,6 +195,20 @@ class AllAppsList {
}
/**
+ * Returns whether <em>apps</em> contains <em>component</em>.
+ */
+ private static boolean findActivity(ArrayList<ApplicationInfo> apps, ComponentName component) {
+ final int N = apps.size();
+ for (int i=0; i<N; i++) {
+ final ApplicationInfo info = apps.get(i);
+ if (info.componentName.equals(component)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* Find an ApplicationInfo object for the given packageName and className.
*/
private ApplicationInfo findApplicationInfoLocked(String packageName, String className) {