File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed
app/src/main/java/fr/free/nrw/commons/contributions Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -538,11 +538,23 @@ private void updateClosestNearbyCardViewInfo() {
538
538
539
539
private void updateNearbyNotification (@ Nullable NearbyController .NearbyPlacesInfo nearbyPlacesInfo ) {
540
540
if (nearbyPlacesInfo != null && nearbyPlacesInfo .placeList != null && nearbyPlacesInfo .placeList .size () > 0 ) {
541
- Place closestNearbyPlace = nearbyPlacesInfo .placeList .get (0 );
542
- String distance = formatDistanceBetween (curLatLng , closestNearbyPlace .___location );
543
- closestNearbyPlace .setDistance (distance );
544
- direction = (float ) computeBearing (curLatLng , closestNearbyPlace .___location );
545
- nearbyNotificationCardView .updateContent (closestNearbyPlace );
541
+ Place closestNearbyPlace = null ;
542
+ // Find the first nearby place that has no image and exists
543
+ for (Place place : nearbyPlacesInfo .placeList ) {
544
+ if (place .pic .equals ("" ) && place .exists ) {
545
+ closestNearbyPlace = place ;
546
+ break ;
547
+ }
548
+ }
549
+
550
+ if (closestNearbyPlace == null ) {
551
+ nearbyNotificationCardView .setVisibility (View .GONE );
552
+ }else {
553
+ String distance = formatDistanceBetween (curLatLng , closestNearbyPlace .___location );
554
+ closestNearbyPlace .setDistance (distance );
555
+ direction = (float ) computeBearing (curLatLng , closestNearbyPlace .___location );
556
+ nearbyNotificationCardView .updateContent (closestNearbyPlace );
557
+ }
546
558
} else {
547
559
// Means that no close nearby place is found
548
560
nearbyNotificationCardView .setVisibility (View .GONE );
You can’t perform that action at this time.
0 commit comments