Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6444eef authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Create a singleton HashMap instead of using Collections.singleton()"...

Merge "Create a singleton HashMap instead of using Collections.singleton()" into ub-launcher3-master
parents c9f844db 580edcf5
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -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;
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -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) {