Skip to content

Commit 3b80547

Browse files
Add code review suggestions.
1 parent b90a566 commit 3b80547

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/stream/SubtitlesStream.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package org.schabi.newpipe.extractor.stream;
22

3-
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
4-
53
import org.schabi.newpipe.extractor.MediaFormat;
64
import org.schabi.newpipe.extractor.services.youtube.ItagItem;
75
import org.schabi.newpipe.extractor.utils.LocaleCompat;

extractor/src/main/java/org/schabi/newpipe/extractor/utils/LocaleCompat.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22

33
import java.util.Locale;
44

5-
public class LocaleCompat {
5+
/**
6+
* This class contains a simple implementation of {@link Locale#forLanguageTag(String)} for Android
7+
* API levels below 21 (Lollipop). This is needed as core library desugaring does not backport that
8+
* method as of this writing.
9+
*
10+
* Relevant issue: https://issuetracker.google.com/issues/171182330
11+
*/
12+
public final class LocaleCompat {
613
private LocaleCompat() {
714
}
815

9-
// Source: LocaleListCompat's private forLanguageTagCompat() method.
10-
// Use Locale.forLanguageTag() on API level >= 21 instead.
16+
// Source: The AndroidX LocaleListCompat class's private forLanguageTagCompat() method.
17+
// Use Locale.forLanguageTag() on Android API level >= 21 / Java instead.
1118
public static Locale forLanguageTag(final String str) {
1219
if (str.contains("-")) {
13-
String[] args = str.split("-", -1);
20+
final String[] args = str.split("-", -1);
1421
if (args.length > 2) {
1522
return new Locale(args[0], args[1], args[2]);
1623
} else if (args.length > 1) {
@@ -19,7 +26,7 @@ public static Locale forLanguageTag(final String str) {
1926
return new Locale(args[0]);
2027
}
2128
} else if (str.contains("_")) {
22-
String[] args = str.split("_", -1);
29+
final String[] args = str.split("_", -1);
2330
if (args.length > 2) {
2431
return new Locale(args[0], args[1], args[2]);
2532
} else if (args.length > 1) {

0 commit comments

Comments
 (0)