mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-24 00:50:32 +00:00
Fix crash when refreshing feed
This commit is contained in:
parent
cb1a138140
commit
2e053ea25a
@ -97,6 +97,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
|
|||||||
|
|
||||||
private var onSettingsChangeListener: SharedPreferences.OnSharedPreferenceChangeListener? = null
|
private var onSettingsChangeListener: SharedPreferences.OnSharedPreferenceChangeListener? = null
|
||||||
private var updateListViewModeOnResume = false
|
private var updateListViewModeOnResume = false
|
||||||
|
private var isRefreshing = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
@ -268,6 +269,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
|
|||||||
feedBinding.refreshRootView.animate(false, 0)
|
feedBinding.refreshRootView.animate(false, 0)
|
||||||
feedBinding.loadingProgressText.animate(true, 200)
|
feedBinding.loadingProgressText.animate(true, 200)
|
||||||
feedBinding.swipeRefreshLayout.isRefreshing = true
|
feedBinding.swipeRefreshLayout.isRefreshing = true
|
||||||
|
isRefreshing = true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hideLoading() {
|
override fun hideLoading() {
|
||||||
@ -276,6 +278,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
|
|||||||
feedBinding.refreshRootView.animate(true, 200)
|
feedBinding.refreshRootView.animate(true, 200)
|
||||||
feedBinding.loadingProgressText.animate(false, 0)
|
feedBinding.loadingProgressText.animate(false, 0)
|
||||||
feedBinding.swipeRefreshLayout.isRefreshing = false
|
feedBinding.swipeRefreshLayout.isRefreshing = false
|
||||||
|
isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showEmptyState() {
|
override fun showEmptyState() {
|
||||||
@ -302,6 +305,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
|
|||||||
feedBinding.refreshRootView.animate(false, 0)
|
feedBinding.refreshRootView.animate(false, 0)
|
||||||
feedBinding.loadingProgressText.animate(false, 0)
|
feedBinding.loadingProgressText.animate(false, 0)
|
||||||
feedBinding.swipeRefreshLayout.isRefreshing = false
|
feedBinding.swipeRefreshLayout.isRefreshing = false
|
||||||
|
isRefreshing = false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleProgressState(progressState: FeedState.ProgressState) {
|
private fun handleProgressState(progressState: FeedState.ProgressState) {
|
||||||
@ -363,7 +367,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
|
|||||||
|
|
||||||
private val listenerStreamItem = object : OnItemClickListener, OnItemLongClickListener {
|
private val listenerStreamItem = object : OnItemClickListener, OnItemLongClickListener {
|
||||||
override fun onItemClick(item: Item<*>, view: View) {
|
override fun onItemClick(item: Item<*>, view: View) {
|
||||||
if (item is StreamItem && !feedBinding.swipeRefreshLayout.isRefreshing) {
|
if (item is StreamItem && !isRefreshing) {
|
||||||
val stream = item.streamWithState.stream
|
val stream = item.streamWithState.stream
|
||||||
NavigationHelper.openVideoDetailFragment(
|
NavigationHelper.openVideoDetailFragment(
|
||||||
requireContext(), fm,
|
requireContext(), fm,
|
||||||
@ -373,7 +377,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemLongClick(item: Item<*>, view: View): Boolean {
|
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())
|
showStreamDialog(item.streamWithState.stream.toStreamInfoItem())
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user