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