Browse Source

fix: crash on new notifications with account without color

main
Distopico 5 years ago
parent
commit
1e0665a49d
1 changed files with 6 additions and 12 deletions
  1. +6
    -12
      app/src/main/java/org/dystopia/email/ServiceSynchronize.java

+ 6
- 12
app/src/main/java/org/dystopia/email/ServiceSynchronize.java View File

@ -167,8 +167,7 @@ public class ServiceSynchronize extends LifecycleService {
new Observer<TupleAccountStats>() { new Observer<TupleAccountStats>() {
@Override @Override
public void onChanged(@Nullable TupleAccountStats stats) { public void onChanged(@Nullable TupleAccountStats stats) {
NotificationManager nm =
getSystemService(NotificationManager.class);
NotificationManager nm = getSystemService(NotificationManager.class);
nm.notify( nm.notify(
NOTIFICATION_SYNCHRONIZE, NOTIFICATION_SYNCHRONIZE,
getNotificationService(stats).build()); getNotificationService(stats).build());
@ -185,8 +184,7 @@ public class ServiceSynchronize extends LifecycleService {
@Override @Override
public void onChanged(List<TupleNotification> messages) { public void onChanged(List<TupleNotification> messages) {
NotificationManager nm =
getSystemService(NotificationManager.class);
NotificationManager nm = getSystemService(NotificationManager.class);
Map<Long, ArrayList<TupleNotification>> messagesByAccount = Map<Long, ArrayList<TupleNotification>> messagesByAccount =
new HashMap<>(); new HashMap<>();
@ -201,8 +199,7 @@ public class ServiceSynchronize extends LifecycleService {
newList.add(message); newList.add(message);
if (messagesByAccount.containsKey(accountKey)) { if (messagesByAccount.containsKey(accountKey)) {
ArrayList<TupleNotification> msgList =
messagesByAccount.get(accountKey);
ArrayList<TupleNotification> msgList = messagesByAccount.get(accountKey);
newList.addAll(msgList); newList.addAll(msgList);
} }
@ -211,8 +208,7 @@ public class ServiceSynchronize extends LifecycleService {
Integer accountColor = message.accountColor; Integer accountColor = message.accountColor;
accounts.put( accounts.put(
accountKey, accountKey,
new Pair<String, Integer>(
accountName, accountColor));
new Pair<String, Integer>(accountName, accountColor));
} }
messagesByAccount.put(accountKey, newList); messagesByAccount.put(accountKey, newList);
} }
@ -222,9 +218,7 @@ public class ServiceSynchronize extends LifecycleService {
messagesByAccount.entrySet()) { messagesByAccount.entrySet()) {
Long accountId = messagesAccount.getKey(); Long accountId = messagesAccount.getKey();
List<Notification> notifications = List<Notification> notifications =
getNotificationUnseen(
messagesAccount.getValue(),
accounts.get(accountId));
getNotificationUnseen(messagesAccount.getValue(), accounts.get(accountId));
List<Integer> all = new ArrayList<>(); List<Integer> all = new ArrayList<>();
List<Integer> added = new ArrayList<>(); List<Integer> added = new ArrayList<>();
List<Integer> removed = new ArrayList<>(); List<Integer> removed = new ArrayList<>();
@ -453,7 +447,7 @@ public class ServiceSynchronize extends LifecycleService {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
String accountName = (String) account.first; String accountName = (String) account.first;
Integer accountColor = (int) account.second;
Integer accountColor = (Integer) account.second;
Integer groupColor = Integer groupColor =
accountColor != null accountColor != null
? accountColor ? accountColor


Loading…
Cancel
Save