Get Singleton Notification
This commit is contained in:
parent
d42794137f
commit
1282e3ed9e
1 changed files with 14 additions and 1 deletions
|
@ -52,6 +52,7 @@ import info.nightscout.androidaps.utils.DecimalFormatter;
|
|||
public class PersistentNotificationPlugin extends PluginBase {
|
||||
|
||||
private static PersistentNotificationPlugin plugin;
|
||||
private Notification notification;
|
||||
|
||||
public static PersistentNotificationPlugin getPlugin() {
|
||||
if (plugin == null) plugin = new PersistentNotificationPlugin(MainApp.instance());
|
||||
|
@ -122,7 +123,7 @@ public class PersistentNotificationPlugin extends PluginBase {
|
|||
}
|
||||
|
||||
@Nonnull
|
||||
public Notification updateNotification() {
|
||||
Notification updateNotification() {
|
||||
String line1 = null;
|
||||
String line2 = null;
|
||||
String line3 = null;
|
||||
|
@ -250,6 +251,7 @@ public class PersistentNotificationPlugin extends PluginBase {
|
|||
|
||||
android.app.Notification notification = builder.build();
|
||||
mNotificationManager.notify(ONGOING_NOTIFICATION_ID, notification);
|
||||
this.notification = notification;
|
||||
return notification;
|
||||
}
|
||||
|
||||
|
@ -269,6 +271,17 @@ public class PersistentNotificationPlugin extends PluginBase {
|
|||
return deltastring;
|
||||
}
|
||||
|
||||
/***
|
||||
* returns the current ongoing notification.
|
||||
*
|
||||
* If it does not exist, return a dummy notification. This should only happen if onStart() wasn't called.
|
||||
*/
|
||||
|
||||
public Notification getLastNotification() {
|
||||
if (notification != null) return notification;
|
||||
else return new Notification();
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventPreferenceChange ev) {
|
||||
|
|
Loading…
Reference in a new issue