Fix NPE when accessing settings screens

Previous PR did not check if preferences to be removed exist on the
current screen and failed when the current screen was not the
notification settings.

Fixes #3782.
This commit is contained in:
Wiktor Kwapisiewicz 2018-12-02 17:50:46 +01:00
parent e6e0d7c1c2
commit 5c2bb43844
No known key found for this signature in database
GPG key ID: B97A1EE09DB417EC

View file

@ -165,10 +165,12 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
}
private fun initializeNotifications() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
PRE_SDK26_NOTIFICATION_PREFERENCES.forEach { findPreference(it).remove() }
} else {
findPreference(PREFERENCE_OPEN_NOTIFICATION_SETTINGS).remove()
findPreference(PREFERENCE_OPEN_NOTIFICATION_SETTINGS)?.let {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
PRE_SDK26_NOTIFICATION_PREFERENCES.forEach { findPreference(it).remove() }
} else {
it.remove()
}
}
}