From f05b8c9542d6cdfb64ccba4a53dfd5ce2df52457 Mon Sep 17 00:00:00 2001 From: Mauricio Colli Date: Thu, 10 Oct 2019 10:31:43 -0300 Subject: [PATCH] Expand import/export options by default when subscriptions list is empty --- .../local/subscription/SubscriptionFragment.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt index e7d675964..4b0c5bf82 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt @@ -57,7 +57,7 @@ class SubscriptionFragment : BaseStateFragment() { @State @JvmField var itemsListState: Parcelable? = null @State @JvmField var feedGroupsListState: Parcelable? = null - @State @JvmField var importExportItemExpandedState: Boolean = false + @State @JvmField var importExportItemExpandedState: Boolean? = null init { setHasOptionsMenu(true) @@ -221,7 +221,7 @@ class SubscriptionFragment : BaseStateFragment() { { onImportPreviousSelected() }, { onImportFromServiceSelected(it) }, { onExportSelected() }, - importExportItemExpandedState) + importExportItemExpandedState ?: false) groupAdapter.add(Section(importExportItem, listOf(subscriptionsSection))) } @@ -307,6 +307,13 @@ class SubscriptionFragment : BaseStateFragment() { subscriptionsSection.update(result.subscriptions) subscriptionsSection.setHideWhenEmpty(false) + if (result.subscriptions.isEmpty() && importExportItemExpandedState == null) { + items_list.post { + importExportItem.isExpanded = true + importExportItem.notifyChanged(FeedImportExportItem.REFRESH_EXPANDED_STATUS) + } + } + if (itemsListState != null) { items_list.layoutManager?.onRestoreInstanceState(itemsListState) itemsListState = null