1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-25 20:42:34 +01:00

Fix flickering in channel groups list

This commit is contained in:
Stypox 2022-10-27 14:01:04 +02:00
parent 8ceefee1e3
commit 83d16dc656
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23

View File

@ -413,16 +413,6 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
private fun handleFeedGroups(groups: List<Group>) { private fun handleFeedGroups(groups: List<Group>) {
val listViewMode = viewModel.getListViewMode() val listViewMode = viewModel.getListViewMode()
carouselAdapter.clear()
carouselAdapter.add(if (listViewMode) FeedGroupAddNewItem() else FeedGroupAddNewGridItem())
carouselAdapter.add(
if (listViewMode)
FeedGroupCardItem(-1, getString(R.string.all), FeedGroupIcon.RSS)
else
FeedGroupCardGridItem(-1, getString(R.string.all), FeedGroupIcon.RSS)
)
carouselAdapter.addAll(groups)
if (feedGroupsCarouselState != null) { if (feedGroupsCarouselState != null) {
feedGroupsCarousel.onRestoreInstanceState(feedGroupsCarouselState) feedGroupsCarousel.onRestoreInstanceState(feedGroupsCarouselState)
feedGroupsCarouselState = null feedGroupsCarouselState = null
@ -434,6 +424,19 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
binding.itemsList.post { binding.itemsList.post {
feedGroupsCarousel.notifyChanged(FeedGroupCarouselItem.PAYLOAD_UPDATE_LIST_VIEW_MODE) feedGroupsCarousel.notifyChanged(FeedGroupCarouselItem.PAYLOAD_UPDATE_LIST_VIEW_MODE)
feedGroupsSortMenuItem.notifyChanged(GroupsHeader.PAYLOAD_UPDATE_ICONS) feedGroupsSortMenuItem.notifyChanged(GroupsHeader.PAYLOAD_UPDATE_ICONS)
// update items here to prevent flickering
carouselAdapter.apply {
clear()
if (listViewMode) {
add(FeedGroupAddNewItem())
add(FeedGroupCardItem(-1, getString(R.string.all), FeedGroupIcon.RSS))
} else {
add(FeedGroupAddNewGridItem())
add(FeedGroupCardGridItem(-1, getString(R.string.all), FeedGroupIcon.RSS))
}
addAll(groups)
}
} }
} }