Improve code in VideoDetailFragment

This commit is contained in:
Stypox 2022-06-18 17:49:04 +02:00
parent 7ba79171c7
commit 4863084fa2
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
1 changed files with 13 additions and 12 deletions

View File

@ -1555,13 +1555,11 @@ public final class VideoDetailFragment
binding.detailSubChannelThumbnailView.setImageDrawable(buddyDrawable); binding.detailSubChannelThumbnailView.setImageDrawable(buddyDrawable);
binding.detailUploaderThumbnailView.setImageDrawable(buddyDrawable); binding.detailUploaderThumbnailView.setImageDrawable(buddyDrawable);
final StreamType streamType = info.getStreamType();
if (info.getViewCount() >= 0) { if (info.getViewCount() >= 0) {
if (streamType.equals(StreamType.AUDIO_LIVE_STREAM)) { if (info.getStreamType().equals(StreamType.AUDIO_LIVE_STREAM)) {
binding.detailViewCountView.setText(Localization.listeningCount(activity, binding.detailViewCountView.setText(Localization.listeningCount(activity,
info.getViewCount())); info.getViewCount()));
} else if (streamType.equals(StreamType.LIVE_STREAM)) { } else if (info.getStreamType().equals(StreamType.LIVE_STREAM)) {
binding.detailViewCountView.setText(Localization binding.detailViewCountView.setText(Localization
.localizeWatchingCount(activity, info.getViewCount())); .localizeWatchingCount(activity, info.getViewCount()));
} else { } else {
@ -1648,7 +1646,7 @@ public final class VideoDetailFragment
} }
binding.detailControlsDownload.setVisibility( binding.detailControlsDownload.setVisibility(
StreamTypeUtil.isLiveStream(streamType) ? View.GONE : View.VISIBLE); StreamTypeUtil.isLiveStream(info.getStreamType()) ? View.GONE : View.VISIBLE);
binding.detailControlsBackground.setVisibility(info.getAudioStreams().isEmpty() binding.detailControlsBackground.setVisibility(info.getAudioStreams().isEmpty()
? View.GONE : View.VISIBLE); ? View.GONE : View.VISIBLE);
@ -2151,21 +2149,24 @@ public final class VideoDetailFragment
return; return;
} }
final List<VideoStream> videoStreams = getNonUrlAndNonTorrentStreams(
currentInfo.getVideoStreams());
final List<VideoStream> videoOnlyStreams = getNonUrlAndNonTorrentStreams(
currentInfo.getVideoOnlyStreams());
final AlertDialog.Builder builder = new AlertDialog.Builder(activity); final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle(R.string.select_quality_external_players); builder.setTitle(R.string.select_quality_external_players);
builder.setNeutralButton(R.string.open_in_browser, (dialog, i) -> builder.setNeutralButton(R.string.open_in_browser, (dialog, i) ->
ShareUtils.openUrlInBrowser(requireActivity(), url)); ShareUtils.openUrlInBrowser(requireActivity(), url));
final List<VideoStream> videoStreamsForExternalPlayers = final List<VideoStream> videoStreamsForExternalPlayers =
ListHelper.getSortedStreamVideosList(activity, videoStreams, videoOnlyStreams, ListHelper.getSortedStreamVideosList(
false, false); activity,
getNonUrlAndNonTorrentStreams(currentInfo.getVideoStreams()),
getNonUrlAndNonTorrentStreams(currentInfo.getVideoOnlyStreams()),
false,
false
);
if (videoStreamsForExternalPlayers.isEmpty()) { if (videoStreamsForExternalPlayers.isEmpty()) {
builder.setMessage(R.string.no_video_streams_available_for_external_players); builder.setMessage(R.string.no_video_streams_available_for_external_players);
builder.setPositiveButton(R.string.ok, null); builder.setPositiveButton(R.string.ok, null);
} else { } else {
final int selectedVideoStreamIndexForExternalPlayers = final int selectedVideoStreamIndexForExternalPlayers =
ListHelper.getDefaultResolutionIndex(activity, videoStreamsForExternalPlayers); ListHelper.getDefaultResolutionIndex(activity, videoStreamsForExternalPlayers);