Skip to content

Commit

Permalink
Merge pull request #10732 from Profpatsch/dont-write-media-format
Browse files Browse the repository at this point in the history
Don't write defaultFormat setting, use default value
  • Loading branch information
TobiGr authored Mar 25, 2024
2 parents 2e318b8 + 575e809 commit 5cf3c58
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions app/src/main/java/org/schabi/newpipe/util/ListHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ private static int getDefaultResolutionWithDefaultFormat(@NonNull final Context
context.getString(R.string.best_resolution_key), defaultFormat, videoStreams);
}

@Nullable
private static MediaFormat getDefaultFormat(@NonNull final Context context,
@StringRes final int defaultFormatKey,
@StringRes final int defaultFormatValueKey) {
Expand All @@ -651,18 +652,14 @@ private static MediaFormat getDefaultFormat(@NonNull final Context context,

final String defaultFormat = context.getString(defaultFormatValueKey);
final String defaultFormatString = preferences.getString(
context.getString(defaultFormatKey), defaultFormat);
context.getString(defaultFormatKey),
defaultFormat
);

MediaFormat defaultMediaFormat = getMediaFormatFromKey(context, defaultFormatString);
if (defaultMediaFormat == null) {
preferences.edit().putString(context.getString(defaultFormatKey), defaultFormat)
.apply();
defaultMediaFormat = getMediaFormatFromKey(context, defaultFormat);
}

return defaultMediaFormat;
return getMediaFormatFromKey(context, defaultFormatString);
}

@Nullable
private static MediaFormat getMediaFormatFromKey(@NonNull final Context context,
@NonNull final String formatKey) {
MediaFormat format = null;
Expand Down

0 comments on commit 5cf3c58

Please sign in to comment.