Handle null context and drawable in nearby map fragment

This commit is contained in:
Vivek Maskara 2020-02-07 12:34:03 -07:00
parent 61bfe84594
commit b8040aef39

View file

@ -558,12 +558,19 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment
* Greys out all markers except current location marker * Greys out all markers except current location marker
*/ */
public void greyOutAllMarkers() { public void greyOutAllMarkers() {
VectorDrawableCompat vectorDrawable; if (getContext() == null) {
vectorDrawable = VectorDrawableCompat.create( Timber.d("Context is null. Skipping greying out of all markers");
return;
}
VectorDrawableCompat vectorDrawable = VectorDrawableCompat.create(
getContext().getResources(), R.drawable.ic_custom_greyed_out_marker, getContext().getTheme()); getContext().getResources(), R.drawable.ic_custom_greyed_out_marker, getContext().getTheme());
if (vectorDrawable == null) {
Timber.d("Vector drawable ic_custom_greyed_out_marker is null");
return;
}
Bitmap icon = UiUtils.getBitmap(vectorDrawable); Bitmap icon = UiUtils.getBitmap(vectorDrawable);
for (Marker marker : mapboxMap.getMarkers()) { for (Marker marker : mapboxMap.getMarkers()) {
if (currentLocationMarker.getTitle() != marker.getTitle()) { if (!currentLocationMarker.getTitle().equals(marker.getTitle())) {
marker.setIcon(IconFactory.getInstance(getContext()).fromBitmap(icon)); marker.setIcon(IconFactory.getInstance(getContext()).fromBitmap(icon));
} }
} }