Browse Source

REPORT-54277 消息推送-消息中心-看不到推送的消息

final/10.0
pengda 4 years ago
parent
commit
0c41f0b6ed
  1. 23
      designer-base/src/main/java/com/fr/design/notification/NotificationCenter.java

23
designer-base/src/main/java/com/fr/design/notification/NotificationCenter.java

@ -3,13 +3,14 @@ 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 = new ArrayList<>();
notifications = Collections.synchronizedList(new ArrayList<>());
}
public static NotificationCenter getInstance(){
@ -17,8 +18,10 @@ public class NotificationCenter {
}
public void addNotification(Notification message){
notifications.add(message);
NotificationCenterPane.getNotificationCenterPane().refreshButton();
synchronized (this) {
notifications.add(message);
NotificationCenterPane.getNotificationCenterPane().refreshButton();
}
}
public int getNotificationsCount(){
@ -26,17 +29,21 @@ public class NotificationCenter {
}
public void removeNotification(int index){
notifications.remove(index);
NotificationCenterPane.getNotificationCenterPane().refreshButton();
synchronized (this) {
notifications.remove(index);
NotificationCenterPane.getNotificationCenterPane().refreshButton();
}
}
public Notification getNotification(int index){
return notifications.get(index);
return notifications.get(index);
}
public void clearAllNotifications(){
notifications.clear();
NotificationCenterPane.getNotificationCenterPane().refreshButton();
synchronized (this) {
notifications.clear();
NotificationCenterPane.getNotificationCenterPane().refreshButton();
}
}
}

Loading…
Cancel
Save