Skip to content

Commit e260046

Browse files
CloeARivaashishkumar468
authored andcommitted
Nearby: make list resize and display message when empty (commons-app#3746)
* Nearby: make list resize and display message when empty * refactored and renamed for clarity * refactoring and simplifying based on comments * refactoring and simplifying based on comments * removing vertical orientation
1 parent 1765b23 commit e260046

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java

+3
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
154154
MapView mapView;
155155
@BindView(R.id.rv_nearby_list)
156156
RecyclerView rvNearbyList;
157+
@BindView(R.id.no_results_message) TextView noResultsView;
157158

158159
@Inject LocationServiceManager locationManager;
159160
@Inject NearbyController nearbyController;
@@ -626,6 +627,7 @@ public void centerMapToPlace(Place place) {
626627
@Override
627628
public void updateListFragment(List<Place> placeList) {
628629
adapterFactory.updateAdapterData(placeList, (RVRendererAdapter<Place>) rvNearbyList.getAdapter());
630+
noResultsView.setVisibility(placeList.size() <= 0 ? View.VISIBLE : View.GONE);
629631
}
630632

631633
public void clearNearbyList() {
@@ -634,6 +636,7 @@ public void clearNearbyList() {
634636

635637
public void updateNearbyList() {
636638
adapterFactory.update((RVRendererAdapter<Place>) rvNearbyList.getAdapter());
639+
noResultsView.setVisibility(rvNearbyList.getAdapter().getItemCount() <= 0 ? View.VISIBLE : View.GONE);
637640
}
638641

639642
public void addPlaceToNearbyList(Place place) {

app/src/main/res/values/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -628,5 +628,6 @@ Upload your first media by tapping on the add button.</string>
628628
<string name="ask_to_turn_location_on">Turn on location?</string>
629629
<string name="nearby_needs_location">Nearby needs location enabled to work properly</string>
630630
<string name="use_location_from_similar_image">Did you shoot these two pictures at the same place? Do you want to use the latitude/longitude of the picture on the right?</string>
631+
<string name="nearby_no_results">No places found, try changing your search criteria.</string>
631632

632633
</resources>

0 commit comments

Comments
 (0)