Skip to content

Commit

Permalink
fix: Edge case bug of setting preferred media without any provider th…
Browse files Browse the repository at this point in the history
…at has mainPage (#231)
  • Loading branch information
Jacekun authored Nov 9, 2021
1 parent f38ffc8 commit 97641d5
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,9 @@ class SettingsFragment : PreferenceFragmentCompat() {
settingsManager.edit()
.putInt(getString(R.string.preferred_media_settings), prefValues[it])
.apply()
val apiRandom = AppUtils.filterProviderByPreferredMedia(apis, prefValues[it]).random()
context?.setKey(HOMEPAGE_API, apiRandom.name)
val apilist = AppUtils.filterProviderByPreferredMedia(apis, prefValues[it])
val apiRandom = if (apilist?.size > 0) { apilist.random().name } else { "" }
context?.setKey(HOMEPAGE_API, apiRandom)
context?.initRequestClient()
}
return@setOnPreferenceClickListener true
Expand Down

0 comments on commit 97641d5

Please sign in to comment.