From f19c36a4ba9adb6d1288a47252a0189aac5033ce Mon Sep 17 00:00:00 2001 From: Tobrun Date: Thu, 20 Jul 2017 10:18:40 +0200 Subject: [PATCH] [android] - avoid creating InfoWindow iterator if no InfoWindows are shown (#9477) --- .../mapboxsdk/maps/InfoWindowManager.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/InfoWindowManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/InfoWindowManager.java index 7599b6afa6c..0b461d12273 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/InfoWindowManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/InfoWindowManager.java @@ -22,7 +22,8 @@ */ class InfoWindowManager { - private List infoWindows; + private final List infoWindows = new ArrayList<>(); + private MapboxMap.InfoWindowAdapter infoWindowAdapter; private boolean allowConcurrentMultipleInfoWindows; @@ -30,13 +31,11 @@ class InfoWindowManager { private MapboxMap.OnInfoWindowLongClickListener onInfoWindowLongClickListener; private MapboxMap.OnInfoWindowCloseListener onInfoWindowCloseListener; - InfoWindowManager() { - this.infoWindows = new ArrayList<>(); - } - void update() { - for (InfoWindow infoWindow : infoWindows) { - infoWindow.update(); + if (!infoWindows.isEmpty()) { + for (InfoWindow infoWindow : infoWindows) { + infoWindow.update(); + } } } @@ -56,10 +55,6 @@ boolean isAllowConcurrentMultipleOpenInfoWindows() { return allowConcurrentMultipleInfoWindows; } - List getInfoWindows() { - return infoWindows; - } - boolean isInfoWindowValidForMarker(@NonNull Marker marker) { return !TextUtils.isEmpty(marker.getTitle()) || !TextUtils.isEmpty(marker.getSnippet()); }