From 6a619ef878696d7d4e5b9b3fb287b2774d8ae7b3 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Mon, 10 Sep 2018 22:28:59 +0300 Subject: [PATCH] Unread bug fix --- .../main/unread/UnreadFragment.java | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java index 1709db82..b18874d5 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java @@ -102,15 +102,12 @@ public class UnreadFragment extends BaseFragment { if (rootView instanceof RelativeLayout) { progressBar = rootView.findViewById(R.id.progressBar); unreadAdapter = new UnreadAdapter(topicSummaries, - fragmentInteractionListener, new UnreadAdapter.MarkReadInteractionListener() { - @Override - public void onMarkReadInteraction(String markReadLinkUrl) { - if (markReadTask != null && markReadTask.getStatus() != AsyncTask.Status.RUNNING) { - markReadTask = new MarkReadTask(); - markReadTask.execute(markReadLinkUrl); - } - } - }); + fragmentInteractionListener, markReadLinkUrl -> { + if (markReadTask != null && markReadTask.getStatus() != AsyncTask.Status.RUNNING) { + markReadTask = new MarkReadTask(); + markReadTask.execute(markReadLinkUrl); + } + }); CustomRecyclerView recyclerView = rootView.findViewById(R.id.list); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(recyclerView.getContext()); @@ -124,19 +121,15 @@ public class UnreadFragment extends BaseFragment { swipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.primary); swipeRefreshLayout.setColorSchemeResources(R.color.accent); swipeRefreshLayout.setOnRefreshListener( - new SwipeRefreshLayout.OnRefreshListener() { - @Override - public void onRefresh() { - if (unreadTask != null && unreadTask.getStatus() != AsyncTask.Status.RUNNING) { - topicSummaries.clear(); - numberOfPages = 0; - loadedPages = 0; - unreadTask = new UnreadTask(); - assert SessionManager.unreadUrl != null; - unreadTask.execute(SessionManager.unreadUrl.toString()); - } + () -> { + if (unreadTask != null && unreadTask.getStatus() != AsyncTask.Status.RUNNING) { + topicSummaries.clear(); + numberOfPages = 0; + loadedPages = 0; + unreadTask = new UnreadTask(); + assert SessionManager.unreadUrl != null; + unreadTask.execute(SessionManager.unreadUrl.toString()); } - } ); } @@ -237,7 +230,12 @@ public class UnreadFragment extends BaseFragment { assert SessionManager.unreadUrl != null; unreadTask.execute(SessionManager.unreadUrl.toString() + ";start=" + loadedPages * 20); } - + else { + progressBar.setVisibility(ProgressBar.INVISIBLE); + swipeRefreshLayout.setRefreshing(false); + } + } + else{ progressBar.setVisibility(ProgressBar.INVISIBLE); swipeRefreshLayout.setRefreshing(false); }