Additonal list view fixes

Setting title to 2 lines
Added back image to browse
Set a fixed height to list item
author only shows if there's space just like comfort grid
This commit is contained in:
Jay 2020-05-02 13:50:39 -04:00
parent 242c556346
commit ea81745c8a
3 changed files with 27 additions and 3 deletions

View File

@ -51,6 +51,9 @@ class LibraryListHolder(
constraint_layout.minHeight = 56.dpToPx constraint_layout.minHeight = 56.dpToPx
if (item.manga.isBlank()) { if (item.manga.isBlank()) {
constraint_layout.minHeight = 0 constraint_layout.minHeight = 0
constraint_layout.updateLayoutParams<ViewGroup.MarginLayoutParams> {
height = ViewGroup.MarginLayoutParams.WRAP_CONTENT
}
if (item.manga.status == -1) { if (item.manga.status == -1) {
title.text = null title.text = null
title.gone() title.gone()
@ -63,6 +66,9 @@ class LibraryListHolder(
subtitle.gone() subtitle.gone()
return return
} }
constraint_layout.updateLayoutParams<ViewGroup.MarginLayoutParams> {
height = 52.dpToPx
}
padding.visible() padding.visible()
card.visible() card.visible()
title.textAlignment = View.TEXT_ALIGNMENT_TEXT_START title.textAlignment = View.TEXT_ALIGNMENT_TEXT_START
@ -72,7 +78,9 @@ class LibraryListHolder(
setUnreadBadge(badge_view, item) setUnreadBadge(badge_view, item)
subtitle.text = item.manga.author?.trim() subtitle.text = item.manga.author?.trim()
subtitle.visibleIf(!item.manga.author.isNullOrBlank()) title.post {
subtitle.visibleIf(title.lineCount == 1 && !item.manga.author.isNullOrBlank())
}
// Update the cover. // Update the cover.
if (item.manga.thumbnail_url == null) Glide.with(view.context).clear(cover_thumbnail) if (item.manga.thumbnail_url == null) Glide.with(view.context).clear(cover_thumbnail)

View File

@ -2,11 +2,15 @@ package eu.kanade.tachiyomi.ui.source.browse
import android.view.View import android.view.View
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
import eu.davidea.flexibleadapter.items.IFlexible import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
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.util.system.getResourceColor import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.widget.StateImageViewTarget
import kotlinx.android.synthetic.main.manga_list_item.* import kotlinx.android.synthetic.main.manga_list_item.*
/** /**
@ -38,5 +42,17 @@ class BrowseSourceListHolder(private val view: View, adapter: FlexibleAdapter<IF
} }
override fun setImage(manga: Manga) { override fun setImage(manga: Manga) {
if (manga.thumbnail_url.isNullOrEmpty()) {
GlideApp.with(view.context).clear(contentView)
} else {
GlideApp.with(view.context)
.load(manga)
.diskCacheStrategy(DiskCacheStrategy.DATA)
.dontAnimate()
.centerCrop()
.placeholder(android.R.color.transparent)
.transition(DrawableTransitionOptions.withCrossFade())
.into(StateImageViewTarget(cover_thumbnail, progress))
}
} }
} }

View File

@ -3,7 +3,7 @@
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="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="52dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:id="@+id/constraint_layout" android:id="@+id/constraint_layout"
android:background="@drawable/list_item_selector"> android:background="@drawable/list_item_selector">
@ -61,7 +61,7 @@
android:layout_marginTop="6dp" android:layout_marginTop="6dp"
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="3" android:maxLines="2"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp" android:textSize="16sp"
app:layout_constrainedWidth="true" app:layout_constrainedWidth="true"