From 99ef945be2ca5fb6708354baca31b9ddff4e0d3a Mon Sep 17 00:00:00 2001 From: stom79 Date: Mon, 6 Nov 2017 18:08:22 +0100 Subject: [PATCH] Avoids null pointer --- .../fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java b/app/src/main/java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java index 365923ce6..855b3595b 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/jobs/NotificationsSyncJob.java @@ -247,7 +247,7 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications super.onLoadingComplete(imageUri, view, loadedImage); notify_user(getContext(), intent, notificationId, loadedImage, finalTitle, message); String lastNotif = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + userId, null); - if( Long.parseLong(notifications.get(0).getId()) > Long.parseLong(lastNotif)){ + if( lastNotif == null || Long.parseLong(notifications.get(0).getId()) > Long.parseLong(lastNotif)){ SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + userId, notifications.get(0).getId()); editor.apply(); @@ -258,7 +258,7 @@ public class NotificationsSyncJob extends Job implements OnRetrieveNotifications notify_user(getContext(), intent, notificationId, BitmapFactory.decodeResource(getContext().getResources(), R.drawable.mastodonlogo), finalTitle, message); String lastNotif = sharedpreferences.getString(Helper.LAST_NOTIFICATION_MAX_ID + userId, null); - if( Long.parseLong(notifications.get(0).getId()) > Long.parseLong(lastNotif)){ + if( lastNotif == null || Long.parseLong(notifications.get(0).getId()) > Long.parseLong(lastNotif)){ SharedPreferences.Editor editor = sharedpreferences.edit(); editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + userId, notifications.get(0).getId()); editor.apply();