From aee04782355cea4e71fe824d6afbc05e1347e77f Mon Sep 17 00:00:00 2001 From: Stypox Date: Fri, 15 Jan 2021 22:29:18 +0100 Subject: [PATCH] FeedFragment: fix view binding and show loading indicator correctly --- .../schabi/newpipe/local/feed/FeedFragment.kt | 18 +++++++++++------- app/src/main/res/layout/fragment_feed.xml | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt index adbff1e54..33bed7d7e 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt @@ -42,6 +42,7 @@ import org.schabi.newpipe.error.ErrorInfo import org.schabi.newpipe.error.UserAction import org.schabi.newpipe.fragments.list.BaseListFragment import org.schabi.newpipe.ktx.animate +import org.schabi.newpipe.ktx.animateHideRecyclerViewAllowingScrolling import org.schabi.newpipe.local.feed.service.FeedLoadService import org.schabi.newpipe.util.Localization import java.util.Calendar @@ -106,7 +107,7 @@ class FeedFragment : BaseListFragment() { override fun initListeners() { super.initListeners() feedBinding.refreshRootView.setOnClickListener { reloadContent() } - feedBinding.swiperefresh.setOnRefreshListener { reloadContent() } + feedBinding.swipeRefreshLayout.setOnRefreshListener { reloadContent() } } // ///////////////////////////////////////////////////////////////////////// @@ -172,23 +173,25 @@ class FeedFragment : BaseListFragment() { override fun showLoading() { super.showLoading() + feedBinding.itemsList.animateHideRecyclerViewAllowingScrolling() feedBinding.refreshRootView.animate(false, 0) - feedBinding.itemsList.animate(false, 0) feedBinding.loadingProgressText.animate(true, 200) + feedBinding.swipeRefreshLayout.isRefreshing = true } override fun hideLoading() { super.hideLoading() feedBinding.refreshRootView.animate(true, 200) feedBinding.loadingProgressText.animate(false, 0) - feedBinding.swiperefresh.isRefreshing = false + feedBinding.swipeRefreshLayout.isRefreshing = false } override fun showEmptyState() { super.showEmptyState() + feedBinding.itemsList.animateHideRecyclerViewAllowingScrolling() feedBinding.refreshRootView.animate(true, 200) - feedBinding.itemsList.animate(false, 0) feedBinding.loadingProgressText.animate(false, 0) + feedBinding.swipeRefreshLayout.isRefreshing = false } override fun handleResult(result: FeedState) { @@ -204,9 +207,10 @@ class FeedFragment : BaseListFragment() { override fun handleError() { super.handleError() infoListAdapter.clearStreamItemList() - feedBinding.refreshRootView.animate(false, 200) - feedBinding.itemsList.animate(false, 200) - feedBinding.loadingProgressText.animate(false, 200) + feedBinding.itemsList.animateHideRecyclerViewAllowingScrolling() + feedBinding.refreshRootView.animate(false, 0) + feedBinding.loadingProgressText.animate(false, 0) + feedBinding.swipeRefreshLayout.isRefreshing = false } private fun handleProgressState(progressState: FeedState.ProgressState) { diff --git a/app/src/main/res/layout/fragment_feed.xml b/app/src/main/res/layout/fragment_feed.xml index 0e2759895..b68c29bc6 100644 --- a/app/src/main/res/layout/fragment_feed.xml +++ b/app/src/main/res/layout/fragment_feed.xml @@ -71,7 +71,7 @@