Use toArray() with zero-length arrays.
This commit is contained in:
parent
1a8f396e77
commit
fc46233baf
|
@ -282,11 +282,9 @@ public abstract class FragmentStatePagerAdapterMenuWorkaround extends PagerAdapt
|
|||
@Nullable
|
||||
public Parcelable saveState() {
|
||||
Bundle state = null;
|
||||
if (mSavedState.size() > 0) {
|
||||
if (!mSavedState.isEmpty()) {
|
||||
state = new Bundle();
|
||||
final Fragment.SavedState[] fss = new Fragment.SavedState[mSavedState.size()];
|
||||
mSavedState.toArray(fss);
|
||||
state.putParcelableArray("states", fss);
|
||||
state.putParcelableArray("states", mSavedState.toArray(new Fragment.SavedState[0]));
|
||||
}
|
||||
for (int i = 0; i < mFragments.size(); i++) {
|
||||
final Fragment f = mFragments.get(i);
|
||||
|
|
|
@ -2167,12 +2167,8 @@ public final class VideoDetailFragment
|
|||
} else {
|
||||
final int selectedVideoStreamIndexForExternalPlayers =
|
||||
ListHelper.getDefaultResolutionIndex(activity, videoStreamsForExternalPlayers);
|
||||
final CharSequence[] resolutions =
|
||||
new CharSequence[videoStreamsForExternalPlayers.size()];
|
||||
|
||||
for (int i = 0; i < videoStreamsForExternalPlayers.size(); i++) {
|
||||
resolutions[i] = videoStreamsForExternalPlayers.get(i).getResolution();
|
||||
}
|
||||
final CharSequence[] resolutions = videoStreamsForExternalPlayers.stream()
|
||||
.map(VideoStream::getResolution).toArray(CharSequence[]::new);
|
||||
|
||||
builder.setSingleChoiceItems(resolutions, selectedVideoStreamIndexForExternalPlayers,
|
||||
null);
|
||||
|
|
|
@ -919,7 +919,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
filterItemCheckedId = item.getItemId();
|
||||
item.setChecked(true);
|
||||
|
||||
contentFilter = new String[]{theContentFilter.get(0)};
|
||||
contentFilter = theContentFilter.toArray(new String[0]);
|
||||
|
||||
if (!TextUtils.isEmpty(searchString)) {
|
||||
search(searchString, contentFilter, sortFilter);
|
||||
|
@ -980,8 +980,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
|
|||
isCorrectedSearch = result.isCorrectedSearch();
|
||||
|
||||
// List<MetaInfo> cannot be bundled without creating some containers
|
||||
metaInfo = new MetaInfo[result.getMetaInfo().size()];
|
||||
metaInfo = result.getMetaInfo().toArray(metaInfo);
|
||||
metaInfo = result.getMetaInfo().toArray(new MetaInfo[0]);
|
||||
showMetaInfoInTextView(result.getMetaInfo(), searchBinding.searchMetaInfoTextView,
|
||||
searchBinding.searchMetaInfoSeparator, disposables);
|
||||
|
||||
|
|
|
@ -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 SLOT_COMPACT_DEFAULTS;
|
||||
}
|
||||
|
||||
// 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)
|
||||
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(i -> i).toArray();
|
||||
|
||||
builder.setStyle(new androidx.media.app.NotificationCompat.MediaStyle()
|
||||
.setMediaSession(player.getMediaSessionManager().getSessionToken())
|
||||
|
|
|
@ -34,7 +34,9 @@ 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;
|
||||
|
||||
public class NotificationActionsPreference extends Preference {
|
||||
|
||||
|
@ -74,13 +76,10 @@ public class NotificationActionsPreference extends Preference {
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void setupActions(@NonNull final View view) {
|
||||
compactSlots =
|
||||
NotificationConstants.getCompactSlotsFromPreferences(
|
||||
getContext(), getSharedPreferences(), 5);
|
||||
notificationSlots = new NotificationSlot[5];
|
||||
for (int i = 0; i < 5; i++) {
|
||||
notificationSlots[i] = new NotificationSlot(i, view);
|
||||
}
|
||||
compactSlots = new ArrayList<>(NotificationConstants
|
||||
.getCompactSlotsFromPreferences(getContext(), getSharedPreferences(), 5));
|
||||
notificationSlots = IntStream.range(0, 5).mapToObj(i -> new NotificationSlot(i, view))
|
||||
.toArray(NotificationSlot[]::new);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -348,8 +348,7 @@ public class WebMReader {
|
|||
ensure(elemTrackEntry);
|
||||
}
|
||||
|
||||
final WebMTrack[] entries = new WebMTrack[trackEntries.size()];
|
||||
trackEntries.toArray(entries);
|
||||
final WebMTrack[] entries = trackEntries.toArray(new WebMTrack[0]);
|
||||
|
||||
for (final WebMTrack entry : entries) {
|
||||
switch (entry.trackType) {
|
||||
|
|
Loading…
Reference in New Issue