Updated ui of global search

you know md2 and all that
also sources with no results say "no results found"
This commit is contained in:
Jay 2020-05-10 14:36:48 -04:00
parent 0244e1edb4
commit 1cca914c8f
5 changed files with 111 additions and 56 deletions

View File

@ -5,6 +5,7 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy
import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.data.glide.GlideApp
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.util.view.visibleIf
import eu.kanade.tachiyomi.widget.StateImageViewTarget import eu.kanade.tachiyomi.widget.StateImageViewTarget
import kotlinx.android.synthetic.main.source_global_search_controller_card_item.* import kotlinx.android.synthetic.main.source_global_search_controller_card_item.*
@ -29,10 +30,8 @@ class SourceSearchCardHolder(view: View, adapter: SourceSearchCardAdapter) :
} }
fun bind(manga: Manga) { fun bind(manga: Manga) {
tvTitle.text = manga.title title.text = manga.title
// Set alpha of thumbnail. favorite_button.visibleIf(manga.favorite)
itemImage.alpha = if (manga.favorite) 0.3f else 1.0f
setImage(manga) setImage(manga)
} }

View File

@ -52,7 +52,8 @@ class SourceSearchHolder(view: View, val adapter: SourceSearchAdapter) :
} }
results.isEmpty() -> { results.isEmpty() -> {
progress.gone() progress.gone()
hideHolder() no_results.visible()
source_card.gone()
} }
else -> { else -> {
progress.gone() progress.gone()
@ -92,12 +93,7 @@ class SourceSearchHolder(view: View, val adapter: SourceSearchAdapter) :
} }
private fun showHolder() { private fun showHolder() {
title.visible()
source_card.visible() source_card.visible()
} no_results.gone()
private fun hideHolder() {
title.gone()
source_card.gone()
} }
} }

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomRightRadius="10dp" />
<solid android:color="@color/unread_badge" />
</shape>

View File

@ -11,19 +11,40 @@
style="@style/TextAppearance.Regular.SubHeading" style="@style/TextAppearance.Regular.SubHeading"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="@dimen/material_component_text_fields_padding_above_and_below_label" android:paddingTop="16dp"
app:layout_constraintBottom_toTopOf="@+id/source_card" android:paddingStart="16dp"
app:layout_constraintHeight_default="wrap" android:paddingEnd="0dp"
android:paddingBottom="0dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:text="Title" /> tools:text="Title" />
<androidx.cardview.widget.CardView <TextView
android:id="@+id/source_card" android:id="@+id/no_results"
style="@style/Theme.Widget.CardView.Item" style="@style/TextAppearance.Regular.Body1"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="144dp" android:paddingStart="16dp"
android:paddingEnd="0dp"
android:paddingBottom="16dp"
app:layout_constraintHeight_default="wrap"
android:textColor="?android:textColorSecondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
tools:visibility="visible"
app:layout_constraintTop_toBottomOf="@id/title"
android:text="@string/no_results_found"/>
<FrameLayout
android:id="@+id/source_card"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:minHeight="208dp"
android:paddingTop="2dp"
android:paddingBottom="8dp"
app:layout_constraintTop_toBottomOf="@id/title"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constrainedHeight="true" app:layout_constrainedHeight="true"
@ -41,11 +62,11 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingEnd="4dp" android:paddingEnd="7dp"
android:paddingStart="4dp" android:paddingStart="7dp"
android:clipToPadding="false" android:clipToPadding="false"
tools:listitem="@layout/source_global_search_controller_card_item" /> tools:listitem="@layout/source_global_search_controller_card_item" />
</androidx.cardview.widget.CardView> </FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,55 +1,87 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/list_item_selector"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="8dp" android:background="@drawable/library_item_selector">
android:paddingEnd="4dp"
android:paddingStart="4dp" <com.google.android.material.card.MaterialCardView
android:paddingTop="8dp"> android:id="@+id/card"
android:layout_width="112dp"
android:layout_height="168dp"
android:layout_gravity="bottom"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0">
<ImageView
android:id="@+id/itemImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:background="?android:attr/colorBackground"
tools:background="?android:attr/colorBackground"
tools:ignore="ContentDescription"
tools:src="@mipmap/ic_launcher" />
<ProgressBar <ProgressBar
android:id="@+id/progress" android:id="@+id/progress"
style="?android:attr/progressBarStyleSmall" style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone" android:visibility="gone"
app:layout_constrainedHeight="true"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<ImageView </com.google.android.material.card.MaterialCardView>
android:id="@+id/itemImage"
android:layout_width="112dp"
android:layout_height="112dp"
android:paddingBottom="8dp"
android:scaleType="fitCenter"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription"
tools:src="@mipmap/ic_launcher" />
<TextView <com.google.android.material.card.MaterialCardView
android:id="@+id/tvTitle" android:id="@+id/favorite_button"
style="@style/TextAppearance.Regular.Caption" android:layout_width="wrap_content"
android:layout_width="104dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="0dp" app:cardCornerRadius="10dp"
android:ellipsize="end" app:cardBackgroundColor="@color/unread_badge"
app:cardElevation="2dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent">
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:gravity="center" android:gravity="center"
android:maxLines="1" android:maxLines="1"
android:paddingStart="5dp"
android:paddingEnd="5dp"
android:textSize="13sp"
android:textColor="@color/unread_badge_text"
style="@style/TextAppearance.Regular.Caption.Light"
android:layout_height="wrap_content"
android:tint="@color/md_white_1000"
android:text="@string/in_library"/>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/title"
style="@style/TextAppearance.Regular.Body1.Light"
android:layout_width="110dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:attr/textColorPrimary"
android:textSize="12sp"
app:layout_constrainedHeight="true" app:layout_constrainedHeight="true"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/itemImage" app:layout_constraintTop_toBottomOf="@+id/card"
tools:text="Sample title" /> tools:text="Sample name" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>