From e95a5be21df6520ee2b5ae873a39b6671222a03d Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 25 Jul 2020 17:14:34 -0400 Subject: [PATCH] Show message when searching with no pinned sources --- .../source/globalsearch/GlobalSearchController.kt | 11 +++++++++++ app/src/main/res/layout/global_search_controller.xml | 7 +++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 19 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt index 021427ea14..04ba78da04 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchController.kt @@ -11,6 +11,7 @@ import androidx.appcompat.widget.SearchView import androidx.recyclerview.widget.LinearLayoutManager import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga +import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.databinding.GlobalSearchControllerBinding import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.ui.base.controller.NucleusController @@ -22,6 +23,8 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import reactivecircus.flowbinding.appcompat.QueryTextEvent import reactivecircus.flowbinding.appcompat.queryTextEvents +import uy.kohesive.injekt.api.get +import uy.kohesive.injekt.injectLazy /** * This controller shows and manages the different search result in global search. @@ -35,6 +38,8 @@ open class GlobalSearchController( GlobalSearchCardAdapter.OnMangaClickListener, GlobalSearchAdapter.OnTitleClickListener { + private val preferences: PreferencesHelper by injectLazy() + /** * Adapter containing search results grouped by lang. */ @@ -180,6 +185,12 @@ open class GlobalSearchController( * @param searchResult result of search. */ fun setItems(searchResult: List) { + if (searchResult.isEmpty() && preferences.searchPinnedSourcesOnly()) { + binding.emptyView.show(R.string.no_pinned_sources) + } else { + binding.emptyView.hide() + } + adapter?.updateDataSet(searchResult) } diff --git a/app/src/main/res/layout/global_search_controller.xml b/app/src/main/res/layout/global_search_controller.xml index ae380eb4b0..7a648e0935 100644 --- a/app/src/main/res/layout/global_search_controller.xml +++ b/app/src/main/res/layout/global_search_controller.xml @@ -33,4 +33,11 @@ + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cca960ba6f..14db14d9a2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -454,6 +454,7 @@ Latest Browse Local source guide + You have no pinned sources This manga has been removed from the database.