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;
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;
+ }
}
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;
} else {
notificationWasAdded = badgeInfo.addNotificationKeyIfNotExists(notificationKey);
}
- updateLauncherIconBadges(Collections.singleton(postedPackageUserKey), notificationWasAdded);
+ updateLauncherIconBadges(Utilities.singletonHashSet(postedPackageUserKey),
+ notificationWasAdded);
}
@Override
if (oldBadgeInfo.getNotificationCount() == 0) {
mPackageUserToBadgeInfos.remove(removedPackageUserKey);
}
- updateLauncherIconBadges(Collections.singleton(removedPackageUserKey));
+ updateLauncherIconBadges(Utilities.singletonHashSet(removedPackageUserKey));
PopupContainerWithArrow openContainer = PopupContainerWithArrow.getOpen(mLauncher);
if (openContainer != null) {