diff options
author | Tony Wickham <twickham@google.com> | 2017-02-09 08:28:52 -0800 |
---|---|---|
committer | Tony Wickham <twickham@google.com> | 2017-02-09 10:30:06 -0800 |
commit | 580edcf529b0755f2bba442e97dd02d8cdad3b82 (patch) | |
tree | a1a89d2bfdd7c9eb67527bd207df81a7e3c1120a /src/com/android/launcher3/Utilities.java | |
parent | 4b20e0c312d7a6f5f0a65e8bada74eeb52c15bc0 (diff) | |
download | android_packages_apps_Trebuchet-580edcf529b0755f2bba442e97dd02d8cdad3b82.tar.gz android_packages_apps_Trebuchet-580edcf529b0755f2bba442e97dd02d8cdad3b82.tar.bz2 android_packages_apps_Trebuchet-580edcf529b0755f2bba442e97dd02d8cdad3b82.zip |
Create a singleton HashMap instead of using Collections.singleton()
The Set returned by Collections.singleton() doesn't support all
operations, causing crashes in certain situations (namely, whenever
a notification is updated rather than added or removed).
Change-Id: Ie104b7f99c4a32db5f1f7e43ec3775d34dc26ce1
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 267cb2aaa..be3297c06 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; @@ -648,4 +649,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; + } } |