Commit d689c37b authored by Varun Patil's avatar Varun Patil

Prevent stale events from showing over fresh ones in Feed

parent e64280ee
......@@ -42,6 +42,7 @@ public class FeedFragment extends BaseFragment {
private SwipeRefreshLayout feedSwipeRefreshLayout;
private AppDatabase appDatabase;
private FloatingActionButton fab;
private boolean freshEventsDisplayed = false;
public FeedFragment() {
// Required empty public constructor
......@@ -98,6 +99,7 @@ public class FeedFragment extends BaseFragment {
if (response.isSuccessful()) {
NewsFeedResponse newsFeedResponse = response.body();
List<Event> events = newsFeedResponse.getEvents();
freshEventsDisplayed = true;
displayEvents(events);
new updateDatabase().execute(events);
......@@ -163,7 +165,9 @@ public class FeedFragment extends BaseFragment {
}
protected void onPostExecute(List<Event> result) {
displayEvents(result);
if (!freshEventsDisplayed) {
displayEvents(result);
}
}
}
}
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