Fix line break

This commit is contained in:
TobiGr 2020-12-23 12:49:32 +01:00
parent c682ea0d18
commit 865c42e273

View File

@ -1,67 +1,67 @@
package org.schabi.newpipe.extractor.stream; package org.schabi.newpipe.extractor.stream;
import org.schabi.newpipe.extractor.MediaFormat; import org.schabi.newpipe.extractor.MediaFormat;
import java.io.Serializable; import java.io.Serializable;
import java.util.Locale; import java.util.Locale;
public class SubtitlesStream extends Stream implements Serializable { public class SubtitlesStream extends Stream implements Serializable {
private final MediaFormat format; private final MediaFormat format;
private final Locale locale; private final Locale locale;
private final boolean autoGenerated; private final boolean autoGenerated;
private final String code; private final String code;
public SubtitlesStream(MediaFormat format, String languageCode, String url, boolean autoGenerated) { public SubtitlesStream(MediaFormat format, String languageCode, String url, boolean autoGenerated) {
super(url, format); super(url, format);
/* /*
* Locale.forLanguageTag only for API >= 21 * Locale.forLanguageTag only for API >= 21
* Locale.Builder only for API >= 21 * Locale.Builder only for API >= 21
* Country codes doesn't work well without * Country codes doesn't work well without
*/ */
final String[] splits = languageCode.split("-"); final String[] splits = languageCode.split("-");
switch (splits.length) { switch (splits.length) {
default: default:
this.locale = new Locale(splits[0]); this.locale = new Locale(splits[0]);
break; break;
case 3: case 3:
this.locale = new Locale(splits[0], splits[1], splits[2]);// complex variants doesn't work! this.locale = new Locale(splits[0], splits[1], splits[2]);// complex variants doesn't work!
break; break;
case 2: case 2:
this.locale = new Locale(splits[0], splits[1]); this.locale = new Locale(splits[0], splits[1]);
break; break;
} }
this.code = languageCode; this.code = languageCode;
this.format = format; this.format = format;
this.autoGenerated = autoGenerated; this.autoGenerated = autoGenerated;
} }
public String getExtension() { public String getExtension() {
return format.suffix; return format.suffix;
} }
public boolean isAutoGenerated() { public boolean isAutoGenerated() {
return autoGenerated; return autoGenerated;
} }
@Override @Override
public boolean equalStats(Stream cmp) { public boolean equalStats(Stream cmp) {
return super.equalStats(cmp) && return super.equalStats(cmp) &&
cmp instanceof SubtitlesStream && cmp instanceof SubtitlesStream &&
code.equals(((SubtitlesStream) cmp).code) && code.equals(((SubtitlesStream) cmp).code) &&
autoGenerated == ((SubtitlesStream) cmp).autoGenerated; autoGenerated == ((SubtitlesStream) cmp).autoGenerated;
} }
public String getDisplayLanguageName() { public String getDisplayLanguageName() {
return locale.getDisplayName(locale); return locale.getDisplayName(locale);
} }
public String getLanguageTag() { public String getLanguageTag() {
return code; return code;
} }
public Locale getLocale() { public Locale getLocale() {
return locale; return locale;
} }
} }