Commit 96935707 authored by Sajal Narang's avatar Sajal Narang

Implement SwipeRefreshLayout

parent 94ac3f9c
......@@ -5,6 +5,7 @@ import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
......@@ -33,7 +34,8 @@ import retrofit2.Response;
*/
public class FeedFragment extends Fragment {
RecyclerView feedRecyclerView;
private RecyclerView feedRecyclerView;
private SwipeRefreshLayout feedSwipeRefreshLayout;
public FeedFragment() {
// Required empty public constructor
......@@ -51,9 +53,21 @@ public class FeedFragment extends Fragment {
public void onStart() {
super.onStart();
updateFeed();
feedSwipeRefreshLayout = (SwipeRefreshLayout) getActivity().findViewById(R.id.feed_swipe_refresh_layout);
feedSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
updateFeed();
}
});
}
private void updateFeed() {
NewsFeedRequest newsFeedRequest = new NewsFeedRequest(NewsFeedRequest.FOLLOWED, 0, 20);
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.getNewsFeed(newsFeedRequest).enqueue(new Callback<NewsFeedResponse>() {
retrofitInterface.getNewsFeed().enqueue(new Callback<NewsFeedResponse>() {
@Override
public void onResponse(Call<NewsFeedResponse> call, Response<NewsFeedResponse> response) {
if (response.isSuccessful()) {
......@@ -79,11 +93,13 @@ public class FeedFragment extends Fragment {
feedRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
}
//Server Error
feedSwipeRefreshLayout.setRefreshing(false);
}
@Override
public void onFailure(Call<NewsFeedResponse> call, Throwable t) {
//Network Error
feedSwipeRefreshLayout.setRefreshing(false);
}
});
}
......
......@@ -39,7 +39,6 @@ public class MapFragment extends Fragment implements OnMapReadyCallback {
googleMap.getUiSettings().setMyLocationButtonEnabled(false);
googleMap.getUiSettings().setZoomGesturesEnabled(true);
LatLngBounds iitbBounds = new LatLngBounds(new LatLng(19.1249000, 72.9046000), new LatLng(19.143522, 72.920000));
googleMap.setLatLngBoundsForCameraTarget(iitbBounds);
googleMap.setMaxZoomPreference(30);
......
......@@ -6,9 +6,10 @@
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.EventFragment">
<ImageView
android:scaleType="centerCrop"
android:id="@+id/event_picture_2"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="360dp" />
<TextView
android:id="@+id/event_title_2"
......@@ -21,24 +22,28 @@
android:layout_height="wrap_content" />
<LinearLayout
android:background="@color/colorPrimary"
style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:text="Going"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:text="Interested"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:text="Not Going"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
......
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/feed_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.FeedFragment">
......@@ -9,4 +10,4 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
</android.support.v4.widget.SwipeRefreshLayout>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment