Skip to content

Commit 29bea33

Browse files
cypheropmaskaravivek
authored andcommitted
hide the notification card if there's no nearby location (#2396)
* hide the notification card if there's no nearby location * some minor changes
1 parent ea45335 commit 29bea33

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,10 +615,11 @@ private void updateNearbyNotification(@Nullable NearbyController.NearbyPlacesInf
615615
Place closestNearbyPlace = nearbyPlacesInfo.placeList.get(0);
616616
String distance = formatDistanceBetween(curLatLng, closestNearbyPlace.location);
617617
closestNearbyPlace.setDistance(distance);
618-
nearbyNotificationCardView.updateContent (true, closestNearbyPlace);
618+
nearbyNotificationCardView.updateContent(closestNearbyPlace);
619+
nearbyNotificationCardView.setVisibility(View.VISIBLE);
619620
} else {
620621
// Means that no close nearby place is found
621-
nearbyNotificationCardView.updateContent (false, null);
622+
nearbyNotificationCardView.setVisibility(View.GONE);
622623
}
623624
}
624625

app/src/main/java/fr/free/nrw/commons/nearby/NearbyNotificationCardView.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,9 @@ private void succeeded() {
116116

117117
/**
118118
* Pass place information to views.
119-
* @param isClosestNearbyPlaceFound false if there are no close place
120119
* @param place Closes place where we will get information from
121120
*/
122-
public void updateContent(boolean isClosestNearbyPlaceFound, Place place) {
121+
public void updateContent(Place place) {
123122
Timber.d("Update nearby card notification content");
124123
this.setVisibility(VISIBLE);
125124
cardViewVisibilityState = CardViewVisibilityState.READY;
@@ -131,14 +130,9 @@ public void updateContent(boolean isClosestNearbyPlaceFound, Place place) {
131130
notificationTitle.setVisibility(VISIBLE);
132131
notificationDistance.setVisibility(VISIBLE);
133132
notificationIcon.setVisibility(VISIBLE);
133+
notificationTitle.setText(place.name);
134+
notificationDistance.setText(place.distance);
134135

135-
if (isClosestNearbyPlaceFound) {
136-
notificationTitle.setText(place.name);
137-
notificationDistance.setText(place.distance);
138-
} else {
139-
notificationDistance.setText("");
140-
notificationTitle.setText(R.string.no_close_nearby);
141-
}
142136
}
143137

144138
@Override

0 commit comments

Comments
 (0)