Fix crash on recents when using grouped
This commit is contained in:
parent
2e563d7d0c
commit
cd2b348719
@ -0,0 +1,24 @@
|
|||||||
|
package eu.kanade.tachiyomi.ui.recents
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.databinding.RecentsFooterItemBinding
|
||||||
|
import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterHolder
|
||||||
|
|
||||||
|
class RecentMangaFooterHolder(
|
||||||
|
view: View,
|
||||||
|
val adapter: RecentMangaAdapter
|
||||||
|
) : BaseChapterHolder(view, adapter) {
|
||||||
|
private val binding = RecentsFooterItemBinding.bind(view)
|
||||||
|
|
||||||
|
fun bind(recentsType: Int) {
|
||||||
|
when (recentsType) {
|
||||||
|
RecentMangaHeaderItem.CONTINUE_READING -> {
|
||||||
|
binding.title.setText(R.string.view_history)
|
||||||
|
}
|
||||||
|
RecentMangaHeaderItem.NEW_CHAPTERS -> {
|
||||||
|
binding.title.setText(R.string.view_all_updates)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,17 +23,6 @@ class RecentMangaHolder(
|
|||||||
binding.cardLayout.setOnClickListener { adapter.delegate.onCoverClick(flexibleAdapterPosition) }
|
binding.cardLayout.setOnClickListener { adapter.delegate.onCoverClick(flexibleAdapterPosition) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bind(recentsType: Int) {
|
|
||||||
when (recentsType) {
|
|
||||||
RecentMangaHeaderItem.CONTINUE_READING -> {
|
|
||||||
binding.title.setText(R.string.view_history)
|
|
||||||
}
|
|
||||||
RecentMangaHeaderItem.NEW_CHAPTERS -> {
|
|
||||||
binding.title.setText(R.string.view_all_updates)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun bind(item: RecentMangaItem) {
|
fun bind(item: RecentMangaItem) {
|
||||||
binding.downloadButton.downloadButton.visibleIf(item.mch.manga.source != LocalSource.ID)
|
binding.downloadButton.downloadButton.visibleIf(item.mch.manga.source != LocalSource.ID)
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.ChapterImpl
|
import eu.kanade.tachiyomi.data.database.models.ChapterImpl
|
||||||
import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory
|
import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory
|
||||||
|
import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterHolder
|
||||||
import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterItem
|
import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterItem
|
||||||
|
|
||||||
class RecentMangaItem(
|
class RecentMangaItem(
|
||||||
@ -16,7 +17,7 @@ class RecentMangaItem(
|
|||||||
chapter: Chapter = ChapterImpl(),
|
chapter: Chapter = ChapterImpl(),
|
||||||
header: AbstractHeaderItem<*>?
|
header: AbstractHeaderItem<*>?
|
||||||
) :
|
) :
|
||||||
BaseChapterItem<RecentMangaHolder, AbstractHeaderItem<*>>(chapter, header) {
|
BaseChapterItem<BaseChapterHolder, AbstractHeaderItem<*>>(chapter, header) {
|
||||||
|
|
||||||
override fun getLayoutRes(): Int {
|
override fun getLayoutRes(): Int {
|
||||||
return if (mch.manga.id == null) R.layout.recents_footer_item
|
return if (mch.manga.id == null) R.layout.recents_footer_item
|
||||||
@ -26,8 +27,9 @@ class RecentMangaItem(
|
|||||||
override fun createViewHolder(
|
override fun createViewHolder(
|
||||||
view: View,
|
view: View,
|
||||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>
|
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>
|
||||||
): RecentMangaHolder {
|
): BaseChapterHolder {
|
||||||
return RecentMangaHolder(view, adapter as RecentMangaAdapter)
|
return if (mch.manga.id == null) RecentMangaFooterHolder(view, adapter as RecentMangaAdapter)
|
||||||
|
else RecentMangaHolder(view, adapter as RecentMangaAdapter)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isSwipeable(): Boolean {
|
override fun isSwipeable(): Boolean {
|
||||||
@ -51,11 +53,11 @@ class RecentMangaItem(
|
|||||||
|
|
||||||
override fun bindViewHolder(
|
override fun bindViewHolder(
|
||||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
||||||
holder: RecentMangaHolder,
|
holder: BaseChapterHolder,
|
||||||
position: Int,
|
position: Int,
|
||||||
payloads: MutableList<Any?>?
|
payloads: MutableList<Any?>?
|
||||||
) {
|
) {
|
||||||
if (mch.manga.id == null) holder.bind((header as? RecentMangaHeaderItem)?.recentsType ?: 0)
|
if (mch.manga.id == null) (holder as? RecentMangaFooterHolder)?.bind((header as? RecentMangaHeaderItem)?.recentsType ?: 0)
|
||||||
else holder.bind(this)
|
else (holder as? RecentMangaHolder)?.bind(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:src="@drawable/ic_arrow_forward_24dp"
|
android:src="@drawable/ic_arrow_forward_24dp"
|
||||||
android:tint="?colorAccent"
|
app:tint="?colorAccent"
|
||||||
android:layout_marginStart="12dp"
|
android:layout_marginStart="12dp"
|
||||||
app:layout_constraintTop_toTopOf="@id/title"
|
app:layout_constraintTop_toTopOf="@id/title"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/title"
|
app:layout_constraintBottom_toBottomOf="@id/title"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user