Merge pull request #334 from Bnyro/master

player stops in settings fixed
This commit is contained in:
Bnyro 2022-05-30 22:24:43 +02:00 committed by GitHub
commit 15de27676a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,6 +37,7 @@ import org.json.JSONTokener
import retrofit2.HttpException
private var isCurrentViewMainSettings = true
private var requireMainActivityRestart = false
class SettingsActivity :
AppCompatActivity(),
@ -243,11 +244,13 @@ class SettingsActivity :
themeToggle?.setOnPreferenceChangeListener { _, _ ->
val refresh = Intent(context, SettingsActivity::class.java)
startActivity(refresh)
requireMainActivityRestart = true
true
}
val accentColor = findPreference<Preference>("accent_color")
accentColor?.setOnPreferenceChangeListener { _, _ ->
requireMainActivityRestart = true
val refresh = Intent(context, SettingsActivity::class.java)
startActivity(refresh)
true
@ -259,9 +262,9 @@ class SettingsActivity :
true
}
val changeLanguage = findPreference<ListPreference>("language")
changeLanguage?.setOnPreferenceChangeListener { _, _ ->
restartMainActivity(requireContext())
val gridColumns = findPreference<ListPreference>("grid")
gridColumns?.setOnPreferenceChangeListener { _, _ ->
requireMainActivityRestart = true
true
}
@ -384,7 +387,13 @@ class SettingsActivity :
if (isCurrentViewMainSettings) {
PreferenceManager.getDefaultSharedPreferences(this)
.unregisterOnSharedPreferenceChangeListener(this)
restartMainActivity(this)
if (requireMainActivityRestart) {
restartMainActivity(this)
finishAffinity()
} else {
super.onBackPressed()
}
finishAndRemoveTask()
} else {
isCurrentViewMainSettings = true
supportFragmentManager