diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/DateSectionItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/DateSectionItem.kt index 0143f3912..1eb7b56fb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/DateSectionItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/DateSectionItem.kt @@ -2,26 +2,26 @@ package eu.kanade.tachiyomi.ui.recent import android.text.format.DateUtils import android.view.View -import android.widget.TextView import androidx.recyclerview.widget.RecyclerView import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.items.AbstractHeaderItem import eu.davidea.flexibleadapter.items.IFlexible import eu.davidea.viewholders.FlexibleViewHolder import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.databinding.RecentSectionItemBinding import java.util.Date -class DateSectionItem(val date: Date) : AbstractHeaderItem() { +class DateSectionItem(val date: Date) : AbstractHeaderItem() { override fun getLayoutRes(): Int { return R.layout.recent_section_item } - override fun createViewHolder(view: View, adapter: FlexibleAdapter>): Holder { - return Holder(view, adapter) + override fun createViewHolder(view: View, adapter: FlexibleAdapter>): DateSectionItemHolder { + return DateSectionItemHolder(view, adapter) } - override fun bindViewHolder(adapter: FlexibleAdapter>, holder: Holder, position: Int, payloads: List?) { + override fun bindViewHolder(adapter: FlexibleAdapter>, holder: DateSectionItemHolder, position: Int, payloads: List?) { holder.bind(this) } @@ -37,14 +37,14 @@ class DateSectionItem(val date: Date) : AbstractHeaderItem) : FlexibleViewHolder(view, adapter, true) { + inner class DateSectionItemHolder(view: View, adapter: FlexibleAdapter<*>) : FlexibleViewHolder(view, adapter, true) { + + private val binding = RecentSectionItemBinding.bind(view) private val now = Date().time - val section_text: TextView = view.findViewById(R.id.section_text) - fun bind(item: DateSectionItem) { - section_text.text = DateUtils.getRelativeTimeSpanString(item.date.time, now, DateUtils.DAY_IN_MILLIS) + binding.sectionText.text = DateUtils.getRelativeTimeSpanString(item.date.time, now, DateUtils.DAY_IN_MILLIS) } } }