diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java index 114947923..e20df67a1 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/playlist/PlaylistFragment.java @@ -423,7 +423,9 @@ public class PlaylistFragment extends BaseListInfoFragment { @Override public void setTitle(final String title) { super.setTitle(title); - headerBinding.playlistTitleView.setText(title); + if (headerBinding != null) { + headerBinding.playlistTitleView.setText(title); + } } private void onBookmarkClicked() { diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java index 26360137e..76d9d6e38 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/search/SearchFragment.java @@ -139,7 +139,7 @@ public class SearchFragment extends BaseListFragment menuItemToFilterName; + @Nullable private Map menuItemToFilterName = null; private StreamingService service; private Page nextPage; private boolean isSuggestionsEnabled = true; @@ -455,11 +455,12 @@ public class SearchFragment extends BaseListFragment cf = new ArrayList<>(1); - cf.add(menuItemToFilterName.get(item.getItemId())); - changeContentFilter(item, cf); - + public boolean onOptionsItemSelected(@NonNull final MenuItem item) { + if (menuItemToFilterName != null) { + final List cf = new ArrayList<>(1); + cf.add(menuItemToFilterName.get(item.getItemId())); + changeContentFilter(item, cf); + } return true; } diff --git a/app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java b/app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java index e50c858ca..045e574be 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java +++ b/app/src/main/java/org/schabi/newpipe/settings/custom/NotificationActionsPreference.java @@ -17,6 +17,7 @@ import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.content.res.AppCompatResources; import androidx.core.graphics.drawable.DrawableCompat; @@ -41,9 +42,8 @@ public class NotificationActionsPreference extends Preference { } - private NotificationSlot[] notificationSlots; - - private List compactSlots; + @Nullable private NotificationSlot[] notificationSlots = null; + @Nullable private List compactSlots = null; //////////////////////////////////////////////////////////////////////////// // Lifecycle @@ -85,19 +85,22 @@ public class NotificationActionsPreference extends Preference { //////////////////////////////////////////////////////////////////////////// private void saveChanges() { - final SharedPreferences.Editor editor = getSharedPreferences().edit(); + if (compactSlots != null && notificationSlots != null) { + final SharedPreferences.Editor editor = getSharedPreferences().edit(); - for (int i = 0; i < 3; i++) { - editor.putInt(getContext().getString(NotificationConstants.SLOT_COMPACT_PREF_KEYS[i]), - (i < compactSlots.size() ? compactSlots.get(i) : -1)); + for (int i = 0; i < 3; i++) { + editor.putInt(getContext().getString( + NotificationConstants.SLOT_COMPACT_PREF_KEYS[i]), + (i < compactSlots.size() ? compactSlots.get(i) : -1)); + } + + for (int i = 0; i < 5; i++) { + editor.putInt(getContext().getString(NotificationConstants.SLOT_PREF_KEYS[i]), + notificationSlots[i].selectedAction); + } + + editor.apply(); } - - for (int i = 0; i < 5; i++) { - editor.putInt(getContext().getString(NotificationConstants.SLOT_PREF_KEYS[i]), - notificationSlots[i].selectedAction); - } - - editor.apply(); }