Skip to content

Commit 72a6fd2

Browse files
shashankiitbhushashank666nicolas-raoul
authored
Enhancement - Nearby banner shows Item without image (commons-app#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 a41c936. * Fixed * Fix null ___location * Fix Conflict * Show Only Items that exists --------- Co-authored-by: shashankkumar <[email protected]> Co-authored-by: Nicolas Raoul <[email protected]>
1 parent 60046f4 commit 72a6fd2

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

app/src/main/java/fr/free/nrw/commons/contributions/ContributionsFragment.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,23 @@ private void updateClosestNearbyCardViewInfo() {
538538

539539
private void updateNearbyNotification(@Nullable NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
540540
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+
}
546558
} else {
547559
// Means that no close nearby place is found
548560
nearbyNotificationCardView.setVisibility(View.GONE);

0 commit comments

Comments
 (0)