Skip to content

Commit 3e08f39

Browse files
committed
Style green markers at nearby controller
1 parent 2ac38a1 commit 3e08f39

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

app/src/main/java/fr/free/nrw/commons/nearby/NearbyController.java

+16-4
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public static List<NearbyBaseMarker> loadAttractionsFromLocationToBaseMarkerOpti
158158
placeList = placeList.subList(0, Math.min(placeList.size(), MAX_RESULTS));
159159

160160
VectorDrawableCompat vectorDrawable = null;
161+
VectorDrawableCompat vectorDrawableGreen = null;
161162
try {
162163
vectorDrawable = VectorDrawableCompat.create(
163164
context.getResources(), R.drawable.ic_custom_bookmark_marker, context.getTheme()
@@ -191,13 +192,15 @@ public static List<NearbyBaseMarker> loadAttractionsFromLocationToBaseMarkerOpti
191192
vectorDrawable = null;
192193
try {
193194
vectorDrawable = VectorDrawableCompat.create(
194-
context.getResources(), R.drawable.ic_custom_map_marker, context.getTheme()
195-
);
195+
context.getResources(), R.drawable.ic_custom_map_marker, context.getTheme());
196+
vectorDrawableGreen = VectorDrawableCompat.create(
197+
context.getResources(), R.drawable.ic_custom_map_marker_green, context.getTheme());
196198
} catch (Resources.NotFoundException e) {
197199
// ignore when running tests.
198200
}
199201
if (vectorDrawable != null) {
200202
Bitmap icon = UiUtils.getBitmap(vectorDrawable);
203+
Bitmap iconGreen = UiUtils.getBitmap(vectorDrawableGreen);
201204

202205
for (Place place : placeList) {
203206
String distance = formatDistanceBetween(curLatLng, place.location);
@@ -210,8 +213,17 @@ public static List<NearbyBaseMarker> loadAttractionsFromLocationToBaseMarkerOpti
210213
place.location.getLatitude(),
211214
place.location.getLongitude()));
212215
nearbyBaseMarker.place(place);
213-
nearbyBaseMarker.icon(IconFactory.getInstance(context)
214-
.fromBitmap(icon));
216+
// Check if string is only spaces or empty, if so place doesn't have any picture
217+
if (!place.pic.trim().isEmpty()) {
218+
219+
if (iconGreen != null) {
220+
nearbyBaseMarker.icon(IconFactory.getInstance(context)
221+
.fromBitmap(iconGreen));
222+
}
223+
} else {
224+
nearbyBaseMarker.icon(IconFactory.getInstance(context)
225+
.fromBitmap(icon));
226+
}
215227

216228
baseMarkerOptions.add(nearbyBaseMarker);
217229
}

0 commit comments

Comments
 (0)