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,20 +114,16 @@ 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);
{ overlay.setPreferredLocation(location);
final Point location = loadOverlayLocation(overlay); final Dimension size = loadOverlaySize(overlay);
overlay.setPreferredLocation(location); overlay.setPreferredSize(size);
final Dimension size = loadOverlaySize(overlay); final OverlayPosition position = loadOverlayPosition(overlay);
overlay.setPreferredSize(size); overlay.setPreferredPosition(position);
final OverlayPosition position = loadOverlayPosition(overlay); rebuildOverlayLayers();
overlay.setPreferredPosition(position); return true;
rebuildOverlayLayers();
}
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);
rebuildOverlayLayers();
if (removeIf)
{
rebuildOverlayLayers();
}
return removeIf; return removeIf;
} }