mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-31 07:13:00 +00:00 
			
		
		
		
	FeedFragment: fix view binding and show loading indicator correctly
This commit is contained in:
		| @@ -42,6 +42,7 @@ import org.schabi.newpipe.error.ErrorInfo | |||||||
| import org.schabi.newpipe.error.UserAction | import org.schabi.newpipe.error.UserAction | ||||||
| import org.schabi.newpipe.fragments.list.BaseListFragment | import org.schabi.newpipe.fragments.list.BaseListFragment | ||||||
| import org.schabi.newpipe.ktx.animate | import org.schabi.newpipe.ktx.animate | ||||||
|  | import org.schabi.newpipe.ktx.animateHideRecyclerViewAllowingScrolling | ||||||
| import org.schabi.newpipe.local.feed.service.FeedLoadService | import org.schabi.newpipe.local.feed.service.FeedLoadService | ||||||
| import org.schabi.newpipe.util.Localization | import org.schabi.newpipe.util.Localization | ||||||
| import java.util.Calendar | import java.util.Calendar | ||||||
| @@ -106,7 +107,7 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() { | |||||||
|     override fun initListeners() { |     override fun initListeners() { | ||||||
|         super.initListeners() |         super.initListeners() | ||||||
|         feedBinding.refreshRootView.setOnClickListener { reloadContent() } |         feedBinding.refreshRootView.setOnClickListener { reloadContent() } | ||||||
|         feedBinding.swiperefresh.setOnRefreshListener { reloadContent() } |         feedBinding.swipeRefreshLayout.setOnRefreshListener { reloadContent() } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // ///////////////////////////////////////////////////////////////////////// |     // ///////////////////////////////////////////////////////////////////////// | ||||||
| @@ -172,23 +173,25 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() { | |||||||
|  |  | ||||||
|     override fun showLoading() { |     override fun showLoading() { | ||||||
|         super.showLoading() |         super.showLoading() | ||||||
|  |         feedBinding.itemsList.animateHideRecyclerViewAllowingScrolling() | ||||||
|         feedBinding.refreshRootView.animate(false, 0) |         feedBinding.refreshRootView.animate(false, 0) | ||||||
|         feedBinding.itemsList.animate(false, 0) |  | ||||||
|         feedBinding.loadingProgressText.animate(true, 200) |         feedBinding.loadingProgressText.animate(true, 200) | ||||||
|  |         feedBinding.swipeRefreshLayout.isRefreshing = true | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun hideLoading() { |     override fun hideLoading() { | ||||||
|         super.hideLoading() |         super.hideLoading() | ||||||
|         feedBinding.refreshRootView.animate(true, 200) |         feedBinding.refreshRootView.animate(true, 200) | ||||||
|         feedBinding.loadingProgressText.animate(false, 0) |         feedBinding.loadingProgressText.animate(false, 0) | ||||||
|         feedBinding.swiperefresh.isRefreshing = false |         feedBinding.swipeRefreshLayout.isRefreshing = false | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun showEmptyState() { |     override fun showEmptyState() { | ||||||
|         super.showEmptyState() |         super.showEmptyState() | ||||||
|  |         feedBinding.itemsList.animateHideRecyclerViewAllowingScrolling() | ||||||
|         feedBinding.refreshRootView.animate(true, 200) |         feedBinding.refreshRootView.animate(true, 200) | ||||||
|         feedBinding.itemsList.animate(false, 0) |  | ||||||
|         feedBinding.loadingProgressText.animate(false, 0) |         feedBinding.loadingProgressText.animate(false, 0) | ||||||
|  |         feedBinding.swipeRefreshLayout.isRefreshing = false | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     override fun handleResult(result: FeedState) { |     override fun handleResult(result: FeedState) { | ||||||
| @@ -204,9 +207,10 @@ class FeedFragment : BaseListFragment<FeedState, Unit>() { | |||||||
|     override fun handleError() { |     override fun handleError() { | ||||||
|         super.handleError() |         super.handleError() | ||||||
|         infoListAdapter.clearStreamItemList() |         infoListAdapter.clearStreamItemList() | ||||||
|         feedBinding.refreshRootView.animate(false, 200) |         feedBinding.itemsList.animateHideRecyclerViewAllowingScrolling() | ||||||
|         feedBinding.itemsList.animate(false, 200) |         feedBinding.refreshRootView.animate(false, 0) | ||||||
|         feedBinding.loadingProgressText.animate(false, 200) |         feedBinding.loadingProgressText.animate(false, 0) | ||||||
|  |         feedBinding.swipeRefreshLayout.isRefreshing = false | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private fun handleProgressState(progressState: FeedState.ProgressState) { |     private fun handleProgressState(progressState: FeedState.ProgressState) { | ||||||
|   | |||||||
| @@ -71,7 +71,7 @@ | |||||||
|     </RelativeLayout> |     </RelativeLayout> | ||||||
|  |  | ||||||
|     <androidx.swiperefreshlayout.widget.SwipeRefreshLayout |     <androidx.swiperefreshlayout.widget.SwipeRefreshLayout | ||||||
|         android:id="@+id/swiperefresh" |         android:id="@+id/swipeRefreshLayout" | ||||||
|         android:layout_width="match_parent" |         android:layout_width="match_parent" | ||||||
|         android:layout_height="match_parent" |         android:layout_height="match_parent" | ||||||
|         android:layout_below="@+id/refresh_root_view"> |         android:layout_below="@+id/refresh_root_view"> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Stypox
					Stypox