mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
fix-issue-4424 (#4445)
Co-authored-by: Pratham2305 <Pratham2305@users.noreply.github.com>
This commit is contained in:
parent
a3cbe3659c
commit
3494fd05a2
1 changed files with 38 additions and 13 deletions
|
|
@ -222,6 +222,15 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
private PlaceAdapter adapter;
|
private PlaceAdapter adapter;
|
||||||
private NearbyParentFragmentInstanceReadyCallback nearbyParentFragmentInstanceReadyCallback;
|
private NearbyParentFragmentInstanceReadyCallback nearbyParentFragmentInstanceReadyCallback;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds filtered markers that are to be shown
|
||||||
|
*/
|
||||||
|
private List<NearbyBaseMarker> filteredMarkers;
|
||||||
|
/**
|
||||||
|
* Holds all the markers
|
||||||
|
*/
|
||||||
|
private List<NearbyBaseMarker> allMarkers;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static NearbyParentFragment newInstance() {
|
public static NearbyParentFragment newInstance() {
|
||||||
NearbyParentFragment fragment = new NearbyParentFragment();
|
NearbyParentFragment fragment = new NearbyParentFragment();
|
||||||
|
|
@ -1241,6 +1250,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
// Remove the previous markers before updating them
|
// Remove the previous markers before updating them
|
||||||
hideAllMarkers();
|
hideAllMarkers();
|
||||||
|
|
||||||
|
filteredMarkers = new ArrayList<>();
|
||||||
|
|
||||||
for (final MarkerPlaceGroup markerPlaceGroup : NearbyController.markerLabelList) {
|
for (final MarkerPlaceGroup markerPlaceGroup : NearbyController.markerLabelList) {
|
||||||
final Place place = markerPlaceGroup.getPlace();
|
final Place place = markerPlaceGroup.getPlace();
|
||||||
|
|
||||||
|
|
@ -1272,6 +1283,9 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
updateMarker(markerPlaceGroup.getIsBookmarked(), place, NearbyController.currentLocation);
|
updateMarker(markerPlaceGroup.getIsBookmarked(), place, NearbyController.currentLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mapBox.clear();
|
||||||
|
mapBox.addMarkers(filteredMarkers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1289,25 +1303,35 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
VectorDrawableCompat vectorDrawable = VectorDrawableCompat.create(
|
VectorDrawableCompat vectorDrawable = VectorDrawableCompat.create(
|
||||||
getContext().getResources(), getIconFor(place, isBookmarked), getContext().getTheme());
|
getContext().getResources(), getIconFor(place, isBookmarked), getContext().getTheme());
|
||||||
|
|
||||||
for (Marker marker : mapBox.getMarkers()) {
|
if(curLatLng != null) {
|
||||||
if (marker.getTitle() != null && marker.getTitle().equals(place.getName())) {
|
for (NearbyBaseMarker nearbyMarker : allMarkers) {
|
||||||
|
if (nearbyMarker.getMarker().getTitle() != null && nearbyMarker.getMarker().getTitle().equals(place.getName())) {
|
||||||
|
|
||||||
|
final Bitmap icon = UiUtils.getBitmap(vectorDrawable);
|
||||||
|
|
||||||
final Bitmap icon = UiUtils.getBitmap(vectorDrawable);
|
|
||||||
if (curLatLng != null) {
|
|
||||||
final String distance = formatDistanceBetween(curLatLng, place.location);
|
final String distance = formatDistanceBetween(curLatLng, place.location);
|
||||||
place.setDistance(distance);
|
place.setDistance(distance);
|
||||||
}
|
|
||||||
|
|
||||||
final NearbyBaseMarker nearbyBaseMarker = new NearbyBaseMarker();
|
final NearbyBaseMarker nearbyBaseMarker = new NearbyBaseMarker();
|
||||||
nearbyBaseMarker.title(place.name);
|
nearbyBaseMarker.title(place.name);
|
||||||
nearbyBaseMarker.position(
|
nearbyBaseMarker.position(
|
||||||
new com.mapbox.mapboxsdk.geometry.LatLng(
|
new com.mapbox.mapboxsdk.geometry.LatLng(
|
||||||
place.location.getLatitude(),
|
place.location.getLatitude(),
|
||||||
place.location.getLongitude()));
|
place.location.getLongitude()));
|
||||||
nearbyBaseMarker.place(place);
|
nearbyBaseMarker.place(place);
|
||||||
nearbyBaseMarker.icon(IconFactory.getInstance(getContext())
|
nearbyBaseMarker.icon(IconFactory.getInstance(getContext())
|
||||||
.fromBitmap(icon));
|
.fromBitmap(icon));
|
||||||
marker.setIcon(IconFactory.getInstance(getContext()).fromBitmap(icon));
|
nearbyMarker.setIcon(IconFactory.getInstance(getContext()).fromBitmap(icon));
|
||||||
|
filteredMarkers.add(nearbyBaseMarker);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (Marker marker : mapBox.getMarkers()) {
|
||||||
|
if (marker.getTitle() != null && marker.getTitle().equals(place.getName())) {
|
||||||
|
|
||||||
|
final Bitmap icon = UiUtils.getBitmap(vectorDrawable);
|
||||||
|
marker.setIcon(IconFactory.getInstance(getContext()).fromBitmap(icon));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1348,6 +1372,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
|
|
||||||
private void addNearbyMarkersToMapBoxMap(final List<NearbyBaseMarker> nearbyBaseMarkers, final Marker selectedMarker) {
|
private void addNearbyMarkersToMapBoxMap(final List<NearbyBaseMarker> nearbyBaseMarkers, final Marker selectedMarker) {
|
||||||
if (isMapBoxReady && mapBox != null) {
|
if (isMapBoxReady && mapBox != null) {
|
||||||
|
allMarkers = new ArrayList<>(nearbyBaseMarkers);
|
||||||
mapBox.addMarkers(nearbyBaseMarkers);
|
mapBox.addMarkers(nearbyBaseMarkers);
|
||||||
setMapMarkerActions(selectedMarker);
|
setMapMarkerActions(selectedMarker);
|
||||||
presenter.updateMapMarkersToController(nearbyBaseMarkers);
|
presenter.updateMapMarkersToController(nearbyBaseMarkers);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue