Addition: Pull down to refresh in nearby activity (#1164)

* added pull down to refresh in nearby activity

* Requested changes made
This commit is contained in:
Balakrishnan S 2018-02-24 01:30:13 +05:30 committed by Vivek Maskara
parent 9aceaca95d
commit a7a2b51ceb
2 changed files with 15 additions and 5 deletions

View file

@ -10,6 +10,7 @@ import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AlertDialog;
import android.view.Menu;
import android.view.MenuInflater;
@ -60,7 +61,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
private NearbyActivityMode viewMode;
private Disposable placesDisposable;
private boolean lockNearbyView; //Determines if the nearby places needs to be refreshed
@BindView(R.id.swipe_container) SwipeRefreshLayout swipeLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -70,6 +71,13 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
bundle = new Bundle();
initDrawer();
initViewState();
swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
lockNearbyView(false);
refreshView(true);
}
});
}
private void initViewState() {
@ -309,7 +317,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
} else {
setListFragment();
}
swipeLayout.setRefreshing(false);
hideProgressBar();
}

View file

@ -21,17 +21,19 @@
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_below="@id/toolbar">
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
</RelativeLayout>