Added boolean to handle feed groups. May need a better solution for this
This commit is contained in:
parent
1aa1a0287e
commit
6eddaa0d38
1 changed files with 22 additions and 14 deletions
|
@ -80,6 +80,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||||
private var feedGroupsCarousel: FeedGroupCarouselItem? = null
|
private var feedGroupsCarousel: FeedGroupCarouselItem? = null
|
||||||
private lateinit var feedGroupsSortMenuItem: HeaderWithMenuItem
|
private lateinit var feedGroupsSortMenuItem: HeaderWithMenuItem
|
||||||
private val subscriptionsSection = Section()
|
private val subscriptionsSection = Section()
|
||||||
|
private var listView: Boolean = false
|
||||||
|
|
||||||
private val requestExportLauncher =
|
private val requestExportLauncher =
|
||||||
registerForActivityResult(StartActivityForResult(), this::requestExportResult)
|
registerForActivityResult(StartActivityForResult(), this::requestExportResult)
|
||||||
|
@ -124,6 +125,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
itemsListState = binding.itemsList.layoutManager?.onSaveInstanceState()
|
itemsListState = binding.itemsList.layoutManager?.onSaveInstanceState()
|
||||||
feedGroupsListState = feedGroupsCarousel?.onSaveInstanceState()
|
feedGroupsListState = feedGroupsCarousel?.onSaveInstanceState()
|
||||||
|
feedGroupsListVerticalState = feedGroupsCarousel?.onSaveInstanceState()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
@ -252,6 +254,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||||
// ////////////////////////////////////////////////////////////////////////
|
// ////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private fun setupInitialLayout() {
|
private fun setupInitialLayout() {
|
||||||
|
listView = false
|
||||||
Section().apply {
|
Section().apply {
|
||||||
val carouselAdapter = GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>()
|
val carouselAdapter = GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>()
|
||||||
|
|
||||||
|
@ -301,6 +304,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun changeLayout() {
|
private fun changeLayout() {
|
||||||
|
listView = true
|
||||||
Section().apply {
|
Section().apply {
|
||||||
val carouselAdapter2 = GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>()
|
val carouselAdapter2 = GroupAdapter<GroupieViewHolder<FeedItemCarouselBinding>>()
|
||||||
|
|
||||||
|
@ -476,6 +480,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleFeedGroups(groups: List<Group>) {
|
private fun handleFeedGroups(groups: List<Group>) {
|
||||||
|
if (!listView) {
|
||||||
feedGroupsSection.update(groups)
|
feedGroupsSection.update(groups)
|
||||||
|
|
||||||
if (feedGroupsListState != null) {
|
if (feedGroupsListState != null) {
|
||||||
|
@ -486,18 +491,21 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
|
||||||
feedGroupsSortMenuItem.showMenuItem = groups.size > 1
|
feedGroupsSortMenuItem.showMenuItem = groups.size > 1
|
||||||
binding.itemsList.post { feedGroupsSortMenuItem.notifyChanged(PAYLOAD_UPDATE_VISIBILITY_MENU_ITEM) }
|
binding.itemsList.post { feedGroupsSortMenuItem.notifyChanged(PAYLOAD_UPDATE_VISIBILITY_MENU_ITEM) }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun handleFeedGroupsVertical(groups: List<Group>) {
|
private fun handleFeedGroupsVertical(groups: List<Group>) {
|
||||||
|
if (listView) {
|
||||||
feedGroupsSection.update(groups)
|
feedGroupsSection.update(groups)
|
||||||
|
|
||||||
if (feedGroupsListState != null) {
|
if (feedGroupsListVerticalState != null) {
|
||||||
feedGroupsCarousel?.onRestoreInstanceState(feedGroupsListState)
|
feedGroupsCarousel?.onRestoreInstanceState(feedGroupsListVerticalState)
|
||||||
feedGroupsListVerticalState = null
|
feedGroupsListVerticalState = null
|
||||||
}
|
}
|
||||||
|
|
||||||
feedGroupsSortMenuItem.showMenuItem = groups.size > 1
|
feedGroupsSortMenuItem.showMenuItem = groups.size > 1
|
||||||
binding.itemsList.post { feedGroupsSortMenuItem.notifyChanged(PAYLOAD_UPDATE_VISIBILITY_MENU_ITEM) }
|
binding.itemsList.post { feedGroupsSortMenuItem.notifyChanged(PAYLOAD_UPDATE_VISIBILITY_MENU_ITEM) }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// /////////////////////////////////////////////////////////////////////////
|
// /////////////////////////////////////////////////////////////////////////
|
||||||
// Contract
|
// Contract
|
||||||
|
|
Loading…
Reference in a new issue