From 640d4b0280d06f3b3a107a56d3357def3af2b5ed Mon Sep 17 00:00:00 2001 From: TobiGr Date: Mon, 16 Jan 2023 23:05:29 +0100 Subject: [PATCH] Fix more NPEs after OnSharedPreferenceChangeListener changes --- .../java/org/schabi/newpipe/local/feed/FeedFragment.kt | 2 +- .../newpipe/settings/VideoAudioSettingsFragment.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt index c1ee4e558..26ad1cc38 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt @@ -122,7 +122,7 @@ class FeedFragment : BaseStateFragment() { groupName = arguments?.getString(KEY_GROUP_NAME) ?: "" onSettingsChangeListener = SharedPreferences.OnSharedPreferenceChangeListener { _, key -> - if (key.equals(getString(R.string.list_view_mode_key))) { + if (getString(R.string.list_view_mode_key).equals(key)) { updateListViewModeOnResume = true } } diff --git a/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java index 039f00c1d..aae9cfca5 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java @@ -27,14 +27,14 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment { updateSeekOptions(); - listener = (sharedPreferences, s) -> { + listener = (sharedPreferences, key) -> { // on M and above, if user chooses to minimise to popup player on exit // and the app doesn't have display over other apps permission, // show a snackbar to let the user give permission if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M - && s.equals(getString(R.string.minimize_on_exit_key))) { - final String newSetting = sharedPreferences.getString(s, null); + && getString(R.string.minimize_on_exit_key).equals(key)) { + final String newSetting = sharedPreferences.getString(key, null); if (newSetting != null && newSetting.equals(getString(R.string.minimize_on_exit_popup_key)) && !Settings.canDrawOverlays(getContext())) { @@ -46,7 +46,7 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment { .show(); } - } else if (s.equals(getString(R.string.use_inexact_seek_key))) { + } else if (getString(R.string.use_inexact_seek_key).equals(key)) { updateSeekOptions(); } };