mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-10-27 13:28:01 +00:00
Fix random NullPointerException in NotificationActionsPreference
This commit is contained in:
@@ -17,6 +17,7 @@ import android.widget.TextView;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.content.res.AppCompatResources;
|
import androidx.appcompat.content.res.AppCompatResources;
|
||||||
import androidx.core.graphics.drawable.DrawableCompat;
|
import androidx.core.graphics.drawable.DrawableCompat;
|
||||||
@@ -41,9 +42,8 @@ public class NotificationActionsPreference extends Preference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private NotificationSlot[] notificationSlots;
|
@Nullable private NotificationSlot[] notificationSlots = null;
|
||||||
|
@Nullable private List<Integer> compactSlots = null;
|
||||||
private List<Integer> compactSlots;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// Lifecycle
|
// Lifecycle
|
||||||
@@ -85,10 +85,12 @@ public class NotificationActionsPreference extends Preference {
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private void saveChanges() {
|
private void saveChanges() {
|
||||||
|
if (compactSlots != null && notificationSlots != null) {
|
||||||
final SharedPreferences.Editor editor = getSharedPreferences().edit();
|
final SharedPreferences.Editor editor = getSharedPreferences().edit();
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
editor.putInt(getContext().getString(NotificationConstants.SLOT_COMPACT_PREF_KEYS[i]),
|
editor.putInt(getContext().getString(
|
||||||
|
NotificationConstants.SLOT_COMPACT_PREF_KEYS[i]),
|
||||||
(i < compactSlots.size() ? compactSlots.get(i) : -1));
|
(i < compactSlots.size() ? compactSlots.get(i) : -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +101,7 @@ public class NotificationActionsPreference extends Preference {
|
|||||||
|
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user