From 6378a41b6da9045f89937a8dfcd93424994401a2 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 27 Dec 2020 15:34:14 -0500 Subject: [PATCH] Minor cleanup of UpdatesHolder --- .../ui/recent/updates/UpdatesAdapter.kt | 12 +++++++-- .../ui/recent/updates/UpdatesController.kt | 2 +- .../ui/recent/updates/UpdatesHolder.kt | 25 +++---------------- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesAdapter.kt index 0d0c7d9e87..39d485bc7d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesAdapter.kt @@ -1,10 +1,18 @@ package eu.kanade.tachiyomi.ui.recent.updates +import android.content.Context import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.items.IFlexible +import eu.kanade.tachiyomi.R +import eu.kanade.tachiyomi.util.system.getResourceColor -class UpdatesAdapter(val controller: UpdatesController) : - FlexibleAdapter>(null, controller, true) { +class UpdatesAdapter( + val controller: UpdatesController, + context: Context +) : FlexibleAdapter>(null, controller, true) { + + var readColor = context.getResourceColor(R.attr.colorOnSurface, 0.38f) + var unreadColor = context.getResourceColor(R.attr.colorOnSurface) val coverClickListener: OnCoverClickListener = controller diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt index ad2a51a3c8..9d4e9bfb1a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesController.kt @@ -84,7 +84,7 @@ class UpdatesController : val layoutManager = LinearLayoutManager(view.context) binding.recycler.layoutManager = layoutManager binding.recycler.setHasFixedSize(true) - adapter = UpdatesAdapter(this@UpdatesController) + adapter = UpdatesAdapter(this@UpdatesController, view.context) binding.recycler.adapter = adapter adapter?.fastScroller = binding.fastScroller diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt index 1820e17fdd..2d712a484c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/updates/UpdatesHolder.kt @@ -13,11 +13,9 @@ import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.data.glide.toMangaThumbnail import eu.kanade.tachiyomi.databinding.UpdatesItemBinding import eu.kanade.tachiyomi.source.LocalSource -import eu.kanade.tachiyomi.util.system.getResourceColor /** * Holder that contains chapter item - * Uses R.layout.item_recent_chapters. * UI related actions should be called from here. * * @param view the inflated view for this holder. @@ -30,28 +28,13 @@ class UpdatesHolder(private val view: View, private val adapter: UpdatesAdapter) private val binding = UpdatesItemBinding.bind(view) - private var readColor = view.context.getResourceColor(R.attr.colorOnSurface, 0.38f) - private var unreadColor = view.context.getResourceColor(R.attr.colorOnSurface) - - /** - * Currently bound item. - */ - private var item: UpdatesItem? = null - init { binding.mangaCover.setOnClickListener { adapter.coverClickListener.onCoverClick(bindingAdapterPosition) } } - /** - * Set values of view - * - * @param item item containing chapter information - */ fun bind(item: UpdatesItem) { - this.item = item - // Set chapter title binding.chapterTitle.text = item.chapter.name @@ -60,11 +43,11 @@ class UpdatesHolder(private val view: View, private val adapter: UpdatesAdapter) // Check if chapter is read and set correct color if (item.chapter.read) { - binding.chapterTitle.setTextColor(readColor) - binding.mangaTitle.setTextColor(readColor) + binding.chapterTitle.setTextColor(adapter.readColor) + binding.mangaTitle.setTextColor(adapter.readColor) } else { - binding.chapterTitle.setTextColor(unreadColor) - binding.mangaTitle.setTextColor(unreadColor) + binding.chapterTitle.setTextColor(adapter.unreadColor) + binding.mangaTitle.setTextColor(adapter.unreadColor) } // Set chapter status