mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 01:11:54 +01:00
parent
36dfb2484a
commit
242c556346
@ -42,7 +42,7 @@ abstract class LibraryHolder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun setReadingButton(item: LibraryItem) {
|
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
|
View.VISIBLE else View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import eu.kanade.tachiyomi.util.system.dpToPx
|
|||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||||
import eu.kanade.tachiyomi.util.view.visible
|
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.*
|
||||||
import kotlinx.android.synthetic.main.manga_list_item.view.*
|
import kotlinx.android.synthetic.main.manga_list_item.view.*
|
||||||
import kotlinx.android.synthetic.main.unread_download_badge.*
|
import kotlinx.android.synthetic.main.unread_download_badge.*
|
||||||
@ -33,7 +34,6 @@ class LibraryListHolder(
|
|||||||
) : LibraryHolder(view, adapter) {
|
) : LibraryHolder(view, adapter) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
play_layout.setOnClickListener { playButtonClicked() }
|
|
||||||
badge_view?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
badge_view?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
marginEnd = (if (padEnd) 22 else 12).dpToPx
|
marginEnd = (if (padEnd) 22 else 12).dpToPx
|
||||||
}
|
}
|
||||||
@ -59,7 +59,6 @@ class LibraryListHolder(
|
|||||||
title.textAlignment = View.TEXT_ALIGNMENT_CENTER
|
title.textAlignment = View.TEXT_ALIGNMENT_CENTER
|
||||||
card.gone()
|
card.gone()
|
||||||
badge_view.gone()
|
badge_view.gone()
|
||||||
play_layout.gone()
|
|
||||||
padding.gone()
|
padding.gone()
|
||||||
subtitle.gone()
|
subtitle.gone()
|
||||||
return
|
return
|
||||||
@ -73,29 +72,21 @@ class LibraryListHolder(
|
|||||||
setUnreadBadge(badge_view, item)
|
setUnreadBadge(badge_view, item)
|
||||||
|
|
||||||
subtitle.text = item.manga.author?.trim()
|
subtitle.text = item.manga.author?.trim()
|
||||||
subtitle.visibility = if (!item.manga.author.isNullOrBlank()) View.VISIBLE
|
subtitle.visibleIf(!item.manga.author.isNullOrBlank())
|
||||||
else View.GONE
|
|
||||||
|
|
||||||
setReadingButton(item)
|
|
||||||
|
|
||||||
// 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)
|
||||||
else {
|
else {
|
||||||
val id = item.manga.id ?: return
|
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)
|
GlideApp.with(view.context).load(item.manga)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
.signature(ObjectKey(MangaImpl.getLastCoverFetch(id).toString()))
|
.signature(ObjectKey(MangaImpl.getLastCoverFetch(id).toString()))
|
||||||
.override(height)
|
.centerCrop()
|
||||||
.into(cover_thumbnail)
|
.into(cover_thumbnail)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun playButtonClicked() {
|
|
||||||
adapter.libraryListener.startReading(adapterPosition)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onActionStateChanged(position: Int, actionState: Int) {
|
override fun onActionStateChanged(position: Int, actionState: Int) {
|
||||||
super.onActionStateChanged(position, actionState)
|
super.onActionStateChanged(position, actionState)
|
||||||
if (actionState == 2) {
|
if (actionState == 2) {
|
||||||
|
@ -8,10 +8,12 @@ import eu.davidea.flexibleadapter.items.IFlexible
|
|||||||
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 kotlinx.android.synthetic.main.manga_list_item.*
|
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(
|
class MangaHolder(
|
||||||
private val view: View,
|
view: View,
|
||||||
private val adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>
|
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>
|
||||||
) : BaseFlexibleViewHolder(view, adapter) {
|
) : BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
fun bind(item: MangaItem) {
|
fun bind(item: MangaItem) {
|
||||||
|
@ -2,15 +2,11 @@ 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.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,16 +38,5 @@ 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()
|
|
||||||
.placeholder(android.R.color.transparent)
|
|
||||||
.transition(DrawableTransitionOptions.withCrossFade())
|
|
||||||
.into(StateImageViewTarget(cover_thumbnail, progress))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,17 +6,18 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
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">
|
||||||
android:minHeight="@dimen/material_component_lists_single_line_with_avatar_height">
|
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:id="@+id/card"
|
android:id="@+id/card"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/material_layout_avatar"
|
||||||
android:layout_marginTop="6dp"
|
android:layout_marginTop="6dp"
|
||||||
android:layout_marginBottom="6dp"
|
android:layout_marginBottom="6dp"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="8dp"
|
||||||
app:layout_constrainedHeight="true"
|
app:layout_constrainedHeight="true"
|
||||||
|
app:cardElevation="0dp"
|
||||||
|
app:cardBackgroundColor="@color/background"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintVertical_bias="0.0">
|
app:layout_constraintVertical_bias="0.0">
|
||||||
@ -24,11 +25,10 @@
|
|||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/cover_thumbnail"
|
android:id="@+id/cover_thumbnail"
|
||||||
android:layout_width="@dimen/material_component_lists_single_line_with_avatar_height"
|
android:layout_width="@dimen/material_layout_avatar"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/material_layout_avatar"
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:background="?android:attr/colorBackground"
|
android:background="?android:attr/colorBackground"
|
||||||
android:maxHeight="150dp"
|
|
||||||
app:layout_constrainedHeight="true"
|
app:layout_constrainedHeight="true"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
@ -38,29 +38,6 @@
|
|||||||
tools:ignore="ContentDescription"
|
tools:ignore="ContentDescription"
|
||||||
tools:src="@mipmap/ic_launcher" />
|
tools:src="@mipmap/ic_launcher" />
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/play_layout"
|
|
||||||
android:layout_width="@dimen/material_component_lists_single_line_with_avatar_height"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:clickable="true"
|
|
||||||
android:focusable="true"
|
|
||||||
android:visibility="gone"
|
|
||||||
tools:visibility="visible">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/play_button"
|
|
||||||
android:layout_width="30dp"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:background="@drawable/round_play_background"
|
|
||||||
android:contentDescription="@string/start_reading"
|
|
||||||
android:padding="6dp"
|
|
||||||
android:src="@drawable/ic_start_reading_white_24dp"
|
|
||||||
android:tint="@android:color/white" />
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progress"
|
android:id="@+id/progress"
|
||||||
style="?android:attr/progressBarStyleSmall"
|
style="?android:attr/progressBarStyleSmall"
|
||||||
@ -81,7 +58,7 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="12dp"
|
android:layout_marginStart="12dp"
|
||||||
android:layout_marginTop="2dp"
|
android:layout_marginTop="6dp"
|
||||||
android:layout_marginEnd="6dp"
|
android:layout_marginEnd="6dp"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="3"
|
android:maxLines="3"
|
||||||
@ -100,7 +77,6 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="6dp"
|
android:layout_marginEnd="6dp"
|
||||||
android:layout_marginBottom="14dp"
|
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
|
Loading…
Reference in New Issue
Block a user