do not show duplicate popups

This commit is contained in:
woodser 2025-07-20 10:06:06 -04:00 committed by woodser
parent 9f55c5d648
commit 79dbe34359

View file

@ -32,10 +32,15 @@ public class PopupManager {
private static Popup displayedPopup; private static Popup displayedPopup;
public static void queueForDisplay(Popup popup) { public static void queueForDisplay(Popup popup) {
if (hasDuplicatePopup(popup)) {
log.warn("The popup is already in the queue or displayed.\n\t" +
"New popup not added=" + popup);
return;
}
boolean result = popups.offer(popup); boolean result = popups.offer(popup);
if (!result) if (!result)
log.warn("The capacity is full with popups in the queue.\n\t" + log.warn("The capacity is full with popups in the queue.\n\t" +
"Not added new popup=" + popup); "New popup not added=" + popup);
displayNext(); displayNext();
} }
@ -57,4 +62,16 @@ public class PopupManager {
} }
} }
} }
private static boolean hasDuplicatePopup(Popup popup) {
if (displayedPopup != null && displayedPopup.toString().equals(popup.toString())) {
return true;
}
for (Popup p : popups) {
if (p.toString().equals(popup.toString())) {
return true;
}
}
return false;
}
} }