From ee1efa4f7f5d9c49fae18596ca546c5b037e263a Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Mon, 12 Feb 2018 11:15:44 +0100 Subject: [PATCH] NotificationStore: add synchronisation when accessing internal store. --- .../plugins/Overview/notifications/NotificationStore.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationStore.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationStore.java index 1ce92249f7..f66651fa03 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationStore.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/NotificationStore.java @@ -44,11 +44,11 @@ public class NotificationStore { } } - public Notification get(int index) { + public synchronized Notification get(int index) { return store.get(index); } - public void add(Notification n) { + public synchronized void add(Notification n) { log.info("Notification received: " + n.text); for (int i = 0; i < store.size(); i++) { if (get(i).id == n.id) { @@ -96,7 +96,7 @@ public class NotificationStore { mgr.notify(n.id, notificationBuilder.build()); } - public boolean remove(int id) { + public synchronized boolean remove(int id) { for (int i = 0; i < store.size(); i++) { if (get(i).id == id) { if (get(i).soundId != null) { @@ -110,7 +110,7 @@ public class NotificationStore { return false; } - public void removeExpired() { + public synchronized void removeExpired() { for (int i = 0; i < store.size(); i++) { Notification n = get(i); if (n.validTo.getTime() != 0 && n.validTo.getTime() < System.currentTimeMillis()) {