From 38bc8ec6b4c6f40dd98355e2fbe2021a16885e60 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 22 Nov 2020 16:53:59 -0500 Subject: [PATCH] Add global search progress bar (closes #3727) --- .../source/globalsearch/GlobalSearchController.kt | 9 +++++++++ app/src/main/res/layout/global_search_controller.xml | 10 ++++++++++ 2 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 64bbb04c8a..08494dcfd3 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 @@ -8,6 +8,7 @@ import android.view.MenuItem import android.view.View import android.view.ViewGroup import androidx.appcompat.widget.SearchView +import androidx.core.view.isVisible import androidx.recyclerview.widget.LinearLayoutManager import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga @@ -194,6 +195,14 @@ open class GlobalSearchController( } adapter?.updateDataSet(searchResult) + + val progress = searchResult.mapNotNull { it.results }.count().toDouble() / searchResult.size + if (progress < 1) { + binding.progressBar.isVisible = true + binding.progressBar.progress = (progress * 100).toInt() + } else { + binding.progressBar.isVisible = false + } } /** diff --git a/app/src/main/res/layout/global_search_controller.xml b/app/src/main/res/layout/global_search_controller.xml index 85770ed92b..a69cc17725 100644 --- a/app/src/main/res/layout/global_search_controller.xml +++ b/app/src/main/res/layout/global_search_controller.xml @@ -13,6 +13,16 @@ android:paddingBottom="4dp" tools:listitem="@layout/global_search_controller_card" /> + +