Skip to content

Commit

Permalink
Fix flickering in channel groups list
Browse files Browse the repository at this point in the history
  • Loading branch information
Stypox committed Oct 27, 2022
1 parent 8ceefee commit 83d16dc
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -413,16 +413,6 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
private fun handleFeedGroups(groups: List<Group>) {
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) {
feedGroupsCarousel.onRestoreInstanceState(feedGroupsCarouselState)
feedGroupsCarouselState = null
Expand All @@ -434,6 +424,19 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
binding.itemsList.post {
feedGroupsCarousel.notifyChanged(FeedGroupCarouselItem.PAYLOAD_UPDATE_LIST_VIEW_MODE)
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)
}
}
}

Expand Down

0 comments on commit 83d16dc

Please sign in to comment.