Use toArray() with zero-length arrays.

This commit is contained in:
Isira Seneviratne 2022-07-30 00:51:15 +05:30
parent 4ed7229861
commit b49b8f325d
7 changed files with 16 additions and 29 deletions

View file

@ -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);

View file

@ -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);