Make entire history item card clickable

This commit is contained in:
arkon 2020-04-22 09:14:30 -04:00
parent badddcf0de
commit 02207f6cfd
4 changed files with 14 additions and 15 deletions

View File

@ -20,10 +20,8 @@ class HistoryAdapter(controller: HistoryController) :
val sourceManager by injectLazy<SourceManager>() val sourceManager by injectLazy<SourceManager>()
val resumeClickListener: OnResumeClickListener = controller val resumeClickListener: OnResumeClickListener = controller
val removeClickListener: OnRemoveClickListener = controller val removeClickListener: OnRemoveClickListener = controller
val itemClickListener: OnItemClickListener = controller
val coverClickListener: OnCoverClickListener = controller
/** /**
* DecimalFormat used to display correct chapter number * DecimalFormat used to display correct chapter number
@ -44,7 +42,7 @@ class HistoryAdapter(controller: HistoryController) :
fun onRemoveClick(position: Int) fun onRemoveClick(position: Int)
} }
interface OnCoverClickListener { interface OnItemClickListener {
fun onCoverClick(position: Int) fun onItemClick(position: Int)
} }
} }

View File

@ -28,7 +28,7 @@ class HistoryController : NucleusController<HistoryControllerBinding, HistoryPre
FlexibleAdapter.OnUpdateListener, FlexibleAdapter.OnUpdateListener,
HistoryAdapter.OnRemoveClickListener, HistoryAdapter.OnRemoveClickListener,
HistoryAdapter.OnResumeClickListener, HistoryAdapter.OnResumeClickListener,
HistoryAdapter.OnCoverClickListener, HistoryAdapter.OnItemClickListener,
RemoveHistoryDialog.Listener { RemoveHistoryDialog.Listener {
/** /**
@ -105,7 +105,7 @@ class HistoryController : NucleusController<HistoryControllerBinding, HistoryPre
RemoveHistoryDialog(this, manga, history).showDialog(router) RemoveHistoryDialog(this, manga, history).showDialog(router)
} }
override fun onCoverClick(position: Int) { override fun onItemClick(position: Int) {
val manga = adapter?.getItem(position)?.mch?.manga ?: return val manga = adapter?.getItem(position)?.mch?.manga ?: return
router.pushController(MangaController(manga).withFadeTransaction()) router.pushController(MangaController(manga).withFadeTransaction())
} }

View File

@ -10,6 +10,7 @@ import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
import eu.kanade.tachiyomi.util.lang.toTimestampString import eu.kanade.tachiyomi.util.lang.toTimestampString
import java.util.Date import java.util.Date
import kotlinx.android.synthetic.main.history_item.cover import kotlinx.android.synthetic.main.history_item.cover
import kotlinx.android.synthetic.main.history_item.holder
import kotlinx.android.synthetic.main.history_item.manga_subtitle import kotlinx.android.synthetic.main.history_item.manga_subtitle
import kotlinx.android.synthetic.main.history_item.manga_title import kotlinx.android.synthetic.main.history_item.manga_title
import kotlinx.android.synthetic.main.history_item.remove import kotlinx.android.synthetic.main.history_item.remove
@ -30,16 +31,16 @@ class HistoryHolder(
) : BaseFlexibleViewHolder(view, adapter) { ) : BaseFlexibleViewHolder(view, adapter) {
init { init {
holder.setOnClickListener {
adapter.itemClickListener.onItemClick(bindingAdapterPosition)
}
remove.setOnClickListener { remove.setOnClickListener {
adapter.removeClickListener.onRemoveClick(adapterPosition) adapter.removeClickListener.onRemoveClick(bindingAdapterPosition)
} }
resume.setOnClickListener { resume.setOnClickListener {
adapter.resumeClickListener.onResumeClick(adapterPosition) adapter.resumeClickListener.onResumeClick(bindingAdapterPosition)
}
cover.setOnClickListener {
adapter.coverClickListener.onCoverClick(adapterPosition)
} }
} }

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/holder"
style="@style/Theme.Widget.CardView.Item" style="@style/Theme.Widget.CardView.Item"
android:padding="0dp"> android:padding="0dp">
@ -12,9 +13,7 @@
android:id="@+id/cover" android:id="@+id/cover"
android:layout_width="85dp" android:layout_width="85dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:clickable="true"
android:contentDescription="@string/description_cover" android:contentDescription="@string/description_cover"
android:focusable="true"
android:scaleType="centerCrop" /> android:scaleType="centerCrop" />
<RelativeLayout <RelativeLayout
@ -32,6 +31,7 @@
android:id="@+id/manga_title" android:id="@+id/manga_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2" android:maxLines="2"
android:textAppearance="@style/TextAppearance.Medium.Title" /> android:textAppearance="@style/TextAppearance.Medium.Title" />