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