Skip to content

Commit c6ba69a

Browse files
author
Yevhen Babiichuk (DustDFG)
committed
Convert newpipe/util/image/PreferredImageQuality to kotlin
1 parent 8ae5a55 commit c6ba69a

2 files changed

Lines changed: 33 additions & 39 deletions

File tree

app/src/main/java/org/schabi/newpipe/util/image/PreferredImageQuality.java

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package org.schabi.newpipe.util.image
2+
3+
import android.content.Context
4+
import org.schabi.newpipe.R
5+
import org.schabi.newpipe.extractor.Image.ResolutionLevel
6+
7+
enum class PreferredImageQuality {
8+
NONE,
9+
LOW,
10+
MEDIUM,
11+
HIGH;
12+
13+
fun toResolutionLevel(): ResolutionLevel {
14+
return when (this) {
15+
LOW -> ResolutionLevel.LOW
16+
MEDIUM -> ResolutionLevel.MEDIUM
17+
HIGH -> ResolutionLevel.HIGH
18+
NONE -> ResolutionLevel.UNKNOWN
19+
}
20+
}
21+
22+
companion object {
23+
@JvmStatic
24+
fun fromPreferenceKey(context: Context, key: String?): PreferredImageQuality {
25+
return when (key) {
26+
context.getString(R.string.image_quality_none_key) -> NONE
27+
context.getString(R.string.image_quality_low_key) -> LOW
28+
context.getString(R.string.image_quality_high_key) -> HIGH
29+
else -> MEDIUM // default to medium
30+
}
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)