|
|
|
@ -3,14 +3,13 @@ package com.fr.design.notification;
|
|
|
|
|
|
|
|
|
|
import com.fr.design.notification.ui.NotificationCenterPane; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
public class NotificationCenter { |
|
|
|
|
private static NotificationCenter notificationCenter = new NotificationCenter(); |
|
|
|
|
private List<Notification> notifications; |
|
|
|
|
private NotificationCenter(){ |
|
|
|
|
notifications = Collections.synchronizedList(new ArrayList<>()); |
|
|
|
|
notifications = new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static NotificationCenter getInstance(){ |
|
|
|
@ -18,10 +17,8 @@ public class NotificationCenter {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void addNotification(Notification message){ |
|
|
|
|
synchronized (this) { |
|
|
|
|
notifications.add(message); |
|
|
|
|
NotificationCenterPane.getNotificationCenterPane().refreshButton(); |
|
|
|
|
} |
|
|
|
|
notifications.add(message); |
|
|
|
|
NotificationCenterPane.getNotificationCenterPane().refreshButton(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int getNotificationsCount(){ |
|
|
|
@ -29,10 +26,8 @@ public class NotificationCenter {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void removeNotification(int index){ |
|
|
|
|
synchronized (this) { |
|
|
|
|
notifications.remove(index); |
|
|
|
|
NotificationCenterPane.getNotificationCenterPane().refreshButton(); |
|
|
|
|
} |
|
|
|
|
notifications.remove(index); |
|
|
|
|
NotificationCenterPane.getNotificationCenterPane().refreshButton(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Notification getNotification(int index){ |
|
|
|
@ -40,10 +35,8 @@ public class NotificationCenter {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void clearAllNotifications(){ |
|
|
|
|
synchronized (this) { |
|
|
|
|
notifications.clear(); |
|
|
|
|
NotificationCenterPane.getNotificationCenterPane().refreshButton(); |
|
|
|
|
} |
|
|
|
|
notifications.clear(); |
|
|
|
|
NotificationCenterPane.getNotificationCenterPane().refreshButton(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|