From 242c55634647c7db81f972d613a00433fb2895dd Mon Sep 17 00:00:00 2001 From: Carlos <2092019+CarlosEsco@users.noreply.github.com> Date: Sat, 2 May 2020 13:33:16 -0400 Subject: [PATCH] condense list view (#281) * condense list view * switch to square --- .../tachiyomi/ui/library/LibraryHolder.kt | 2 +- .../tachiyomi/ui/library/LibraryListHolder.kt | 17 ++------- .../tachiyomi/ui/migration/MangaHolder.kt | 6 ++- .../source/browse/BrowseSourceListHolder.kt | 15 -------- app/src/main/res/layout/manga_list_item.xml | 38 ++++--------------- 5 files changed, 16 insertions(+), 62 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHolder.kt index 1b8b2cc245..8f87fcfa2c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHolder.kt @@ -42,7 +42,7 @@ abstract class LibraryHolder( } fun setReadingButton(item: LibraryItem) { - play_layout.visibility = if (item.manga.unread > 0 && item.unreadType > 0 && !item.hideReadingButton) + play_layout?.visibility = if (item.manga.unread > 0 && item.unreadType > 0 && !item.hideReadingButton) View.VISIBLE else View.GONE } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt index 17679f0f63..bd6fe6cf96 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt @@ -12,6 +12,7 @@ import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.view.gone import eu.kanade.tachiyomi.util.view.updateLayoutParams import eu.kanade.tachiyomi.util.view.visible +import eu.kanade.tachiyomi.util.view.visibleIf import kotlinx.android.synthetic.main.manga_list_item.* import kotlinx.android.synthetic.main.manga_list_item.view.* import kotlinx.android.synthetic.main.unread_download_badge.* @@ -33,7 +34,6 @@ class LibraryListHolder( ) : LibraryHolder(view, adapter) { init { - play_layout.setOnClickListener { playButtonClicked() } badge_view?.updateLayoutParams { marginEnd = (if (padEnd) 22 else 12).dpToPx } @@ -59,7 +59,6 @@ class LibraryListHolder( title.textAlignment = View.TEXT_ALIGNMENT_CENTER card.gone() badge_view.gone() - play_layout.gone() padding.gone() subtitle.gone() return @@ -73,29 +72,21 @@ class LibraryListHolder( setUnreadBadge(badge_view, item) subtitle.text = item.manga.author?.trim() - subtitle.visibility = if (!item.manga.author.isNullOrBlank()) View.VISIBLE - else View.GONE - - setReadingButton(item) + subtitle.visibleIf(!item.manga.author.isNullOrBlank()) // Update the cover. if (item.manga.thumbnail_url == null) Glide.with(view.context).clear(cover_thumbnail) else { val id = item.manga.id ?: return - val height = itemView.context.resources.getDimensionPixelSize(R.dimen - .material_component_lists_single_line_with_avatar_height) + GlideApp.with(view.context).load(item.manga) .diskCacheStrategy(DiskCacheStrategy.RESOURCE) .signature(ObjectKey(MangaImpl.getLastCoverFetch(id).toString())) - .override(height) + .centerCrop() .into(cover_thumbnail) } } - private fun playButtonClicked() { - adapter.libraryListener.startReading(adapterPosition) - } - override fun onActionStateChanged(position: Int, actionState: Int) { super.onActionStateChanged(position, actionState) if (actionState == 2) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/MangaHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/MangaHolder.kt index 5e8e995d36..0f7b6c6802 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/MangaHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/MangaHolder.kt @@ -8,10 +8,12 @@ import eu.davidea.flexibleadapter.items.IFlexible import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder import kotlinx.android.synthetic.main.manga_list_item.* +import kotlinx.android.synthetic.main.manga_list_item.subtitle +import kotlinx.android.synthetic.main.manga_list_item.title class MangaHolder( - private val view: View, - private val adapter: FlexibleAdapter> + view: View, + adapter: FlexibleAdapter> ) : BaseFlexibleViewHolder(view, adapter) { fun bind(item: MangaItem) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceListHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceListHolder.kt index 5fcb45c843..850f6de757 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceListHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/source/browse/BrowseSourceListHolder.kt @@ -2,15 +2,11 @@ package eu.kanade.tachiyomi.ui.source.browse import android.view.View 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.items.IFlexible import eu.kanade.tachiyomi.R 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.widget.StateImageViewTarget import kotlinx.android.synthetic.main.manga_list_item.* /** @@ -42,16 +38,5 @@ class BrowseSourceListHolder(private val view: View, adapter: FlexibleAdapter + android:background="@drawable/list_item_selector"> @@ -24,11 +25,10 @@ - - - - - -