Skip to content

Commit a7a2b51

Browse files
97balakrishnanVivek Maskara
authored andcommitted
Addition: Pull down to refresh in nearby activity (commons-app#1164)
* added pull down to refresh in nearby activity * Requested changes made
1 parent 9aceaca commit a7a2b51

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.support.annotation.NonNull;
1111
import android.support.v4.app.Fragment;
1212
import android.support.v4.app.FragmentTransaction;
13+
import android.support.v4.widget.SwipeRefreshLayout;
1314
import android.support.v7.app.AlertDialog;
1415
import android.view.Menu;
1516
import android.view.MenuInflater;
@@ -60,7 +61,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
6061
private NearbyActivityMode viewMode;
6162
private Disposable placesDisposable;
6263
private boolean lockNearbyView; //Determines if the nearby places needs to be refreshed
63-
64+
@BindView(R.id.swipe_container) SwipeRefreshLayout swipeLayout;
6465
@Override
6566
protected void onCreate(Bundle savedInstanceState) {
6667
super.onCreate(savedInstanceState);
@@ -70,6 +71,13 @@ protected void onCreate(Bundle savedInstanceState) {
7071
bundle = new Bundle();
7172
initDrawer();
7273
initViewState();
74+
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
75+
@Override
76+
public void onRefresh() {
77+
lockNearbyView(false);
78+
refreshView(true);
79+
}
80+
});
7381
}
7482

7583
private void initViewState() {
@@ -309,7 +317,7 @@ private void populatePlaces(List<Place> placeList) {
309317
} else {
310318
setListFragment();
311319
}
312-
320+
swipeLayout.setRefreshing(false);
313321
hideProgressBar();
314322
}
315323

app/src/main/res/layout/activity_nearby.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,19 @@
2121
android:orientation="horizontal"
2222
android:gravity="center_vertical"
2323
android:layout_below="@id/toolbar">
24-
2524
<ProgressBar
2625
android:id="@+id/progressBar"
2726
android:layout_width="match_parent"
2827
android:layout_height="wrap_content" />
29-
28+
<android.support.v4.widget.SwipeRefreshLayout
29+
android:id="@+id/swipe_container"
30+
android:layout_width="match_parent"
31+
android:layout_height="match_parent">
3032
<FrameLayout
3133
android:id="@+id/container"
3234
android:layout_width="match_parent"
3335
android:layout_height="match_parent" />
34-
36+
</android.support.v4.widget.SwipeRefreshLayout>
3537
</LinearLayout>
3638
</RelativeLayout>
3739

0 commit comments

Comments
 (0)