fix: Edge case bug of setting preferred media without any provider that has mainPage (#231)

This commit is contained in:
Jace 2021-11-09 22:40:12 +08:00 committed by GitHub
parent f38ffc8ce9
commit 97641d5459
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -347,8 +347,9 @@ class SettingsFragment : PreferenceFragmentCompat() {
settingsManager.edit() settingsManager.edit()
.putInt(getString(R.string.preferred_media_settings), prefValues[it]) .putInt(getString(R.string.preferred_media_settings), prefValues[it])
.apply() .apply()
val apiRandom = AppUtils.filterProviderByPreferredMedia(apis, prefValues[it]).random() val apilist = AppUtils.filterProviderByPreferredMedia(apis, prefValues[it])
context?.setKey(HOMEPAGE_API, apiRandom.name) val apiRandom = if (apilist?.size > 0) { apilist.random().name } else { "" }
context?.setKey(HOMEPAGE_API, apiRandom)
context?.initRequestClient() context?.initRequestClient()
} }
return@setOnPreferenceClickListener true return@setOnPreferenceClickListener true