Expand import/export options by default when subscriptions list is empty

This commit is contained in:
Mauricio Colli 2019-10-10 10:31:43 -03:00
parent 8b87893248
commit f05b8c9542
No known key found for this signature in database
GPG key ID: F200BFD6F29DDD85

View file

@ -57,7 +57,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
@State @JvmField var itemsListState: Parcelable? = null @State @JvmField var itemsListState: Parcelable? = null
@State @JvmField var feedGroupsListState: Parcelable? = null @State @JvmField var feedGroupsListState: Parcelable? = null
@State @JvmField var importExportItemExpandedState: Boolean = false @State @JvmField var importExportItemExpandedState: Boolean? = null
init { init {
setHasOptionsMenu(true) setHasOptionsMenu(true)
@ -221,7 +221,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
{ onImportPreviousSelected() }, { onImportPreviousSelected() },
{ onImportFromServiceSelected(it) }, { onImportFromServiceSelected(it) },
{ onExportSelected() }, { onExportSelected() },
importExportItemExpandedState) importExportItemExpandedState ?: false)
groupAdapter.add(Section(importExportItem, listOf(subscriptionsSection))) groupAdapter.add(Section(importExportItem, listOf(subscriptionsSection)))
} }
@ -307,6 +307,13 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
subscriptionsSection.update(result.subscriptions) subscriptionsSection.update(result.subscriptions)
subscriptionsSection.setHideWhenEmpty(false) subscriptionsSection.setHideWhenEmpty(false)
if (result.subscriptions.isEmpty() && importExportItemExpandedState == null) {
items_list.post {
importExportItem.isExpanded = true
importExportItem.notifyChanged(FeedImportExportItem.REFRESH_EXPANDED_STATUS)
}
}
if (itemsListState != null) { if (itemsListState != null) {
items_list.layoutManager?.onRestoreInstanceState(itemsListState) items_list.layoutManager?.onRestoreInstanceState(itemsListState)
itemsListState = null itemsListState = null