Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some random NullPointerExceptions #5944

Merged
merged 3 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,9 @@ public void onComplete() { }
@Override
public void setTitle(final String title) {
super.setTitle(title);
headerBinding.playlistTitleView.setText(title);
if (headerBinding != null) {
headerBinding.playlistTitleView.setText(title);
}
}

private void onBookmarkClicked() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
@State
boolean wasSearchFocused = false;

private Map<Integer, String> menuItemToFilterName;
@Nullable private Map<Integer, String> menuItemToFilterName = null;
Stypox marked this conversation as resolved.
Show resolved Hide resolved
private StreamingService service;
private Page nextPage;
private boolean isSuggestionsEnabled = true;
Expand Down Expand Up @@ -455,11 +455,12 @@ public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
}

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
final List<String> 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<String> cf = new ArrayList<>(1);
cf.add(menuItemToFilterName.get(item.getItemId()));
changeContentFilter(item, cf);
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
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;
Expand All @@ -41,9 +42,8 @@ public NotificationActionsPreference(final Context context, final AttributeSet a
}


private NotificationSlot[] notificationSlots;

private List<Integer> compactSlots;
@Nullable private NotificationSlot[] notificationSlots = null;
@Nullable private List<Integer> compactSlots = null;

////////////////////////////////////////////////////////////////////////////
// Lifecycle
Expand Down Expand Up @@ -85,19 +85,22 @@ private void setupActions(@NonNull final View view) {
////////////////////////////////////////////////////////////////////////////

private void saveChanges() {
final SharedPreferences.Editor editor = getSharedPreferences().edit();
if (compactSlots != null && notificationSlots != null) {
Stypox marked this conversation as resolved.
Show resolved Hide resolved
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);
}
for (int i = 0; i < 5; i++) {
editor.putInt(getContext().getString(NotificationConstants.SLOT_PREF_KEYS[i]),
notificationSlots[i].selectedAction);
}

editor.apply();
editor.apply();
}
}


Expand Down