1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 08:30:44 +00:00

FeedFragment: fix view binding and show loading indicator correctly

This commit is contained in:
Stypox 2021-01-15 22:29:18 +01:00
parent c3cf1d81c2
commit aee0478235
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
2 changed files with 12 additions and 8 deletions

View File

@ -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<FeedState, Unit>() {
override fun initListeners() {
super.initListeners()
feedBinding.refreshRootView.setOnClickListener { reloadContent() }
feedBinding.swiperefresh.setOnRefreshListener { reloadContent() }
feedBinding.swipeRefreshLayout.setOnRefreshListener { reloadContent() }
}
// /////////////////////////////////////////////////////////////////////////
@ -172,23 +173,25 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() {
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<FeedState, Unit>() {
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) {

View File

@ -71,7 +71,7 @@
</RelativeLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swiperefresh"
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/refresh_root_view">