Replace more Kotlin synthetics
This commit is contained in:
+2
-2
@@ -491,13 +491,13 @@ open class BrowseSourceController(bundle: Bundle) :
|
||||
* @param manga the manga to find.
|
||||
* @return the holder of the manga or null if it's not bound.
|
||||
*/
|
||||
private fun getHolder(manga: Manga): SourceHolder? {
|
||||
private fun getHolder(manga: Manga): SourceHolder<*>? {
|
||||
val adapter = adapter ?: return null
|
||||
|
||||
adapter.allBoundViewHolders.forEach { holder ->
|
||||
val item = adapter.getItem(holder.bindingAdapterPosition) as? SourceItem
|
||||
if (item != null && item.manga.id!! == manga.id!!) {
|
||||
return holder as SourceHolder
|
||||
return holder as SourceHolder<*>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -18,9 +18,9 @@ import eu.kanade.tachiyomi.widget.StateImageViewTarget
|
||||
* @constructor creates a new catalogue holder.
|
||||
*/
|
||||
class SourceComfortableGridHolder(private val view: View, private val adapter: FlexibleAdapter<*>) :
|
||||
SourceGridHolder(view, adapter) {
|
||||
SourceHolder<SourceComfortableGridItemBinding>(view, adapter) {
|
||||
|
||||
private val binding = SourceComfortableGridItemBinding.bind(view)
|
||||
override val binding = SourceComfortableGridItemBinding.bind(view)
|
||||
|
||||
/**
|
||||
* Method called from [CatalogueAdapter.onBindViewHolder]. It updates the data for this
|
||||
|
||||
@@ -18,9 +18,9 @@ import eu.kanade.tachiyomi.widget.StateImageViewTarget
|
||||
* @constructor creates a new catalogue holder.
|
||||
*/
|
||||
open class SourceGridHolder(private val view: View, private val adapter: FlexibleAdapter<*>) :
|
||||
SourceHolder(view, adapter) {
|
||||
SourceHolder<SourceComfortableGridItemBinding>(view, adapter) {
|
||||
|
||||
private val binding = SourceComfortableGridItemBinding.bind(view)
|
||||
override val binding = SourceComfortableGridItemBinding.bind(view)
|
||||
|
||||
/**
|
||||
* Method called from [CatalogueAdapter.onBindViewHolder]. It updates the data for this
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package eu.kanade.tachiyomi.ui.browse.source.browse
|
||||
|
||||
import android.view.View
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.viewholders.FlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
@@ -11,9 +12,11 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
* @param view the inflated view for this holder.
|
||||
* @param adapter the adapter handling this holder.
|
||||
*/
|
||||
abstract class SourceHolder(view: View, adapter: FlexibleAdapter<*>) :
|
||||
abstract class SourceHolder<VB : ViewBinding>(view: View, adapter: FlexibleAdapter<*>) :
|
||||
FlexibleViewHolder(view, adapter) {
|
||||
|
||||
abstract val binding: VB
|
||||
|
||||
/**
|
||||
* Method called from [CatalogueAdapter.onBindViewHolder]. It updates the data for this
|
||||
* holder with the given manga.
|
||||
|
||||
@@ -13,12 +13,12 @@ import eu.davidea.flexibleadapter.items.IFlexible
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues.DisplayMode
|
||||
import eu.kanade.tachiyomi.databinding.SourceComfortableGridItemBinding
|
||||
import eu.kanade.tachiyomi.databinding.SourceCompactGridItemBinding
|
||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||
import kotlinx.android.synthetic.main.source_compact_grid_item.view.card
|
||||
import kotlinx.android.synthetic.main.source_compact_grid_item.view.gradient
|
||||
|
||||
class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMode>) :
|
||||
AbstractFlexibleItem<SourceHolder>() {
|
||||
AbstractFlexibleItem<SourceHolder<*>>() {
|
||||
|
||||
override fun getLayoutRes(): Int {
|
||||
return when (displayMode.get()) {
|
||||
@@ -31,17 +31,18 @@ class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMo
|
||||
override fun createViewHolder(
|
||||
view: View,
|
||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>
|
||||
): SourceHolder {
|
||||
): SourceHolder<*> {
|
||||
return when (displayMode.get()) {
|
||||
DisplayMode.COMPACT_GRID -> {
|
||||
val binding = SourceCompactGridItemBinding.bind(view)
|
||||
val parent = adapter.recyclerView as AutofitRecyclerView
|
||||
val coverHeight = parent.itemWidth / 3 * 4
|
||||
view.apply {
|
||||
card.layoutParams = FrameLayout.LayoutParams(
|
||||
binding.card.layoutParams = FrameLayout.LayoutParams(
|
||||
MATCH_PARENT,
|
||||
coverHeight
|
||||
)
|
||||
gradient.layoutParams = FrameLayout.LayoutParams(
|
||||
binding.gradient.layoutParams = FrameLayout.LayoutParams(
|
||||
MATCH_PARENT,
|
||||
coverHeight / 2,
|
||||
Gravity.BOTTOM
|
||||
@@ -50,10 +51,11 @@ class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMo
|
||||
SourceGridHolder(view, adapter)
|
||||
}
|
||||
DisplayMode.COMFORTABLE_GRID -> {
|
||||
val binding = SourceComfortableGridItemBinding.bind(view)
|
||||
val parent = adapter.recyclerView as AutofitRecyclerView
|
||||
val coverHeight = parent.itemWidth / 3 * 4
|
||||
view.apply {
|
||||
card.layoutParams = ConstraintLayout.LayoutParams(
|
||||
binding.card.layoutParams = ConstraintLayout.LayoutParams(
|
||||
MATCH_PARENT,
|
||||
coverHeight
|
||||
)
|
||||
@@ -68,7 +70,7 @@ class SourceItem(val manga: Manga, private val displayMode: Preference<DisplayMo
|
||||
|
||||
override fun bindViewHolder(
|
||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
||||
holder: SourceHolder,
|
||||
holder: SourceHolder<*>,
|
||||
position: Int,
|
||||
payloads: List<Any?>?
|
||||
) {
|
||||
|
||||
@@ -22,9 +22,9 @@ import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
* @constructor creates a new catalogue holder.
|
||||
*/
|
||||
class SourceListHolder(private val view: View, adapter: FlexibleAdapter<*>) :
|
||||
SourceHolder(view, adapter) {
|
||||
SourceHolder<SourceListItemBinding>(view, adapter) {
|
||||
|
||||
private val binding = SourceListItemBinding.bind(view)
|
||||
override val binding = SourceListItemBinding.bind(view)
|
||||
|
||||
private val favoriteColor = view.context.getResourceColor(R.attr.colorOnSurface, 0.38f)
|
||||
private val unfavoriteColor = view.context.getResourceColor(R.attr.colorOnSurface)
|
||||
|
||||
Reference in New Issue
Block a user