mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
parent
28da0b88ae
commit
653fee66eb
15 changed files with 49 additions and 14 deletions
|
@ -330,7 +330,7 @@ class ExtensionBottomSheet @JvmOverloads constructor(context: Context, attrs: At
|
|||
|
||||
fun setMigrationManga(manga: List<MangaItem>?) {
|
||||
if (migAdapter !is MangaAdapter) {
|
||||
migAdapter = MangaAdapter(this)
|
||||
migAdapter = MangaAdapter(this, presenter.preferences.outlineOnCovers().get())
|
||||
migrationFrameLayout?.onBind(migAdapter!!)
|
||||
migAdapter?.stateRestorationPolicy = RecyclerView.Adapter.StateRestorationPolicy.PREVENT_WHEN_EMPTY
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import eu.kanade.tachiyomi.data.image.coil.loadManga
|
|||
import eu.kanade.tachiyomi.databinding.MangaGridItemBinding
|
||||
import eu.kanade.tachiyomi.util.lang.highlightText
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.view.setCards
|
||||
|
||||
/**
|
||||
* Class used to hold the displayed data of a manga in the library, like the cover or the title.
|
||||
|
@ -79,7 +78,6 @@ class LibraryGridHolder(
|
|||
}
|
||||
|
||||
setUnreadBadge(binding.unreadDownloadBadge.badgeView, item)
|
||||
setCards(adapter.showOutline, binding.card, binding.unreadDownloadBadge.badgeView)
|
||||
setReadingButton(item)
|
||||
setSelected(adapter.isSelected(flexibleAdapterPosition))
|
||||
|
||||
|
|
|
@ -3,10 +3,12 @@ package eu.kanade.tachiyomi.ui.library
|
|||
import android.view.View
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.view.isVisible
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.view.setCards
|
||||
|
||||
/**
|
||||
* Generic class used to hold the displayed data of a manga in the library.
|
||||
|
@ -22,6 +24,14 @@ abstract class LibraryHolder(
|
|||
|
||||
protected val color = ColorUtils.setAlphaComponent(itemView.context.getResourceColor(R.attr.colorSecondary), 75)
|
||||
|
||||
init {
|
||||
val card = itemView.findViewById<MaterialCardView>(R.id.card)
|
||||
val badgeView = itemView.findViewById<LibraryBadge>(R.id.badge_view)
|
||||
if (card != null && badgeView != null) {
|
||||
setCards(adapter.showOutline, card, badgeView)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method called from [LibraryCategoryAdapter.onBindViewHolder]. It updates the data for this
|
||||
* holder with the given manga.
|
||||
|
|
|
@ -10,7 +10,6 @@ import eu.kanade.tachiyomi.data.image.coil.loadManga
|
|||
import eu.kanade.tachiyomi.databinding.MangaListItemBinding
|
||||
import eu.kanade.tachiyomi.util.lang.highlightText
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.view.setCards
|
||||
|
||||
/**
|
||||
* Class used to hold the displayed data of a manga in the library, like the cover or the binding.title.
|
||||
|
@ -68,7 +67,6 @@ class LibraryListHolder(
|
|||
// Update the binding.title of the manga.
|
||||
binding.title.text = item.manga.title.highlightText(item.filter, color)
|
||||
setUnreadBadge(binding.unreadDownloadBadge.badgeView, item)
|
||||
setCards(adapter.showOutline, binding.card, binding.unreadDownloadBadge.badgeView)
|
||||
|
||||
val authorArtist =
|
||||
if (item.manga.author == item.manga.artist || item.manga.artist.isNullOrBlank()) {
|
||||
|
|
|
@ -3,7 +3,7 @@ package eu.kanade.tachiyomi.ui.migration
|
|||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.items.IFlexible
|
||||
|
||||
class MangaAdapter(listener: Any) :
|
||||
class MangaAdapter(listener: Any, val showOutline: Boolean) :
|
||||
FlexibleAdapter<IFlexible<*>>(null, listener) {
|
||||
|
||||
private var items: List<IFlexible<*>>? = null
|
||||
|
|
|
@ -8,13 +8,20 @@ import eu.davidea.flexibleadapter.items.IFlexible
|
|||
import eu.kanade.tachiyomi.data.image.coil.loadManga
|
||||
import eu.kanade.tachiyomi.databinding.MangaListItemBinding
|
||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.util.view.setCards
|
||||
|
||||
class MangaHolder(
|
||||
view: View,
|
||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>
|
||||
adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
||||
showOutline: Boolean
|
||||
) : BaseFlexibleViewHolder(view, adapter) {
|
||||
|
||||
private val binding = MangaListItemBinding.bind(view)
|
||||
|
||||
init {
|
||||
setCards(showOutline, binding.card, null)
|
||||
}
|
||||
|
||||
fun bind(item: MangaItem) {
|
||||
// Update the title of the manga.
|
||||
binding.title.text = item.manga.title
|
||||
|
|
|
@ -15,7 +15,7 @@ class MangaItem(val manga: Manga) : AbstractFlexibleItem<MangaHolder>() {
|
|||
}
|
||||
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): MangaHolder {
|
||||
return MangaHolder(view, adapter)
|
||||
return MangaHolder(view, adapter, (adapter as? MangaAdapter)?.showOutline ?: true)
|
||||
}
|
||||
|
||||
override fun bindViewHolder(
|
||||
|
|
|
@ -79,7 +79,7 @@ class MigrationController :
|
|||
} else {
|
||||
title = state.selectedSource.toString()
|
||||
if (adapter !is MangaAdapter) {
|
||||
adapter = MangaAdapter(this)
|
||||
adapter = MangaAdapter(this, presenter.preferences.outlineOnCovers().get())
|
||||
binding.migrationRecycler.adapter = adapter
|
||||
}
|
||||
adapter?.updateDataSet(state.mangaForSource, true)
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Date
|
|||
class MigrationPresenter(
|
||||
private val sourceManager: SourceManager = Injekt.get(),
|
||||
private val db: DatabaseHelper = Injekt.get(),
|
||||
private val preferences: PreferencesHelper = Injekt.get()
|
||||
val preferences: PreferencesHelper = Injekt.get()
|
||||
) : BasePresenter<MigrationController>() {
|
||||
|
||||
var state = ViewState()
|
||||
|
|
|
@ -23,6 +23,7 @@ class MigrationProcessAdapter(
|
|||
var items: List<MigrationProcessItem> = emptyList()
|
||||
val preferences: PreferencesHelper by injectLazy()
|
||||
|
||||
var showOutline = preferences.outlineOnCovers().get()
|
||||
val menuItemListener: MigrationProcessInterface = controller
|
||||
|
||||
override fun updateDataSet(items: List<MigrationProcessItem>?) {
|
||||
|
|
|
@ -18,6 +18,7 @@ import eu.kanade.tachiyomi.source.SourceManager
|
|||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
|
||||
import eu.kanade.tachiyomi.util.system.launchUI
|
||||
import eu.kanade.tachiyomi.util.view.setCards
|
||||
import eu.kanade.tachiyomi.util.view.setVectorCompat
|
||||
import eu.kanade.tachiyomi.util.view.withFadeTransaction
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -41,6 +42,9 @@ class MigrationProcessHolder(
|
|||
// PopupMenu is shown.
|
||||
binding.migrationMenu.setOnClickListener { it.post { showPopupMenu(it) } }
|
||||
binding.skipManga.setOnClickListener { it.post { adapter.removeManga(flexibleAdapterPosition) } }
|
||||
arrayOf(binding.migrationMangaCardFrom, binding.migrationMangaCardTo).forEach {
|
||||
setCards(adapter.showOutline, it.card, it.unreadDownloadBadge.badgeView)
|
||||
}
|
||||
}
|
||||
|
||||
fun bind(item: MigrationProcessItem) {
|
||||
|
|
|
@ -48,15 +48,22 @@ class RecentMangaAdapter(val delegate: RecentsInterface) :
|
|||
preferences.showTitleFirstInRecents().register { showTitleFirst = it }
|
||||
preferences.showUpdatedTime().register { showUpdatedTime = it }
|
||||
preferences.uniformGrid().register { uniformCovers = it }
|
||||
preferences.outlineOnCovers().register { showOutline = it }
|
||||
preferences.outlineOnCovers().register(false) {
|
||||
showOutline = it
|
||||
(0 until itemCount).forEach { i ->
|
||||
(recyclerView.findViewHolderForAdapterPosition(i) as? RecentMangaHolder)?.updateCards()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun <T> Preference<T>.register(onChanged: (T) -> Unit) {
|
||||
private fun <T> Preference<T>.register(notify: Boolean = true, onChanged: (T) -> Unit) {
|
||||
asFlow()
|
||||
.drop(1)
|
||||
.onEach {
|
||||
onChanged(it)
|
||||
notifyDataSetChanged()
|
||||
if (notify) {
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
.launchIn(delegate.scope())
|
||||
}
|
||||
|
|
|
@ -28,6 +28,11 @@ class RecentMangaHolder(
|
|||
init {
|
||||
binding.cardLayout.setOnClickListener { adapter.delegate.onCoverClick(flexibleAdapterPosition) }
|
||||
binding.removeHistory.setOnClickListener { adapter.delegate.onRemoveHistoryClicked(flexibleAdapterPosition) }
|
||||
updateCards()
|
||||
}
|
||||
|
||||
fun updateCards() {
|
||||
setCards(adapter.showOutline, binding.card, null)
|
||||
}
|
||||
|
||||
fun bind(item: RecentMangaItem) {
|
||||
|
@ -83,7 +88,6 @@ class RecentMangaHolder(
|
|||
}
|
||||
}
|
||||
}
|
||||
setCards(adapter.showOutline, binding.card, null)
|
||||
|
||||
binding.removeHistory.isVisible = item.mch.history.id != null && showRemoveHistory
|
||||
val chapterName = if (item.mch.manga.hideChapterTitle(adapter.preferences)) {
|
||||
|
|
|
@ -2,6 +2,8 @@ package eu.kanade.tachiyomi.ui.source.globalsearch
|
|||
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
/**
|
||||
* Adapter that holds the manga items from search results.
|
||||
|
@ -15,6 +17,8 @@ class GlobalSearchCardAdapter(controller: GlobalSearchController) :
|
|||
* Listen for browse item clicks.
|
||||
*/
|
||||
val mangaClickListener: OnMangaClickListener = controller
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
val showOutlines = preferences.outlineOnCovers().get()
|
||||
|
||||
/**
|
||||
* Listener which should be called when user clicks browse.
|
||||
|
|
|
@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.data.image.coil.CoverViewTarget
|
|||
import eu.kanade.tachiyomi.databinding.SourceGlobalSearchControllerCardItemBinding
|
||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.util.view.makeShapeCorners
|
||||
import eu.kanade.tachiyomi.util.view.setCards
|
||||
|
||||
class GlobalSearchMangaHolder(view: View, adapter: GlobalSearchCardAdapter) :
|
||||
BaseFlexibleViewHolder(view, adapter) {
|
||||
|
@ -30,6 +31,7 @@ class GlobalSearchMangaHolder(view: View, adapter: GlobalSearchCardAdapter) :
|
|||
adapter.mangaClickListener.onMangaLongClick(flexibleAdapterPosition, adapter)
|
||||
true
|
||||
}
|
||||
setCards(adapter.showOutlines, binding.card, binding.favoriteButton)
|
||||
}
|
||||
|
||||
fun bind(manga: Manga) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue