Further cleanup maxBitrate function

This commit is contained in:
tzugen 2021-11-03 12:55:20 +01:00
parent a66d07ae84
commit aac73cd6d7
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
1 changed files with 13 additions and 6 deletions

View File

@ -69,14 +69,21 @@ object Settings {
@JvmStatic
val maxBitRate: Int
get() {
val preferences = preferences
return preferences.getString(
if (Util.networkInfo().unmetered) Constants.PREFERENCES_KEY_MAX_BITRATE_WIFI
else Constants.PREFERENCES_KEY_MAX_BITRATE_MOBILE,
"0"
)!!.toInt()
val network = Util.networkInfo()
if (!network.connected) return 0
if (network.unmetered) {
return maxWifiBitRate
} else {
return maxMobileBitRate
}
}
private var maxWifiBitRate by StringIntSetting(Constants.PREFERENCES_KEY_MAX_BITRATE_WIFI)
private var maxMobileBitRate by StringIntSetting(Constants.PREFERENCES_KEY_MAX_BITRATE_MOBILE)
@JvmStatic
val preloadCount: Int
get() {