Merge pull request #8724 from Isira-Seneviratne/toArray_improvements

Use toArray() with zero-length arrays.
This commit is contained in:
Stypox 2022-08-06 11:33:05 +02:00 committed by GitHub
commit 6f86e21605
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 29 deletions

View file

@ -14,7 +14,6 @@ import org.schabi.newpipe.util.Localization;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
@ -115,7 +114,7 @@ public final class NotificationConstants {
};
public static final Integer[] SLOT_COMPACT_DEFAULTS = {0, 1, 2};
public static final List<Integer> SLOT_COMPACT_DEFAULTS = List.of(0, 1, 2);
public static final int[] SLOT_COMPACT_PREF_KEYS = {
R.string.notification_slot_compact_0_key,
@ -181,7 +180,7 @@ public final class NotificationConstants {
if (compactSlot == Integer.MAX_VALUE) {
// settings not yet populated, return default values
return new ArrayList<>(Arrays.asList(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

View file

@ -99,10 +99,7 @@ public final class NotificationUtil {
// build the compact slot indices array (need code to convert from Integer... because Java)
final List<Integer> compactSlotList = NotificationConstants.getCompactSlotsFromPreferences(
player.getContext(), player.getPrefs(), nonNothingSlotCount);
final int[] compactSlots = new int[compactSlotList.size()];
for (int i = 0; i < compactSlotList.size(); i++) {
compactSlots[i] = compactSlotList.get(i);
}
final int[] compactSlots = compactSlotList.stream().mapToInt(Integer::intValue).toArray();
builder.setStyle(new androidx.media.app.NotificationCompat.MediaStyle()
.setMediaSession(player.getMediaSessionManager().getSessionToken())