summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-02-09 21:59:46 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-02-09 21:59:47 +0000
commitc6444eef17c472629b17bd7ca0da4bcb95cf5959 (patch)
treee9ac69fa8c2081bb8122c6ec21ab4e2bff2282f9 /src/com/android/launcher3
parentc9f844db2b54e17c562736f9fdb54202c2ad6d1a (diff)
parent580edcf529b0755f2bba442e97dd02d8cdad3b82 (diff)
downloadandroid_packages_apps_Trebuchet-c6444eef17c472629b17bd7ca0da4bcb95cf5959.tar.gz
android_packages_apps_Trebuchet-c6444eef17c472629b17bd7ca0da4bcb95cf5959.tar.bz2
android_packages_apps_Trebuchet-c6444eef17c472629b17bd7ca0da4bcb95cf5959.zip
Merge "Create a singleton HashMap instead of using Collections.singleton()" into ub-launcher3-master
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r--src/com/android/launcher3/Utilities.java11
-rw-r--r--src/com/android/launcher3/popup/PopupDataProvider.java6
2 files changed, 15 insertions, 2 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 839b5e85c..78774f3b8 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -60,6 +60,7 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.Executor;
@@ -652,4 +653,14 @@ public final class Utilities {
throw new RuntimeException(e);
}
}
+
+ /**
+ * Returns a HashSet with a single element. We use this instead of Collections.singleton()
+ * because HashSet ensures all operations, such as remove, are supported.
+ */
+ public static <T> HashSet<T> singletonHashSet(T elem) {
+ HashSet<T> hashSet = new HashSet<>(1);
+ hashSet.add(elem);
+ return hashSet;
+ }
}
diff --git a/src/com/android/launcher3/popup/PopupDataProvider.java b/src/com/android/launcher3/popup/PopupDataProvider.java
index 4f3b8a6b1..c754fda99 100644
--- a/src/com/android/launcher3/popup/PopupDataProvider.java
+++ b/src/com/android/launcher3/popup/PopupDataProvider.java
@@ -22,6 +22,7 @@ import android.util.Log;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
+import com.android.launcher3.Utilities;
import com.android.launcher3.badge.BadgeInfo;
import com.android.launcher3.notification.NotificationInfo;
import com.android.launcher3.notification.NotificationListener;
@@ -68,7 +69,8 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
} else {
notificationWasAdded = badgeInfo.addNotificationKeyIfNotExists(notificationKey);
}
- updateLauncherIconBadges(Collections.singleton(postedPackageUserKey), notificationWasAdded);
+ updateLauncherIconBadges(Utilities.singletonHashSet(postedPackageUserKey),
+ notificationWasAdded);
}
@Override
@@ -78,7 +80,7 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
if (oldBadgeInfo.getNotificationCount() == 0) {
mPackageUserToBadgeInfos.remove(removedPackageUserKey);
}
- updateLauncherIconBadges(Collections.singleton(removedPackageUserKey));
+ updateLauncherIconBadges(Utilities.singletonHashSet(removedPackageUserKey));
PopupContainerWithArrow openContainer = PopupContainerWithArrow.getOpen(mLauncher);
if (openContainer != null) {