Fix IllegalStateException

This commit is contained in:
Nicolas Pomepuy 2024-10-17 10:00:29 +02:00 committed by Duncan McNamara
parent 344be73e6e
commit 3daead8e57
2 changed files with 20 additions and 2 deletions

View File

@ -56,13 +56,22 @@ class PreferencesRemoteAccess : BasePreferenceFragment(), SharedPreferences.OnSh
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
preferenceScreen.sharedPreferences!!.registerOnSharedPreferenceChangeListener(this)
if(!settings.getBoolean(REMOTE_ACCESS_ONBOARDING, false)) {
settings.putSingle(REMOTE_ACCESS_ONBOARDING, true)
startActivity(Intent(Intent.ACTION_VIEW).apply { setClassName(activity, REMOTE_ACCESS_ONBOARDING) })
}
}
override fun onStart() {
super.onStart()
preferenceScreen.sharedPreferences!!.registerOnSharedPreferenceChangeListener(this)
}
override fun onStop() {
super.onStop()
preferenceScreen.sharedPreferences!!.unregisterOnSharedPreferenceChangeListener(this)
}
override fun onCreatePreferences(bundle: Bundle?, s: String?) {
super.onCreatePreferences(bundle, s)
settings = Settings.getInstance(activity)

View File

@ -56,13 +56,22 @@ class PreferencesRemoteAccess : BasePreferenceFragment(), SharedPreferences.OnSh
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setHasOptionsMenu(true)
preferenceScreen.sharedPreferences!!.registerOnSharedPreferenceChangeListener(this)
if(!settings.getBoolean(REMOTE_ACCESS_ONBOARDING, false)) {
settings.putSingle(REMOTE_ACCESS_ONBOARDING, true)
startActivity(Intent(Intent.ACTION_VIEW).apply { setClassName(requireActivity(), REMOTE_ACCESS_ONBOARDING) })
}
}
override fun onStart() {
super.onStart()
preferenceScreen.sharedPreferences!!.registerOnSharedPreferenceChangeListener(this)
}
override fun onStop() {
super.onStop()
preferenceScreen.sharedPreferences!!.unregisterOnSharedPreferenceChangeListener(this)
}
override fun onCreatePreferences(bundle: Bundle?, s: String?) {
super.onCreatePreferences(bundle, s)
settings = Settings.getInstance(requireActivity())