Fix overlay collection modification checks

- Remove check for .add as for ArrayList it is always true and so it is
dead condition
- Add check for removeIf, so the overlay layers will be rebuilt only
when something is removed

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-06-14 16:26:52 +02:00
committed by Abex
parent 0ff91107b7
commit f83f959caf

View File

@@ -114,10 +114,8 @@ public class OverlayManager
return false; return false;
} }
final boolean add = overlays.add(overlay); // Add is always true
overlays.add(overlay);
if (add)
{
final Point location = loadOverlayLocation(overlay); final Point location = loadOverlayLocation(overlay);
overlay.setPreferredLocation(location); overlay.setPreferredLocation(location);
final Dimension size = loadOverlaySize(overlay); final Dimension size = loadOverlaySize(overlay);
@@ -125,9 +123,7 @@ public class OverlayManager
final OverlayPosition position = loadOverlayPosition(overlay); final OverlayPosition position = loadOverlayPosition(overlay);
overlay.setPreferredPosition(position); overlay.setPreferredPosition(position);
rebuildOverlayLayers(); rebuildOverlayLayers();
} return true;
return add;
} }
/** /**
@@ -157,7 +153,12 @@ public class OverlayManager
public synchronized boolean removeIf(Predicate<Overlay> filter) public synchronized boolean removeIf(Predicate<Overlay> filter)
{ {
final boolean removeIf = overlays.removeIf(filter); final boolean removeIf = overlays.removeIf(filter);
if (removeIf)
{
rebuildOverlayLayers(); rebuildOverlayLayers();
}
return removeIf; return removeIf;
} }