소스 검색

Explicitly show "No results found" in global search instead of hiding row

arkon 4 년 전
부모
커밋
d3ebedeef2

+ 8 - 7
app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchHolder.kt

@@ -6,6 +6,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
 import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
 import eu.kanade.tachiyomi.util.view.gone
 import eu.kanade.tachiyomi.util.view.visible
+import kotlinx.android.synthetic.main.global_search_controller_card.no_results_found
 import kotlinx.android.synthetic.main.global_search_controller_card.progress
 import kotlinx.android.synthetic.main.global_search_controller_card.recycler
 import kotlinx.android.synthetic.main.global_search_controller_card.source_card
@@ -58,15 +59,15 @@ class GlobalSearchHolder(view: View, val adapter: GlobalSearchAdapter) :
         when {
             results == null -> {
                 progress.visible()
-                showHolder()
+                showResultsHolder()
             }
             results.isEmpty() -> {
                 progress.gone()
-                hideHolder()
+                showNoResults()
             }
             else -> {
                 progress.gone()
-                showHolder()
+                showResultsHolder()
             }
         }
         if (results !== lastBoundResults) {
@@ -101,13 +102,13 @@ class GlobalSearchHolder(view: View, val adapter: GlobalSearchAdapter) :
         return null
     }
 
-    private fun showHolder() {
-        title_wrapper.visible()
+    private fun showResultsHolder() {
+        no_results_found.gone()
         source_card.visible()
     }
 
-    private fun hideHolder() {
-        title_wrapper.gone()
+    private fun showNoResults() {
+        no_results_found.visible()
         source_card.gone()
     }
 }

+ 10 - 0
app/src/main/res/layout/global_search_controller_card.xml

@@ -38,6 +38,16 @@
 
     </androidx.constraintlayout.widget.ConstraintLayout>
 
+    <TextView
+        android:id="@+id/no_results_found"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingStart="@dimen/material_component_text_fields_padding_above_and_below_label"
+        android:paddingEnd="@dimen/material_component_text_fields_padding_above_and_below_label"
+        android:paddingBottom="@dimen/material_component_text_fields_padding_above_and_below_label"
+        android:text="@string/no_results_found"
+        android:visibility="gone" />
+
     <androidx.cardview.widget.CardView
         android:id="@+id/source_card"
         style="@style/Theme.Widget.CardView.Item"