fix crash in notifications fragment, save account only when notificationid changed

main
Conny Duck 6 years ago
parent 73934e4652
commit f61456d8b3
  1. 24
      app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java

@ -691,19 +691,23 @@ public class NotificationsFragment extends SFragment implements
private void saveNewestNotificationId(List<Notification> notifications) {
AccountEntity account = accountManager.getActiveAccount();
BigInteger lastNoti = new BigInteger(account.getLastNotificationId());
if(account != null) {
BigInteger lastNoti = new BigInteger(account.getLastNotificationId());
for (Notification noti : notifications) {
BigInteger a = new BigInteger(noti.getId());
if (isBiggerThan(a, lastNoti)) {
lastNoti = a;
for (Notification noti : notifications) {
BigInteger a = new BigInteger(noti.getId());
if (isBiggerThan(a, lastNoti)) {
lastNoti = a;
}
}
}
Log.d(TAG, "saving newest noti id: " + lastNoti);
account.setLastNotificationId(lastNoti.toString());
accountManager.saveAccount(account);
String lastNotificationId = lastNoti.toString();
if(!account.getLastNotificationId().equals(lastNotificationId)) {
Log.d(TAG, "saving newest noti id: " + lastNotificationId);
account.setLastNotificationId(lastNotificationId);
accountManager.saveAccount(account);
}
}
}
private boolean isBiggerThan(BigInteger newId, BigInteger lastShownNotificationId) {

Loading…
Cancel
Save