From a9af1dfdd28a70b2668f201eedf25265b946adb5 Mon Sep 17 00:00:00 2001 From: Isira Seneviratne Date: Fri, 5 Aug 2022 06:54:03 +0530 Subject: [PATCH] Applied code review changes. --- .../player/notification/NotificationConstants.java | 2 +- .../newpipe/player/notification/NotificationUtil.java | 2 +- .../settings/custom/NotificationActionsPreference.java | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/notification/NotificationConstants.java b/app/src/main/java/org/schabi/newpipe/player/notification/NotificationConstants.java index 7015e0717..89bf0b22a 100644 --- a/app/src/main/java/org/schabi/newpipe/player/notification/NotificationConstants.java +++ b/app/src/main/java/org/schabi/newpipe/player/notification/NotificationConstants.java @@ -180,7 +180,7 @@ public final class NotificationConstants { if (compactSlot == Integer.MAX_VALUE) { // settings not yet populated, return default values - return SLOT_COMPACT_DEFAULTS; + return new ArrayList<>(SLOT_COMPACT_DEFAULTS); } // a negative value (-1) is set when the user does not want a particular compact slot diff --git a/app/src/main/java/org/schabi/newpipe/player/notification/NotificationUtil.java b/app/src/main/java/org/schabi/newpipe/player/notification/NotificationUtil.java index ef225b14e..1a91bc66d 100644 --- a/app/src/main/java/org/schabi/newpipe/player/notification/NotificationUtil.java +++ b/app/src/main/java/org/schabi/newpipe/player/notification/NotificationUtil.java @@ -99,7 +99,7 @@ public final class NotificationUtil { // build the compact slot indices array (need code to convert from Integer... because Java) final List compactSlotList = NotificationConstants.getCompactSlotsFromPreferences( player.getContext(), player.getPrefs(), nonNothingSlotCount); - final int[] compactSlots = compactSlotList.stream().mapToInt(i -> i).toArray(); + final int[] compactSlots = compactSlotList.stream().mapToInt(Integer::intValue).toArray(); builder.setStyle(new androidx.media.app.NotificationCompat.MediaStyle() .setMediaSession(player.getMediaSessionManager().getSessionToken()) diff --git a/app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java b/app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java index 1101f410d..1770685e4 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java +++ b/app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java @@ -34,7 +34,6 @@ import org.schabi.newpipe.util.DeviceUtils; import org.schabi.newpipe.util.ThemeHelper; import org.schabi.newpipe.views.FocusOverlayView; -import java.util.ArrayList; import java.util.List; import java.util.stream.IntStream; @@ -76,9 +75,10 @@ public class NotificationActionsPreference extends Preference { //////////////////////////////////////////////////////////////////////////// private void setupActions(@NonNull final View view) { - compactSlots = new ArrayList<>(NotificationConstants - .getCompactSlotsFromPreferences(getContext(), getSharedPreferences(), 5)); - notificationSlots = IntStream.range(0, 5).mapToObj(i -> new NotificationSlot(i, view)) + compactSlots = NotificationConstants.getCompactSlotsFromPreferences(getContext(), + getSharedPreferences(), 5); + notificationSlots = IntStream.range(0, 5) + .mapToObj(i -> new NotificationSlot(i, view)) .toArray(NotificationSlot[]::new); }