fix crash in notifications fragment, save account only when notificationid changed
This commit is contained in:
parent
5131c44e93
commit
f72e08cae4
|
@ -691,6 +691,7 @@ public class NotificationsFragment extends SFragment implements
|
||||||
private void saveNewestNotificationId(List<Notification> notifications) {
|
private void saveNewestNotificationId(List<Notification> notifications) {
|
||||||
|
|
||||||
AccountEntity account = accountManager.getActiveAccount();
|
AccountEntity account = accountManager.getActiveAccount();
|
||||||
|
if(account != null) {
|
||||||
BigInteger lastNoti = new BigInteger(account.getLastNotificationId());
|
BigInteger lastNoti = new BigInteger(account.getLastNotificationId());
|
||||||
|
|
||||||
for (Notification noti : notifications) {
|
for (Notification noti : notifications) {
|
||||||
|
@ -700,11 +701,14 @@ public class NotificationsFragment extends SFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG, "saving newest noti id: " + lastNoti);
|
String lastNotificationId = lastNoti.toString();
|
||||||
|
if(!account.getLastNotificationId().equals(lastNotificationId)) {
|
||||||
account.setLastNotificationId(lastNoti.toString());
|
Log.d(TAG, "saving newest noti id: " + lastNotificationId);
|
||||||
|
account.setLastNotificationId(lastNotificationId);
|
||||||
accountManager.saveAccount(account);
|
accountManager.saveAccount(account);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isBiggerThan(BigInteger newId, BigInteger lastShownNotificationId) {
|
private boolean isBiggerThan(BigInteger newId, BigInteger lastShownNotificationId) {
|
||||||
return lastShownNotificationId.compareTo(newId) < 0;
|
return lastShownNotificationId.compareTo(newId) < 0;
|
||||||
|
|
Loading…
Reference in New Issue