Skip to content

Commit 4863084

Browse files
committed
Improve code in VideoDetailFragment
1 parent 7ba7917 commit 4863084

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,13 +1555,11 @@ public void handleResult(@NonNull final StreamInfo info) {
15551555
binding.detailSubChannelThumbnailView.setImageDrawable(buddyDrawable);
15561556
binding.detailUploaderThumbnailView.setImageDrawable(buddyDrawable);
15571557

1558-
final StreamType streamType = info.getStreamType();
1559-
15601558
if (info.getViewCount() >= 0) {
1561-
if (streamType.equals(StreamType.AUDIO_LIVE_STREAM)) {
1559+
if (info.getStreamType().equals(StreamType.AUDIO_LIVE_STREAM)) {
15621560
binding.detailViewCountView.setText(Localization.listeningCount(activity,
15631561
info.getViewCount()));
1564-
} else if (streamType.equals(StreamType.LIVE_STREAM)) {
1562+
} else if (info.getStreamType().equals(StreamType.LIVE_STREAM)) {
15651563
binding.detailViewCountView.setText(Localization
15661564
.localizeWatchingCount(activity, info.getViewCount()));
15671565
} else {
@@ -1648,7 +1646,7 @@ public void handleResult(@NonNull final StreamInfo info) {
16481646
}
16491647

16501648
binding.detailControlsDownload.setVisibility(
1651-
StreamTypeUtil.isLiveStream(streamType) ? View.GONE : View.VISIBLE);
1649+
StreamTypeUtil.isLiveStream(info.getStreamType()) ? View.GONE : View.VISIBLE);
16521650
binding.detailControlsBackground.setVisibility(info.getAudioStreams().isEmpty()
16531651
? View.GONE : View.VISIBLE);
16541652

@@ -2151,21 +2149,24 @@ private void showExternalPlaybackDialog() {
21512149
return;
21522150
}
21532151

2154-
final List<VideoStream> videoStreams = getNonUrlAndNonTorrentStreams(
2155-
currentInfo.getVideoStreams());
2156-
final List<VideoStream> videoOnlyStreams = getNonUrlAndNonTorrentStreams(
2157-
currentInfo.getVideoOnlyStreams());
2158-
21592152
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
21602153
builder.setTitle(R.string.select_quality_external_players);
21612154
builder.setNeutralButton(R.string.open_in_browser, (dialog, i) ->
21622155
ShareUtils.openUrlInBrowser(requireActivity(), url));
2156+
21632157
final List<VideoStream> videoStreamsForExternalPlayers =
2164-
ListHelper.getSortedStreamVideosList(activity, videoStreams, videoOnlyStreams,
2165-
false, false);
2158+
ListHelper.getSortedStreamVideosList(
2159+
activity,
2160+
getNonUrlAndNonTorrentStreams(currentInfo.getVideoStreams()),
2161+
getNonUrlAndNonTorrentStreams(currentInfo.getVideoOnlyStreams()),
2162+
false,
2163+
false
2164+
);
2165+
21662166
if (videoStreamsForExternalPlayers.isEmpty()) {
21672167
builder.setMessage(R.string.no_video_streams_available_for_external_players);
21682168
builder.setPositiveButton(R.string.ok, null);
2169+
21692170
} else {
21702171
final int selectedVideoStreamIndexForExternalPlayers =
21712172
ListHelper.getDefaultResolutionIndex(activity, videoStreamsForExternalPlayers);

0 commit comments

Comments
 (0)