From cb1a138140d72833411132ecf9eb0e4d1b2b0297 Mon Sep 17 00:00:00 2001 From: Douile <25043847+Douile@users.noreply.github.com> Date: Tue, 22 Jun 2021 19:42:20 +0100 Subject: [PATCH 1/2] #6081: Disable feed click handlers during refresh This patch changes click handlers for feed (Whats new) so that they do nothing while the feed is refreshing and the items being clicked are not visible. --- .../main/java/org/schabi/newpipe/local/feed/FeedFragment.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 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 4c1bb0732..f401ea924 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 @@ -363,7 +363,7 @@ class FeedFragment : BaseStateFragment() { private val listenerStreamItem = object : OnItemClickListener, OnItemLongClickListener { override fun onItemClick(item: Item<*>, view: View) { - if (item is StreamItem) { + if (item is StreamItem && !feedBinding.swipeRefreshLayout.isRefreshing) { val stream = item.streamWithState.stream NavigationHelper.openVideoDetailFragment( requireContext(), fm, @@ -373,7 +373,7 @@ class FeedFragment : BaseStateFragment() { } override fun onItemLongClick(item: Item<*>, view: View): Boolean { - if (item is StreamItem) { + if (item is StreamItem && !feedBinding.swipeRefreshLayout.isRefreshing) { showStreamDialog(item.streamWithState.stream.toStreamInfoItem()) return true } From 2e053ea25a9909ca45082a3c31fadce0aa0c8892 Mon Sep 17 00:00:00 2001 From: Douile <25043847+Douile@users.noreply.github.com> Date: Sun, 11 Jul 2021 03:00:32 +0100 Subject: [PATCH 2/2] Fix crash when refreshing feed --- .../java/org/schabi/newpipe/local/feed/FeedFragment.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 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 f401ea924..ec24afa99 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 @@ -97,6 +97,7 @@ class FeedFragment : BaseStateFragment() { private var onSettingsChangeListener: SharedPreferences.OnSharedPreferenceChangeListener? = null private var updateListViewModeOnResume = false + private var isRefreshing = false init { setHasOptionsMenu(true) @@ -268,6 +269,7 @@ class FeedFragment : BaseStateFragment() { feedBinding.refreshRootView.animate(false, 0) feedBinding.loadingProgressText.animate(true, 200) feedBinding.swipeRefreshLayout.isRefreshing = true + isRefreshing = true } override fun hideLoading() { @@ -276,6 +278,7 @@ class FeedFragment : BaseStateFragment() { feedBinding.refreshRootView.animate(true, 200) feedBinding.loadingProgressText.animate(false, 0) feedBinding.swipeRefreshLayout.isRefreshing = false + isRefreshing = false } override fun showEmptyState() { @@ -302,6 +305,7 @@ class FeedFragment : BaseStateFragment() { feedBinding.refreshRootView.animate(false, 0) feedBinding.loadingProgressText.animate(false, 0) feedBinding.swipeRefreshLayout.isRefreshing = false + isRefreshing = false } private fun handleProgressState(progressState: FeedState.ProgressState) { @@ -363,7 +367,7 @@ class FeedFragment : BaseStateFragment() { private val listenerStreamItem = object : OnItemClickListener, OnItemLongClickListener { override fun onItemClick(item: Item<*>, view: View) { - if (item is StreamItem && !feedBinding.swipeRefreshLayout.isRefreshing) { + if (item is StreamItem && !isRefreshing) { val stream = item.streamWithState.stream NavigationHelper.openVideoDetailFragment( requireContext(), fm, @@ -373,7 +377,7 @@ class FeedFragment : BaseStateFragment() { } override fun onItemLongClick(item: Item<*>, view: View): Boolean { - if (item is StreamItem && !feedBinding.swipeRefreshLayout.isRefreshing) { + if (item is StreamItem && !isRefreshing) { showStreamDialog(item.streamWithState.stream.toStreamInfoItem()) return true }