Skip to content

Commit 8dad6d7

Browse files
StypoxAudricV
authored andcommitted
Code improvements here and there
1 parent e5ffa2a commit 8dad6d7

3 files changed

Lines changed: 29 additions & 29 deletions

File tree

app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -786,10 +786,8 @@ private void prepareSelectedDownload() {
786786

787787
if (format == MediaFormat.TTML) {
788788
filenameTmp += MediaFormat.SRT.suffix;
789-
} else {
790-
if (format != null) {
791-
filenameTmp += format.suffix;
792-
}
789+
} else if (format != null) {
790+
filenameTmp += format.suffix;
793791
}
794792
break;
795793
default:

app/src/main/java/org/schabi/newpipe/util/SecondaryStreamHelper.java

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,35 @@ public SecondaryStreamHelper(@NonNull final StreamSizeWrapper<T> streams,
3535
public static AudioStream getAudioStreamFor(@NonNull final List<AudioStream> audioStreams,
3636
@NonNull final VideoStream videoStream) {
3737
final MediaFormat mediaFormat = videoStream.getFormat();
38-
if (mediaFormat != null) {
39-
switch (mediaFormat) {
40-
case WEBM:
41-
case MPEG_4:// ¿is mpeg-4 DASH?
42-
break;
43-
default:
44-
return null;
45-
}
38+
if (mediaFormat == null) {
39+
return null;
40+
}
4641

47-
final boolean m4v = (mediaFormat == MediaFormat.MPEG_4);
42+
switch (mediaFormat) {
43+
case WEBM:
44+
case MPEG_4:// ¿is mpeg-4 DASH?
45+
break;
46+
default:
47+
return null;
48+
}
4849

49-
for (final AudioStream audio : audioStreams) {
50-
if (audio.getFormat() == (m4v ? MediaFormat.M4A : MediaFormat.WEBMA)) {
51-
return audio;
52-
}
53-
}
50+
final boolean m4v = (mediaFormat == MediaFormat.MPEG_4);
5451

55-
if (m4v) {
56-
return null;
52+
for (final AudioStream audio : audioStreams) {
53+
if (audio.getFormat() == (m4v ? MediaFormat.M4A : MediaFormat.WEBMA)) {
54+
return audio;
5755
}
56+
}
57+
58+
if (m4v) {
59+
return null;
60+
}
5861

59-
// retry, but this time in reverse order
60-
for (int i = audioStreams.size() - 1; i >= 0; i--) {
61-
final AudioStream audio = audioStreams.get(i);
62-
if (audio.getFormat() == MediaFormat.WEBMA_OPUS) {
63-
return audio;
64-
}
62+
// retry, but this time in reverse order
63+
for (int i = audioStreams.size() - 1; i >= 0; i--) {
64+
final AudioStream audio = audioStreams.get(i);
65+
if (audio.getFormat() == MediaFormat.WEBMA_OPUS) {
66+
return audio;
6567
}
6668
}
6769

app/src/main/java/org/schabi/newpipe/util/StreamItemAdapter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ private View getCustomView(final int position,
155155
qualityString += " (" + context.getString(R.string.caption_auto_generated) + ")";
156156
}
157157
} else {
158-
if (mediaFormat != null) {
159-
qualityString = mediaFormat.getSuffix();
160-
} else {
158+
if (mediaFormat == null) {
161159
qualityString = context.getString(R.string.unknown_quality);
160+
} else {
161+
qualityString = mediaFormat.getSuffix();
162162
}
163163
}
164164

0 commit comments

Comments
 (0)