Use toArray() with zero-length arrays.
This commit is contained in:
parent
1a8f396e77
commit
fc46233baf
7 changed files with 16 additions and 29 deletions
|
@ -282,11 +282,9 @@ public abstract class FragmentStatePagerAdapterMenuWorkaround extends PagerAdapt
|
||||||
@Nullable
|
@Nullable
|
||||||
public Parcelable saveState() {
|
public Parcelable saveState() {
|
||||||
Bundle state = null;
|
Bundle state = null;
|
||||||
if (mSavedState.size() > 0) {
|
if (!mSavedState.isEmpty()) {
|
||||||
state = new Bundle();
|
state = new Bundle();
|
||||||
final Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
|
state.putParcelableArray("states", mSavedState.toArray(new Fragment.SavedState[0]));
|
||||||
mSavedState.toArray(fss);
|
|
||||||
state.putParcelableArray("states", fss);
|
|
||||||
}
|
}
|
||||||
for (int i = 0; i < mFragments.size(); i++) {
|
for (int i = 0; i < mFragments.size(); i++) {
|
||||||
final Fragment f = mFragments.get(i);
|
final Fragment f = mFragments.get(i);
|
||||||
|
|
|
@ -2167,12 +2167,8 @@ public final class VideoDetailFragment
|
||||||
} else {
|
} else {
|
||||||
final int selectedVideoStreamIndexForExternalPlayers =
|
final int selectedVideoStreamIndexForExternalPlayers =
|
||||||
ListHelper.getDefaultResolutionIndex(activity, videoStreamsForExternalPlayers);
|
ListHelper.getDefaultResolutionIndex(activity, videoStreamsForExternalPlayers);
|
||||||
final CharSequence[] resolutions =
|
final CharSequence[] resolutions = videoStreamsForExternalPlayers.stream()
|
||||||
new CharSequence[videoStreamsForExternalPlayers.size()];
|
.map(VideoStream::getResolution).toArray(CharSequence[]::new);
|
||||||
|
|
||||||
for (int i = 0; i < videoStreamsForExternalPlayers.size(); i++) {
|
|
||||||
resolutions[i] = videoStreamsForExternalPlayers.get(i).getResolution();
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.setSingleChoiceItems(resolutions, selectedVideoStreamIndexForExternalPlayers,
|
builder.setSingleChoiceItems(resolutions, selectedVideoStreamIndexForExternalPlayers,
|
||||||
null);
|
null);
|
||||||
|
|
|
@ -919,7 +919,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||||
filterItemCheckedId = item.getItemId();
|
filterItemCheckedId = item.getItemId();
|
||||||
item.setChecked(true);
|
item.setChecked(true);
|
||||||
|
|
||||||
contentFilter = new String[]{theContentFilter.get(0)};
|
contentFilter = theContentFilter.toArray(new String[0]);
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(searchString)) {
|
if (!TextUtils.isEmpty(searchString)) {
|
||||||
search(searchString, contentFilter, sortFilter);
|
search(searchString, contentFilter, sortFilter);
|
||||||
|
@ -980,8 +980,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
||||||
isCorrectedSearch = result.isCorrectedSearch();
|
isCorrectedSearch = result.isCorrectedSearch();
|
||||||
|
|
||||||
// List<MetaInfo> cannot be bundled without creating some containers
|
// List<MetaInfo> cannot be bundled without creating some containers
|
||||||
metaInfo = new MetaInfo[result.getMetaInfo().size()];
|
metaInfo = result.getMetaInfo().toArray(new MetaInfo[0]);
|
||||||
metaInfo = result.getMetaInfo().toArray(metaInfo);
|
|
||||||
showMetaInfoInTextView(result.getMetaInfo(), searchBinding.searchMetaInfoTextView,
|
showMetaInfoInTextView(result.getMetaInfo(), searchBinding.searchMetaInfoTextView,
|
||||||
searchBinding.searchMetaInfoSeparator, disposables);
|
searchBinding.searchMetaInfoSeparator, disposables);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ import org.schabi.newpipe.util.Localization;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
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 = {
|
public static final int[] SLOT_COMPACT_PREF_KEYS = {
|
||||||
R.string.notification_slot_compact_0_key,
|
R.string.notification_slot_compact_0_key,
|
||||||
|
@ -181,7 +180,7 @@ public final class NotificationConstants {
|
||||||
|
|
||||||
if (compactSlot == Integer.MAX_VALUE) {
|
if (compactSlot == Integer.MAX_VALUE) {
|
||||||
// settings not yet populated, return default values
|
// settings not yet populated, return default values
|
||||||
return new ArrayList<>(Arrays.asList(SLOT_COMPACT_DEFAULTS));
|
return SLOT_COMPACT_DEFAULTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// a negative value (-1) is set when the user does not want a particular compact slot
|
// a negative value (-1) is set when the user does not want a particular compact slot
|
||||||
|
|
|
@ -99,10 +99,7 @@ public final class NotificationUtil {
|
||||||
// build the compact slot indices array (need code to convert from Integer... because Java)
|
// build the compact slot indices array (need code to convert from Integer... because Java)
|
||||||
final List<Integer> compactSlotList = NotificationConstants.getCompactSlotsFromPreferences(
|
final List<Integer> compactSlotList = NotificationConstants.getCompactSlotsFromPreferences(
|
||||||
player.getContext(), player.getPrefs(), nonNothingSlotCount);
|
player.getContext(), player.getPrefs(), nonNothingSlotCount);
|
||||||
final int[] compactSlots = new int[compactSlotList.size()];
|
final int[] compactSlots = compactSlotList.stream().mapToInt(i -> i).toArray();
|
||||||
for (int i = 0; i < compactSlotList.size(); i++) {
|
|
||||||
compactSlots[i] = compactSlotList.get(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.setStyle(new androidx.media.app.NotificationCompat.MediaStyle()
|
builder.setStyle(new androidx.media.app.NotificationCompat.MediaStyle()
|
||||||
.setMediaSession(player.getMediaSessionManager().getSessionToken())
|
.setMediaSession(player.getMediaSessionManager().getSessionToken())
|
||||||
|
|
|
@ -34,7 +34,9 @@ import org.schabi.newpipe.util.DeviceUtils;
|
||||||
import org.schabi.newpipe.util.ThemeHelper;
|
import org.schabi.newpipe.util.ThemeHelper;
|
||||||
import org.schabi.newpipe.views.FocusOverlayView;
|
import org.schabi.newpipe.views.FocusOverlayView;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
public class NotificationActionsPreference extends Preference {
|
public class NotificationActionsPreference extends Preference {
|
||||||
|
|
||||||
|
@ -74,13 +76,10 @@ public class NotificationActionsPreference extends Preference {
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private void setupActions(@NonNull final View view) {
|
private void setupActions(@NonNull final View view) {
|
||||||
compactSlots =
|
compactSlots = new ArrayList<>(NotificationConstants
|
||||||
NotificationConstants.getCompactSlotsFromPreferences(
|
.getCompactSlotsFromPreferences(getContext(), getSharedPreferences(), 5));
|
||||||
getContext(), getSharedPreferences(), 5);
|
notificationSlots = IntStream.range(0, 5).mapToObj(i -> new NotificationSlot(i, view))
|
||||||
notificationSlots = new NotificationSlot[5];
|
.toArray(NotificationSlot[]::new);
|
||||||
for (int i = 0; i < 5; i++) {
|
|
||||||
notificationSlots[i] = new NotificationSlot(i, view);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -348,8 +348,7 @@ public class WebMReader {
|
||||||
ensure(elemTrackEntry);
|
ensure(elemTrackEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
final WebMTrack[] entries = new WebMTrack[trackEntries.size()];
|
final WebMTrack[] entries = trackEntries.toArray(new WebMTrack[0]);
|
||||||
trackEntries.toArray(entries);
|
|
||||||
|
|
||||||
for (final WebMTrack entry : entries) {
|
for (final WebMTrack entry : entries) {
|
||||||
switch (entry.trackType) {
|
switch (entry.trackType) {
|
||||||
|
|
Loading…
Reference in a new issue