From 4e001d881ccf21cee2c88d01cdf3c5dda4b2c70f Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 22 Jun 2023 15:53:55 +0200 Subject: [PATCH] Show nothing here indicator if home tab is empty --- .../libretube/ui/fragments/HomeFragment.kt | 15 +++++++++--- app/src/main/res/layout/fragment_home.xml | 23 +++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt index 9983c2262..95f6f621c 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/HomeFragment.kt @@ -4,6 +4,8 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.core.view.isGone +import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.lifecycle.Lifecycle @@ -91,6 +93,13 @@ class HomeFragment : Fragment() { async { if (visibleItems.contains(FEATURED)) loadFeed() }, async { if (visibleItems.contains(PLAYLISTS)) loadPlaylists() }, ) + + val binding = _binding ?: return@repeatOnLifecycle + // No category is shown because they are either empty or disabled + if (binding.progress.isVisible) { + binding.progress.isGone = true + binding.nothingHere.isVisible = true + } } } } @@ -190,11 +199,11 @@ class HomeFragment : Fragment() { private fun makeVisible(vararg views: View) { views.forEach { - it.visibility = View.VISIBLE + it.isVisible = true } val binding = _binding ?: return - binding.progress.visibility = View.GONE - binding.scroll.visibility = View.VISIBLE + binding.progress.isGone = true + binding.scroll.isVisible = true binding.refresh.isRefreshing = false } diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index ad60d6cc0..67105a1b5 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -89,4 +89,27 @@ + + + + + + + \ No newline at end of file