Update latest tab with the new global search features

This commit is contained in:
Jobobby04 2020-07-19 19:52:50 -04:00
parent 8e94afb9c1
commit 4771fa529d
2 changed files with 34 additions and 26 deletions

View File

@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.LatestAdapter import eu.kanade.tachiyomi.ui.browse.source.globalsearch.LatestAdapter
import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible import eu.kanade.tachiyomi.util.view.visible
import kotlinx.android.synthetic.main.latest_controller_card.no_results_found
import kotlinx.android.synthetic.main.latest_controller_card.progress import kotlinx.android.synthetic.main.latest_controller_card.progress
import kotlinx.android.synthetic.main.latest_controller_card.recycler import kotlinx.android.synthetic.main.latest_controller_card.recycler
import kotlinx.android.synthetic.main.latest_controller_card.source_card import kotlinx.android.synthetic.main.latest_controller_card.source_card
@ -62,15 +63,15 @@ class LatestHolder(view: View, val adapter: LatestAdapter) :
when { when {
results == null -> { results == null -> {
progress.visible() progress.visible()
showHolder() showResultsHolder()
} }
results.isEmpty() -> { results.isEmpty() -> {
progress.gone() progress.gone()
hideHolder() showNoResults()
} }
else -> { else -> {
progress.gone() progress.gone()
showHolder() showResultsHolder()
} }
} }
if (results !== lastBoundResults) { if (results !== lastBoundResults) {
@ -105,13 +106,13 @@ class LatestHolder(view: View, val adapter: LatestAdapter) :
return null return null
} }
private fun showHolder() { private fun showResultsHolder() {
title_wrapper.visible() no_results_found.gone()
source_card.visible() source_card.visible()
} }
private fun hideHolder() { private fun showNoResults() {
title_wrapper.gone() no_results_found.visible()
source_card.gone() source_card.gone()
} }
} }

View File

@ -6,41 +6,48 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<RelativeLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/title_wrapper" android:id="@+id/title_wrapper"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:padding="@dimen/material_component_text_fields_padding_above_and_below_label"
app:srcCompat="@drawable/ic_add_24dp"
app:tint="?android:attr/textColorPrimary"
tools:ignore="ContentDescription" />
<TextView <TextView
android:id="@+id/title" android:id="@+id/title"
style="@style/TextAppearance.Regular.SubHeading" style="@style/TextAppearance.Regular.SubHeading"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toEndOf="@+id/image"
android:padding="@dimen/material_component_text_fields_padding_above_and_below_label" android:padding="@dimen/material_component_text_fields_padding_above_and_below_label"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/title_more_icon"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Title" /> tools:text="Title" />
<ImageView <ImageView
android:id="@+id/title_more_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:contentDescription="@string/label_more"
android:layout_centerVertical="true"
android:padding="@dimen/material_component_text_fields_padding_above_and_below_label" android:padding="@dimen/material_component_text_fields_padding_above_and_below_label"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_arrow_forward_24dp" app:srcCompat="@drawable/ic_arrow_forward_24dp"
app:tint="?android:attr/textColorPrimary" app:tint="?android:attr/textColorPrimary" />
tools:ignore="ContentDescription" />
</RelativeLayout> </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 <androidx.cardview.widget.CardView
android:id="@+id/source_card" android:id="@+id/source_card"