Skip to content

Commit 7084fd2

Browse files
authored
Nearby: make list resize and display message when empty (#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 fbd057b commit 7084fd2

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
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/layout/bottom_sheet_nearby.xml

+18-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,29 @@
33
android:id="@+id/bottom_sheet"
44
android:layout_width="match_parent"
55
android:layout_height="match_parent"
6-
android:orientation="vertical"
6+
android:gravity="bottom"
77
app:behavior_hideable="true"
88
android:visibility="visible"
99
app:layout_behavior="@string/bottom_sheet_behavior"
10-
android:background="@android:color/white">
10+
android:background="@android:color/transparent">
11+
12+
<RelativeLayout
13+
android:layout_width="match_parent"
14+
android:layout_height="wrap_content"
15+
android:background="@android:color/white">
16+
17+
<TextView
18+
android:id="@+id/no_results_message"
19+
android:layout_width="match_parent"
20+
android:layout_height="wrap_content"
21+
android:padding="50dp"
22+
android:layout_centerInParent="true"
23+
android:visibility="gone"
24+
android:text="@string/nearby_no_results"/>
1125

1226
<androidx.recyclerview.widget.RecyclerView
1327
android:id="@+id/rv_nearby_list"
1428
android:layout_width="match_parent"
15-
android:layout_height="match_parent" />
29+
android:layout_height="wrap_content"/>
30+
</RelativeLayout>
1631
</RelativeLayout>

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)