From 0aca996bc0e618e43739371950979caf70afe391 Mon Sep 17 00:00:00 2001 From: Blatzar <46196380+Blatzar@users.noreply.github.com> Date: Thu, 26 Jan 2023 18:09:22 +0100 Subject: [PATCH] Better notice when not logged in in library --- .../cloudstream3/ui/library/LibraryFragment.kt | 18 +++++++++++++++++- app/src/main/res/layout/fragment_library.xml | 1 - app/src/main/res/values/strings.xml | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/library/LibraryFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/library/LibraryFragment.kt index baf8f71e..42f0928d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/library/LibraryFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/library/LibraryFragment.kt @@ -253,6 +253,12 @@ class LibraryFragment : Fragment() { activity?.loadSearchResult( searchClickCallback.card ) + } else { + // Search when no provider can open + QuickSearchFragment.pushSearch( + activity, + searchClickCallback.card.name + ) } } LibraryOpenerType.None -> {} @@ -283,7 +289,16 @@ class LibraryFragment : Fragment() { when (resource) { is Resource.Success -> { val pages = resource.value - empty_list_textview?.isVisible = pages.all { it.items.isEmpty() } + val showNotice = pages.all { it.items.isEmpty() } + empty_list_textview?.isVisible = showNotice + if (showNotice) { + if (libraryViewModel.availableApiNames.size > 1) { + empty_list_textview?.setText(R.string.empty_library_logged_in_message) + } else { + empty_list_textview?.setText(R.string.empty_library_no_accounts_message) + } + } + (viewpager.adapter as? ViewpagerAdapter)?.pages = pages // Using notifyItemRangeChanged keeps the animations when sorting viewpager.adapter?.notifyItemRangeChanged(0, viewpager.adapter?.itemCount ?: 0) @@ -303,6 +318,7 @@ class LibraryFragment : Fragment() { } is Resource.Loading -> { loading_indicator?.show() + empty_list_textview?.isVisible = false } is Resource.Failure -> { // No user indication it failed :( diff --git a/app/src/main/res/layout/fragment_library.xml b/app/src/main/res/layout/fragment_library.xml index c86e5d93..116a4e03 100644 --- a/app/src/main/res/layout/fragment_library.xml +++ b/app/src/main/res/layout/fragment_library.xml @@ -14,7 +14,6 @@ android:layout_gravity="center" android:layout_margin="30dp" android:gravity="center" - android:text="@string/empty_library_message" android:visibility="gone" tools:visibility="visible" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c935809b..acfc5932 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -627,5 +627,6 @@ Alphabetical (Z to A) Select Library Open with - Looks like your library is empty :(\nLogin to a library account or add shows to your local library + Looks like your library is empty :(\nLogin to a library account or add shows to your local library + Looks like this list is empty, try switching to another one