Enhancement - Nearby banner shows Item without image (#5468)

* Enhancement Nearby banner shows Item without image

* spacing

* Enhancement Nearby banner shows Item without image

* spacing

* Fix Crash

* Reverted "Fix Crash"

This reverts commit a41c9362bb.

* Fixed

* Fix null location

* Fix Conflict

* Show Only Items that exists

---------

Co-authored-by: shashankkumar <shashankkumar45556@gmail.com>
Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
Shashank Kumar 2024-02-01 18:47:52 +05:30 committed by GitHub
parent 60046f4881
commit 72a6fd2c90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -538,11 +538,23 @@ public class ContributionsFragment
private void updateNearbyNotification(@Nullable NearbyController.NearbyPlacesInfo nearbyPlacesInfo) { private void updateNearbyNotification(@Nullable NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
if (nearbyPlacesInfo != null && nearbyPlacesInfo.placeList != null && nearbyPlacesInfo.placeList.size() > 0) { if (nearbyPlacesInfo != null && nearbyPlacesInfo.placeList != null && nearbyPlacesInfo.placeList.size() > 0) {
Place closestNearbyPlace = nearbyPlacesInfo.placeList.get(0); Place closestNearbyPlace = null;
String distance = formatDistanceBetween(curLatLng, closestNearbyPlace.location); // Find the first nearby place that has no image and exists
closestNearbyPlace.setDistance(distance); for (Place place : nearbyPlacesInfo.placeList) {
direction = (float) computeBearing(curLatLng, closestNearbyPlace.location); if (place.pic.equals("") && place.exists) {
nearbyNotificationCardView.updateContent(closestNearbyPlace); closestNearbyPlace = place;
break;
}
}
if(closestNearbyPlace == null) {
nearbyNotificationCardView.setVisibility(View.GONE);
}else{
String distance = formatDistanceBetween(curLatLng, closestNearbyPlace.location);
closestNearbyPlace.setDistance(distance);
direction = (float) computeBearing(curLatLng, closestNearbyPlace.location);
nearbyNotificationCardView.updateContent(closestNearbyPlace);
}
} else { } else {
// Means that no close nearby place is found // Means that no close nearby place is found
nearbyNotificationCardView.setVisibility(View.GONE); nearbyNotificationCardView.setVisibility(View.GONE);