Skip to content

Commit b8040ae

Browse files
committed
Handle null context and drawable in nearby map fragment
1 parent 61bfe84 commit b8040ae

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyMapFragment.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,19 @@ public void updateMarker(boolean isBookmarked, Place place, @Nullable LatLng cur
558558
* Greys out all markers except current location marker
559559
*/
560560
public void greyOutAllMarkers() {
561-
VectorDrawableCompat vectorDrawable;
562-
vectorDrawable = VectorDrawableCompat.create(
561+
if (getContext() == null) {
562+
Timber.d("Context is null. Skipping greying out of all markers");
563+
return;
564+
}
565+
VectorDrawableCompat vectorDrawable = VectorDrawableCompat.create(
563566
getContext().getResources(), R.drawable.ic_custom_greyed_out_marker, getContext().getTheme());
567+
if (vectorDrawable == null) {
568+
Timber.d("Vector drawable ic_custom_greyed_out_marker is null");
569+
return;
570+
}
564571
Bitmap icon = UiUtils.getBitmap(vectorDrawable);
565572
for (Marker marker : mapboxMap.getMarkers()) {
566-
if (currentLocationMarker.getTitle() != marker.getTitle()) {
573+
if (!currentLocationMarker.getTitle().equals(marker.getTitle())) {
567574
marker.setIcon(IconFactory.getInstance(getContext()).fromBitmap(icon));
568575
}
569576
}

0 commit comments

Comments
 (0)