mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-11 12:29:10 +01:00
Binding Holders
I'm in absolute pain
This commit is contained in:
parent
ea3ea165aa
commit
89f4ad393b
@ -4,11 +4,11 @@ import android.view.View
|
|||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
|
import eu.kanade.tachiyomi.databinding.DownloadItemBinding
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.view.setVectorCompat
|
import eu.kanade.tachiyomi.util.view.setVectorCompat
|
||||||
import eu.kanade.tachiyomi.util.view.visibleIf
|
import eu.kanade.tachiyomi.util.view.visibleIf
|
||||||
import kotlinx.android.synthetic.main.download_item.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class used to hold the data of a download.
|
* Class used to hold the data of a download.
|
||||||
@ -20,9 +20,10 @@ import kotlinx.android.synthetic.main.download_item.*
|
|||||||
class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
|
class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
|
||||||
BaseFlexibleViewHolder(view, adapter) {
|
BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
|
private val binding = DownloadItemBinding.bind(view)
|
||||||
init {
|
init {
|
||||||
setDragHandleView(reorder)
|
setDragHandleView(binding.reorder)
|
||||||
migration_menu.setOnClickListener { it.post { showPopupMenu(it) } }
|
binding.downloadMenu.setOnClickListener { it.post { showPopupMenu(it) } }
|
||||||
}
|
}
|
||||||
|
|
||||||
private lateinit var download: Download
|
private lateinit var download: Download
|
||||||
@ -30,30 +31,30 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
|
|||||||
/**
|
/**
|
||||||
* Binds this holder with the given category.
|
* Binds this holder with the given category.
|
||||||
*
|
*
|
||||||
* @param category The category to bind.
|
* @param download The download to bind.
|
||||||
*/
|
*/
|
||||||
fun bind(download: Download) {
|
fun bind(download: Download) {
|
||||||
this.download = download
|
this.download = download
|
||||||
// Update the chapter name.
|
// Update the chapter name.
|
||||||
chapter_title.text = download.chapter.name
|
binding.chapterTitle.text = download.chapter.name
|
||||||
|
|
||||||
// Update the manga title
|
// Update the manga title
|
||||||
title.text = download.manga.title
|
binding.title.text = download.manga.title
|
||||||
|
|
||||||
// Update the progress bar and the number of downloaded pages
|
// Update the progress bar and the number of downloaded pages
|
||||||
val pages = download.pages
|
val pages = download.pages
|
||||||
if (pages == null) {
|
if (pages == null) {
|
||||||
download_progress.progress = 0
|
binding.downloadProgress.progress = 0
|
||||||
download_progress.max = 1
|
binding.downloadProgress.max = 1
|
||||||
download_progress_text.text = ""
|
binding.downloadProgressText.text = ""
|
||||||
} else {
|
} else {
|
||||||
download_progress.max = pages.size * 100
|
binding.downloadProgress.max = pages.size * 100
|
||||||
notifyProgress()
|
notifyProgress()
|
||||||
notifyDownloadedPages()
|
notifyDownloadedPages()
|
||||||
}
|
}
|
||||||
|
|
||||||
migration_menu.visibleIf(flexibleAdapterPosition != 0 || flexibleAdapterPosition != adapter.itemCount - 1)
|
binding.downloadMenu.visibleIf(flexibleAdapterPosition != 0 || flexibleAdapterPosition != adapter.itemCount - 1)
|
||||||
migration_menu.setVectorCompat(
|
binding.downloadMenu.setVectorCompat(
|
||||||
R.drawable.ic_more_vert_24dp,
|
R.drawable.ic_more_vert_24dp,
|
||||||
view.context
|
view.context
|
||||||
.getResourceColor(android.R.attr.textColorPrimary)
|
.getResourceColor(android.R.attr.textColorPrimary)
|
||||||
@ -65,10 +66,10 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
|
|||||||
*/
|
*/
|
||||||
fun notifyProgress() {
|
fun notifyProgress() {
|
||||||
val pages = download.pages ?: return
|
val pages = download.pages ?: return
|
||||||
if (download_progress.max == 1) {
|
if (binding.downloadProgress.max == 1) {
|
||||||
download_progress.max = pages.size * 100
|
binding.downloadProgress.max = pages.size * 100
|
||||||
}
|
}
|
||||||
download_progress.progress = download.pageProgress
|
binding.downloadProgress.progress = download.pageProgress
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,7 +77,7 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
|
|||||||
*/
|
*/
|
||||||
fun notifyDownloadedPages() {
|
fun notifyDownloadedPages() {
|
||||||
val pages = download.pages ?: return
|
val pages = download.pages ?: return
|
||||||
download_progress_text.text = "${download.downloadedImages}/${pages.size}"
|
binding.downloadProgressText.text = "${download.downloadedImages}/${pages.size}"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemReleased(position: Int) {
|
override fun onItemReleased(position: Int) {
|
||||||
@ -93,8 +94,6 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
|
|||||||
// Inflate our menu resource into the PopupMenu's Menu
|
// Inflate our menu resource into the PopupMenu's Menu
|
||||||
popup.menuInflater.inflate(R.menu.download_single, popup.menu)
|
popup.menuInflater.inflate(R.menu.download_single, popup.menu)
|
||||||
|
|
||||||
val download = item.download
|
|
||||||
|
|
||||||
popup.menu.findItem(R.id.move_to_top).isVisible = flexibleAdapterPosition != 0
|
popup.menu.findItem(R.id.move_to_top).isVisible = flexibleAdapterPosition != 0
|
||||||
popup.menu.findItem(R.id.move_to_bottom).isVisible = flexibleAdapterPosition != adapter
|
popup.menu.findItem(R.id.move_to_bottom).isVisible = flexibleAdapterPosition != adapter
|
||||||
.itemCount - 1
|
.itemCount - 1
|
||||||
@ -110,14 +109,14 @@ class DownloadHolder(private val view: View, val adapter: DownloadAdapter) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getFrontView(): View {
|
override fun getFrontView(): View {
|
||||||
return front_view
|
return binding.frontView
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getRearRightView(): View {
|
override fun getRearRightView(): View {
|
||||||
return right_view
|
return binding.rightView
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getRearLeftView(): View {
|
override fun getRearLeftView(): View {
|
||||||
return left_view
|
return binding.leftView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@ import android.view.ViewGroup
|
|||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.databinding.ExtensionDetailHeaderBinding
|
||||||
import eu.kanade.tachiyomi.ui.extension.getApplicationIcon
|
import eu.kanade.tachiyomi.ui.extension.getApplicationIcon
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
import eu.kanade.tachiyomi.util.view.inflate
|
import eu.kanade.tachiyomi.util.view.inflate
|
||||||
import kotlinx.android.synthetic.main.extension_detail_header.view.*
|
|
||||||
|
|
||||||
class ExtensionDetailsHeaderAdapter(private val presenter: ExtensionDetailsPresenter) :
|
class ExtensionDetailsHeaderAdapter(private val presenter: ExtensionDetailsPresenter) :
|
||||||
RecyclerView.Adapter<ExtensionDetailsHeaderAdapter.HeaderViewHolder>() {
|
RecyclerView.Adapter<ExtensionDetailsHeaderAdapter.HeaderViewHolder>() {
|
||||||
@ -34,28 +34,29 @@ class ExtensionDetailsHeaderAdapter(private val presenter: ExtensionDetailsPrese
|
|||||||
|
|
||||||
inner class HeaderViewHolder(private val view: View) : RecyclerView.ViewHolder(view) {
|
inner class HeaderViewHolder(private val view: View) : RecyclerView.ViewHolder(view) {
|
||||||
fun bind() {
|
fun bind() {
|
||||||
|
val binding = ExtensionDetailHeaderBinding.bind(view)
|
||||||
val extension = presenter.extension ?: return
|
val extension = presenter.extension ?: return
|
||||||
val context = view.context
|
val context = view.context
|
||||||
|
|
||||||
extension.getApplicationIcon(context)?.let { view.extension_icon.setImageDrawable(it) }
|
extension.getApplicationIcon(context)?.let { binding.extensionIcon.setImageDrawable(it) }
|
||||||
view.extension_title.text = extension.name
|
binding.extensionTitle.text = extension.name
|
||||||
view.extension_version.text = context.getString(R.string.version_, extension.versionName)
|
binding.extensionVersion.text = context.getString(R.string.version_, extension.versionName)
|
||||||
view.extension_lang.text = context.getString(R.string.language_, LocaleHelper.getSourceDisplayName(extension.lang, context))
|
binding.extensionLang.text = context.getString(R.string.language_, LocaleHelper.getSourceDisplayName(extension.lang, context))
|
||||||
view.extension_nsfw.isVisible = extension.isNsfw
|
binding.extensionNsfw.isVisible = extension.isNsfw
|
||||||
view.extension_pkg.text = extension.pkgName
|
binding.extensionPkg.text = extension.pkgName
|
||||||
|
|
||||||
view.extension_uninstall_button.setOnClickListener {
|
binding.extensionUninstallButton.setOnClickListener {
|
||||||
presenter.uninstallExtension()
|
presenter.uninstallExtension()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extension.isObsolete) {
|
if (extension.isObsolete) {
|
||||||
view.extension_warning_banner.isVisible = true
|
binding.extensionWarningBanner.isVisible = true
|
||||||
view.extension_warning_banner.setText(R.string.obsolete_extension_message)
|
binding.extensionWarningBanner.setText(R.string.obsolete_extension_message)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extension.isUnofficial) {
|
if (extension.isUnofficial) {
|
||||||
view.extension_warning_banner.isVisible = true
|
binding.extensionWarningBanner.isVisible = true
|
||||||
view.extension_warning_banner.setText(R.string.unofficial_extension_message)
|
binding.extensionWarningBanner.setText(R.string.unofficial_extension_message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,11 @@ import coil.api.clear
|
|||||||
import coil.api.load
|
import coil.api.load
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
||||||
|
import eu.kanade.tachiyomi.databinding.TrackSearchItemBinding
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
import eu.kanade.tachiyomi.util.view.inflate
|
import eu.kanade.tachiyomi.util.view.inflate
|
||||||
import kotlinx.android.synthetic.main.track_search_item.view.*
|
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
class TrackSearchAdapter(context: Context) :
|
class TrackSearchAdapter(context: Context) :
|
||||||
ArrayAdapter<TrackSearch>(context, R.layout.track_search_item, ArrayList<TrackSearch>()) {
|
ArrayAdapter<TrackSearch>(context, R.layout.track_search_item, ArrayList<TrackSearch>()) {
|
||||||
@ -43,32 +44,33 @@ class TrackSearchAdapter(context: Context) :
|
|||||||
class TrackSearchHolder(private val view: View) {
|
class TrackSearchHolder(private val view: View) {
|
||||||
|
|
||||||
fun onSetValues(track: TrackSearch) {
|
fun onSetValues(track: TrackSearch) {
|
||||||
view.track_search_title.text = track.title
|
val binding = TrackSearchItemBinding.bind(view)
|
||||||
view.track_search_summary.text = track.summary
|
binding.trackSearchTitle.text = track.title
|
||||||
view.track_search_cover.clear()
|
binding.trackSearchSummary.text = track.summary
|
||||||
if (!track.cover_url.isNullOrEmpty()) {
|
binding.trackSearchCover.clear()
|
||||||
view.track_search_cover.load(track.cover_url)
|
if (track.cover_url.isNotEmpty()) {
|
||||||
|
binding.trackSearchCover.load(track.cover_url)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (track.publishing_status.isNullOrBlank()) {
|
if (track.publishing_status.isBlank()) {
|
||||||
view.track_search_status.gone()
|
binding.trackSearchStatus.gone()
|
||||||
view.track_search_status_result.gone()
|
binding.trackSearchStatusResult.gone()
|
||||||
} else {
|
} else {
|
||||||
view.track_search_status_result.text = track.publishing_status.capitalize()
|
binding.trackSearchStatusResult.text = track.publishing_status.capitalize(Locale.ROOT)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (track.publishing_type.isNullOrBlank()) {
|
if (track.publishing_type.isBlank()) {
|
||||||
view.track_search_type.gone()
|
binding.trackSearchType.gone()
|
||||||
view.track_search_type_result.gone()
|
binding.trackSearchTypeResult.gone()
|
||||||
} else {
|
} else {
|
||||||
view.track_search_type_result.text = track.publishing_type.capitalize()
|
binding.trackSearchTypeResult.text = track.publishing_type.capitalize(Locale.ROOT)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (track.start_date.isNullOrBlank()) {
|
if (track.start_date.isBlank()) {
|
||||||
view.track_search_start.gone()
|
binding.trackSearchStart.gone()
|
||||||
view.track_search_start_result.gone()
|
binding.trackSearchStartResult.gone()
|
||||||
} else {
|
} else {
|
||||||
view.track_search_start_result.text = track.start_date
|
binding.trackSearchStartResult.text = track.start_date
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
|
|||||||
import eu.davidea.flexibleadapter.items.AbstractHeaderItem
|
import eu.davidea.flexibleadapter.items.AbstractHeaderItem
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.databinding.SourceHeaderItemBinding
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import kotlinx.android.synthetic.main.source_header_item.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Item that contains the selection header.
|
* Item that contains the selection header.
|
||||||
@ -25,7 +25,7 @@ class SelectionHeader : AbstractHeaderItem<SelectionHeader.Holder>() {
|
|||||||
* Creates a new view holder for this item.
|
* Creates a new view holder for this item.
|
||||||
*/
|
*/
|
||||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): Holder {
|
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): Holder {
|
||||||
return SelectionHeader.Holder(view, adapter)
|
return Holder(view, adapter)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,7 +42,8 @@ class SelectionHeader : AbstractHeaderItem<SelectionHeader.Holder>() {
|
|||||||
|
|
||||||
class Holder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>) : BaseFlexibleViewHolder(view, adapter) {
|
class Holder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>) : BaseFlexibleViewHolder(view, adapter) {
|
||||||
init {
|
init {
|
||||||
title.text = view.context.getString(R.string.select_a_source_then_item_to_migrate)
|
val binding = SourceHeaderItemBinding.bind(view)
|
||||||
|
binding.title.text = view.context.getString(R.string.select_a_source_then_item_to_migrate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,11 +7,10 @@ import coil.api.clear
|
|||||||
import coil.transform.CircleCropTransformation
|
import coil.transform.CircleCropTransformation
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.image.coil.loadLibraryManga
|
import eu.kanade.tachiyomi.data.image.coil.loadLibraryManga
|
||||||
|
import eu.kanade.tachiyomi.databinding.RecentChaptersItemBinding
|
||||||
import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterHolder
|
import eu.kanade.tachiyomi.ui.manga.chapter.BaseChapterHolder
|
||||||
import eu.kanade.tachiyomi.util.chapter.ChapterUtil
|
import eu.kanade.tachiyomi.util.chapter.ChapterUtil
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import kotlinx.android.synthetic.main.download_button.*
|
|
||||||
import kotlinx.android.synthetic.main.recent_chapters_item.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holder that contains chapter item
|
* Holder that contains chapter item
|
||||||
@ -41,8 +40,9 @@ class RecentChapterHolder(private val view: View, private val adapter: RecentCha
|
|||||||
*/
|
*/
|
||||||
private var item: RecentChapterItem? = null
|
private var item: RecentChapterItem? = null
|
||||||
|
|
||||||
|
private val binding = RecentChaptersItemBinding.bind(view)
|
||||||
init {
|
init {
|
||||||
manga_cover.setOnClickListener {
|
binding.mangaCover.setOnClickListener {
|
||||||
adapter.coverClickListener.onCoverClick(flexibleAdapterPosition)
|
adapter.coverClickListener.onCoverClick(flexibleAdapterPosition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,16 +55,16 @@ class RecentChapterHolder(private val view: View, private val adapter: RecentCha
|
|||||||
fun bind(item: RecentChapterItem) {
|
fun bind(item: RecentChapterItem) {
|
||||||
this.item = item
|
this.item = item
|
||||||
|
|
||||||
// Set chapter title
|
// Set chapter binding.title
|
||||||
chapter_title.text = item.chapter.name
|
binding.chapterTitle.text = item.chapter.name
|
||||||
|
|
||||||
// Set manga title
|
// Set manga binding.title
|
||||||
title.text = item.manga.title
|
binding.title.text = item.manga.title
|
||||||
|
|
||||||
if (front_view.translationX == 0f) {
|
if (binding.frontView.translationX == 0f) {
|
||||||
read.setImageDrawable(
|
binding.read.setImageDrawable(
|
||||||
ContextCompat.getDrawable(
|
ContextCompat.getDrawable(
|
||||||
read.context,
|
binding.root.context,
|
||||||
if (item.read) R.drawable.ic_eye_off_24dp
|
if (item.read) R.drawable.ic_eye_off_24dp
|
||||||
else R.drawable.ic_eye_24dp
|
else R.drawable.ic_eye_24dp
|
||||||
)
|
)
|
||||||
@ -73,15 +73,15 @@ class RecentChapterHolder(private val view: View, private val adapter: RecentCha
|
|||||||
|
|
||||||
// Set cover
|
// Set cover
|
||||||
if ((view.context as? Activity)?.isDestroyed != true) {
|
if ((view.context as? Activity)?.isDestroyed != true) {
|
||||||
manga_cover.clear()
|
binding.mangaCover.clear()
|
||||||
manga_cover.loadLibraryManga(item.manga) {
|
binding.mangaCover.loadLibraryManga(item.manga) {
|
||||||
transformations(CircleCropTransformation())
|
transformations(CircleCropTransformation())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val chapterColor = ChapterUtil.chapterColor(itemView.context, item)
|
val chapterColor = ChapterUtil.chapterColor(itemView.context, item)
|
||||||
chapter_title.setTextColor(chapterColor)
|
binding.chapterTitle.setTextColor(chapterColor)
|
||||||
title.setTextColor(chapterColor)
|
binding.title.setTextColor(chapterColor)
|
||||||
|
|
||||||
// Set chapter status
|
// Set chapter status
|
||||||
notifyStatus(item.status, item.progress)
|
notifyStatus(item.status, item.progress)
|
||||||
@ -89,15 +89,15 @@ class RecentChapterHolder(private val view: View, private val adapter: RecentCha
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun resetFrontView() {
|
private fun resetFrontView() {
|
||||||
if (front_view.translationX != 0f) itemView.post { adapter.notifyItemChanged(flexibleAdapterPosition) }
|
if (binding.frontView.translationX != 0f) itemView.post { adapter.notifyItemChanged(flexibleAdapterPosition) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getFrontView(): View {
|
override fun getFrontView(): View {
|
||||||
return front_view
|
return binding.frontView
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getRearRightView(): View {
|
override fun getRearRightView(): View {
|
||||||
return right_view
|
return binding.rightView
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,5 +106,5 @@ class RecentChapterHolder(private val view: View, private val adapter: RecentCha
|
|||||||
* @param status download status
|
* @param status download status
|
||||||
*/
|
*/
|
||||||
fun notifyStatus(status: Int, progress: Int) =
|
fun notifyStatus(status: Int, progress: Int) =
|
||||||
download_button.setDownloadStatus(status, progress)
|
binding.downloadButton.root.setDownloadStatus(status, progress)
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@ import coil.api.clear
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory
|
import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory
|
||||||
import eu.kanade.tachiyomi.data.image.coil.loadLibraryManga
|
import eu.kanade.tachiyomi.data.image.coil.loadLibraryManga
|
||||||
|
import eu.kanade.tachiyomi.databinding.RecentlyReadItemBinding
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.lang.toTimestampString
|
import eu.kanade.tachiyomi.util.lang.toTimestampString
|
||||||
import kotlinx.android.synthetic.main.recently_read_item.*
|
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,16 +24,17 @@ class RecentlyReadHolder(
|
|||||||
val adapter: RecentlyReadAdapter
|
val adapter: RecentlyReadAdapter
|
||||||
) : BaseFlexibleViewHolder(view, adapter) {
|
) : BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
|
private val binding = RecentlyReadItemBinding.bind(view)
|
||||||
init {
|
init {
|
||||||
remove.setOnClickListener {
|
binding.remove.setOnClickListener {
|
||||||
adapter.removeClickListener.onRemoveClick(flexibleAdapterPosition)
|
adapter.removeClickListener.onRemoveClick(flexibleAdapterPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
resume.setOnClickListener {
|
binding.resume.setOnClickListener {
|
||||||
adapter.resumeClickListener.onResumeClick(flexibleAdapterPosition)
|
adapter.resumeClickListener.onResumeClick(flexibleAdapterPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
cover.setOnClickListener {
|
binding.cover.setOnClickListener {
|
||||||
adapter.coverClickListener.onCoverClick(flexibleAdapterPosition)
|
adapter.coverClickListener.onCoverClick(flexibleAdapterPosition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,18 +49,18 @@ class RecentlyReadHolder(
|
|||||||
val (manga, chapter, history) = item
|
val (manga, chapter, history) = item
|
||||||
|
|
||||||
// Set manga title
|
// Set manga title
|
||||||
title.text = manga.title
|
binding.title.text = manga.title
|
||||||
|
|
||||||
// Set source + chapter title
|
// Set source + chapter title
|
||||||
val formattedNumber = adapter.decimalFormat.format(chapter.chapter_number.toDouble())
|
val formattedNumber = adapter.decimalFormat.format(chapter.chapter_number.toDouble())
|
||||||
manga_source.text = itemView.context.getString(R.string.source_dash_chapter_)
|
binding.mangaSource.text = itemView.context.getString(R.string.source_dash_chapter_)
|
||||||
.format(adapter.sourceManager.getOrStub(manga.source).toString(), formattedNumber)
|
.format(adapter.sourceManager.getOrStub(manga.source).toString(), formattedNumber)
|
||||||
|
|
||||||
// Set last read timestamp title
|
// Set last read timestamp title
|
||||||
last_read.text = Date(history.last_read).toTimestampString(adapter.dateFormat)
|
binding.lastRead.text = Date(history.last_read).toTimestampString(adapter.dateFormat)
|
||||||
|
|
||||||
// Set cover
|
// Set binding.cover
|
||||||
cover.clear()
|
binding.cover.clear()
|
||||||
cover.loadLibraryManga(manga)
|
binding.cover.loadLibraryManga(manga)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,10 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
|
|||||||
import eu.davidea.flexibleadapter.items.AbstractHeaderItem
|
import eu.davidea.flexibleadapter.items.AbstractHeaderItem
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.databinding.RecentsHeaderItemBinding
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.ui.library.LibraryHeaderItem
|
import eu.kanade.tachiyomi.ui.library.LibraryHeaderItem
|
||||||
import eu.kanade.tachiyomi.util.view.visibleIf
|
import eu.kanade.tachiyomi.util.view.visibleIf
|
||||||
import kotlinx.android.synthetic.main.recents_header_item.*
|
|
||||||
|
|
||||||
class RecentMangaHeaderItem(val recentsType: Int) :
|
class RecentMangaHeaderItem(val recentsType: Int) :
|
||||||
AbstractHeaderItem<RecentMangaHeaderItem.Holder>() {
|
AbstractHeaderItem<RecentMangaHeaderItem.Holder>() {
|
||||||
@ -60,13 +60,14 @@ class RecentMangaHeaderItem(val recentsType: Int) :
|
|||||||
true
|
true
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
private val binding = RecentsHeaderItemBinding.bind(view)
|
||||||
init {
|
init {
|
||||||
action_history.setOnClickListener { adapter.delegate.showHistory() }
|
binding.actionHistory.setOnClickListener { adapter.delegate.showHistory() }
|
||||||
action_update.setOnClickListener { adapter.delegate.showUpdates() }
|
binding.actionUpdate.setOnClickListener { adapter.delegate.showUpdates() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bind(recentsType: Int) {
|
fun bind(recentsType: Int) {
|
||||||
title.setText(
|
binding.title.setText(
|
||||||
when (recentsType) {
|
when (recentsType) {
|
||||||
CONTINUE_READING -> R.string.continue_reading
|
CONTINUE_READING -> R.string.continue_reading
|
||||||
NEW_CHAPTERS -> R.string.new_chapters
|
NEW_CHAPTERS -> R.string.new_chapters
|
||||||
@ -74,9 +75,9 @@ class RecentMangaHeaderItem(val recentsType: Int) :
|
|||||||
else -> R.string.continue_reading
|
else -> R.string.continue_reading
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
action_history.visibleIf(recentsType == -1)
|
binding.actionHistory.visibleIf(recentsType == -1)
|
||||||
action_update.visibleIf(recentsType == -1)
|
binding.actionUpdate.visibleIf(recentsType == -1)
|
||||||
title.visibleIf(recentsType != -1)
|
binding.title.visibleIf(recentsType != -1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.core.graphics.ColorUtils
|
import androidx.core.graphics.ColorUtils
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder
|
import eu.davidea.viewholders.FlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.databinding.SettingsSearchControllerCardBinding
|
||||||
import eu.kanade.tachiyomi.util.lang.highlightText
|
import eu.kanade.tachiyomi.util.lang.highlightText
|
||||||
import kotlinx.android.synthetic.main.settings_search_controller_card.view.*
|
|
||||||
import kotlin.reflect.full.createInstance
|
import kotlin.reflect.full.createInstance
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,8 +18,9 @@ import kotlin.reflect.full.createInstance
|
|||||||
class SettingsSearchHolder(view: View, val adapter: SettingsSearchAdapter) :
|
class SettingsSearchHolder(view: View, val adapter: SettingsSearchAdapter) :
|
||||||
FlexibleViewHolder(view, adapter) {
|
FlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
|
private val binding = SettingsSearchControllerCardBinding.bind(view)
|
||||||
init {
|
init {
|
||||||
view.title_wrapper.setOnClickListener {
|
binding.titleWrapper.setOnClickListener {
|
||||||
adapter.getItem(bindingAdapterPosition)?.let {
|
adapter.getItem(bindingAdapterPosition)?.let {
|
||||||
val ctrl = it.settingsSearchResult.searchController::class.createInstance()
|
val ctrl = it.settingsSearchResult.searchController::class.createInstance()
|
||||||
ctrl.preferenceKey = it.settingsSearchResult.key
|
ctrl.preferenceKey = it.settingsSearchResult.key
|
||||||
@ -37,8 +38,8 @@ class SettingsSearchHolder(view: View, val adapter: SettingsSearchAdapter) :
|
|||||||
*/
|
*/
|
||||||
fun bind(item: SettingsSearchItem) {
|
fun bind(item: SettingsSearchItem) {
|
||||||
val color = ColorUtils.setAlphaComponent(ContextCompat.getColor(itemView.context, R.color.colorAccent), 75)
|
val color = ColorUtils.setAlphaComponent(ContextCompat.getColor(itemView.context, R.color.colorAccent), 75)
|
||||||
itemView.search_result_pref_title.text = item.settingsSearchResult.title.highlightText(item.searchResult, color)
|
binding.searchResultPrefTitle.text = item.settingsSearchResult.title.highlightText(item.searchResult, color)
|
||||||
itemView.search_result_pref_summary.text = item.settingsSearchResult.summary.highlightText(item.searchResult, color)
|
binding.searchResultPrefSummary.text = item.settingsSearchResult.summary.highlightText(item.searchResult, color)
|
||||||
itemView.search_result_pref_breadcrumb.text = item.settingsSearchResult.breadcrumb.highlightText(item.searchResult, color)
|
binding.searchResultPrefBreadcrumb.text = item.settingsSearchResult.breadcrumb.highlightText(item.searchResult, color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,15 @@ import android.view.View
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
|
import eu.kanade.tachiyomi.databinding.SourceHeaderItemBinding
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||||
import kotlinx.android.synthetic.main.source_header_item.*
|
|
||||||
|
|
||||||
class LangHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>) :
|
class LangHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>) :
|
||||||
BaseFlexibleViewHolder(view, adapter) {
|
BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
fun bind(item: LangItem) {
|
fun bind(item: LangItem) {
|
||||||
title.text = LocaleHelper.getSourceDisplayName(item.code, itemView.context)
|
val binding = SourceHeaderItemBinding.bind(itemView)
|
||||||
|
binding.title.text = LocaleHelper.getSourceDisplayName(item.code, itemView.context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
|||||||
import eu.kanade.tachiyomi.ui.library.LibraryCategoryAdapter
|
import eu.kanade.tachiyomi.ui.library.LibraryCategoryAdapter
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
import eu.kanade.tachiyomi.data.image.coil.CoverViewTarget
|
import eu.kanade.tachiyomi.data.image.coil.CoverViewTarget
|
||||||
import kotlinx.android.synthetic.main.manga_grid_item.*
|
import eu.kanade.tachiyomi.databinding.MangaGridItemBinding
|
||||||
import kotlinx.android.synthetic.main.unread_download_badge.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class used to hold the displayed data of a manga in the library, like the cover or the title.
|
* Class used to hold the displayed data of a manga in the library, like the cover or the title.
|
||||||
@ -30,12 +29,13 @@ class BrowseSourceGridHolder(
|
|||||||
compact: Boolean
|
compact: Boolean
|
||||||
) : BrowseSourceHolder(view, adapter) {
|
) : BrowseSourceHolder(view, adapter) {
|
||||||
|
|
||||||
|
private val binding = MangaGridItemBinding.bind(view)
|
||||||
init {
|
init {
|
||||||
if (compact) {
|
if (compact) {
|
||||||
text_layout.gone()
|
binding.textLayout.gone()
|
||||||
} else {
|
} else {
|
||||||
compact_title.gone()
|
binding.compactTitle.gone()
|
||||||
gradient.gone()
|
binding.gradient.gone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,9 +47,9 @@ class BrowseSourceGridHolder(
|
|||||||
*/
|
*/
|
||||||
override fun onSetValues(manga: Manga) {
|
override fun onSetValues(manga: Manga) {
|
||||||
// Update the title of the manga.
|
// Update the title of the manga.
|
||||||
title.text = manga.title
|
binding.title.text = manga.title
|
||||||
compact_title.text = title.text
|
binding.compactTitle.text = binding.title.text
|
||||||
badge_view.setInLibrary(manga.favorite)
|
binding.unreadDownloadBadge.root.setInLibrary(manga.favorite)
|
||||||
|
|
||||||
// Update the cover.
|
// Update the cover.
|
||||||
setImage(manga)
|
setImage(manga)
|
||||||
@ -58,11 +58,11 @@ class BrowseSourceGridHolder(
|
|||||||
override fun setImage(manga: Manga) {
|
override fun setImage(manga: Manga) {
|
||||||
if ((view.context as? Activity)?.isDestroyed == true) return
|
if ((view.context as? Activity)?.isDestroyed == true) return
|
||||||
if (manga.thumbnail_url == null) {
|
if (manga.thumbnail_url == null) {
|
||||||
cover_thumbnail.clear()
|
binding.coverThumbnail.clear()
|
||||||
} else {
|
} else {
|
||||||
val id = manga.id ?: return
|
val id = manga.id ?: return
|
||||||
val request = LoadRequest.Builder(view.context).data(manga)
|
val request = LoadRequest.Builder(view.context).data(manga)
|
||||||
.target(CoverViewTarget(cover_thumbnail, progress)).build()
|
.target(CoverViewTarget(binding.coverThumbnail, binding.progress)).build()
|
||||||
Coil.imageLoader(view.context).execute(request)
|
Coil.imageLoader(view.context).execute(request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,10 @@ import eu.davidea.flexibleadapter.items.IFlexible
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
|
import eu.kanade.tachiyomi.databinding.MangaGridItemBinding
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||||
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
import eu.kanade.tachiyomi.widget.AutofitRecyclerView
|
||||||
import kotlinx.android.synthetic.main.manga_grid_item.view.*
|
|
||||||
|
|
||||||
class BrowseSourceItem(
|
class BrowseSourceItem(
|
||||||
val manga: Manga,
|
val manga: Manga,
|
||||||
@ -40,32 +40,33 @@ class BrowseSourceItem(
|
|||||||
return if (parent is AutofitRecyclerView && !catalogueAsList.getOrDefault()) {
|
return if (parent is AutofitRecyclerView && !catalogueAsList.getOrDefault()) {
|
||||||
val listType = catalogueListType.getOrDefault()
|
val listType = catalogueListType.getOrDefault()
|
||||||
view.apply {
|
view.apply {
|
||||||
|
val binding = MangaGridItemBinding.bind(this)
|
||||||
val coverHeight = (parent.itemWidth / 3 * 4f).toInt()
|
val coverHeight = (parent.itemWidth / 3 * 4f).toInt()
|
||||||
if (listType == 1) {
|
if (listType == 1) {
|
||||||
gradient.layoutParams = FrameLayout.LayoutParams(
|
binding.gradient.layoutParams = FrameLayout.LayoutParams(
|
||||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||||
(coverHeight * 0.66f).toInt(),
|
(coverHeight * 0.66f).toInt(),
|
||||||
Gravity.BOTTOM
|
Gravity.BOTTOM
|
||||||
)
|
)
|
||||||
card.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
binding.card.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||||
bottomMargin = 6.dpToPx
|
bottomMargin = 6.dpToPx
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
constraint_layout.background = ContextCompat.getDrawable(
|
binding.constraintLayout.background = ContextCompat.getDrawable(
|
||||||
context,
|
context,
|
||||||
R.drawable.library_item_selector
|
R.drawable.library_item_selector
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
constraint_layout.layoutParams = FrameLayout.LayoutParams(
|
binding.constraintLayout.layoutParams = FrameLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
)
|
)
|
||||||
cover_thumbnail.maxHeight = Int.MAX_VALUE
|
binding.coverThumbnail.maxHeight = Int.MAX_VALUE
|
||||||
cover_thumbnail.minimumHeight = 0
|
binding.coverThumbnail.minimumHeight = 0
|
||||||
constraint_layout.minHeight = 0
|
binding.constraintLayout.minHeight = 0
|
||||||
cover_thumbnail.scaleType = ImageView.ScaleType.CENTER_CROP
|
binding.coverThumbnail.scaleType = ImageView.ScaleType.CENTER_CROP
|
||||||
cover_thumbnail.adjustViewBounds = false
|
binding.coverThumbnail.adjustViewBounds = false
|
||||||
cover_thumbnail.layoutParams = FrameLayout.LayoutParams(
|
binding.coverThumbnail.layoutParams = FrameLayout.LayoutParams(
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
(parent.itemWidth / 3f * 3.7f).toInt()
|
(parent.itemWidth / 3f * 3.7f).toInt()
|
||||||
)
|
)
|
||||||
|
@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.data.image.coil.CoverViewTarget
|
import eu.kanade.tachiyomi.data.image.coil.CoverViewTarget
|
||||||
import kotlinx.android.synthetic.main.manga_list_item.*
|
import eu.kanade.tachiyomi.databinding.MangaListItemBinding
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class used to hold the displayed data of a manga in the catalogue, like the cover or the title.
|
* Class used to hold the displayed data of a manga in the catalogue, like the cover or the title.
|
||||||
@ -24,6 +24,8 @@ import kotlinx.android.synthetic.main.manga_list_item.*
|
|||||||
class BrowseSourceListHolder(private val view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>) :
|
class BrowseSourceListHolder(private val view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>) :
|
||||||
BrowseSourceHolder(view, adapter) {
|
BrowseSourceHolder(view, adapter) {
|
||||||
|
|
||||||
|
private val binding = MangaListItemBinding.bind(view)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called from [CatalogueAdapter.onBindViewHolder]. It updates the data for this
|
* Method called from [CatalogueAdapter.onBindViewHolder]. It updates the data for this
|
||||||
* holder with the given manga.
|
* holder with the given manga.
|
||||||
@ -31,8 +33,8 @@ class BrowseSourceListHolder(private val view: View, adapter: FlexibleAdapter<IF
|
|||||||
* @param manga the manga to bind.
|
* @param manga the manga to bind.
|
||||||
*/
|
*/
|
||||||
override fun onSetValues(manga: Manga) {
|
override fun onSetValues(manga: Manga) {
|
||||||
title.text = manga.title
|
binding.title.text = manga.title
|
||||||
with(subtitle) {
|
with(binding.subtitle) {
|
||||||
visibility = if (manga.favorite) View.VISIBLE else View.GONE
|
visibility = if (manga.favorite) View.VISIBLE else View.GONE
|
||||||
text = view.resources.getString(R.string.in_library)
|
text = view.resources.getString(R.string.in_library)
|
||||||
setTextColor(view.context.getResourceColor(android.R.attr.colorAccent))
|
setTextColor(view.context.getResourceColor(android.R.attr.colorAccent))
|
||||||
@ -44,11 +46,11 @@ class BrowseSourceListHolder(private val view: View, adapter: FlexibleAdapter<IF
|
|||||||
override fun setImage(manga: Manga) {
|
override fun setImage(manga: Manga) {
|
||||||
// Update the cover.
|
// Update the cover.
|
||||||
if (manga.thumbnail_url == null) {
|
if (manga.thumbnail_url == null) {
|
||||||
cover_thumbnail.clear()
|
binding.coverThumbnail.clear()
|
||||||
} else {
|
} else {
|
||||||
val id = manga.id ?: return
|
manga.id ?: return
|
||||||
val request = LoadRequest.Builder(view.context).data(manga)
|
val request = LoadRequest.Builder(view.context).data(manga)
|
||||||
.target(CoverViewTarget(cover_thumbnail)).build()
|
.target(CoverViewTarget(binding.coverThumbnail)).build()
|
||||||
Coil.imageLoader(view.context).execute(request)
|
Coil.imageLoader(view.context).execute(request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@ package eu.kanade.tachiyomi.ui.source.global_search
|
|||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
|
import eu.kanade.tachiyomi.databinding.SourceGlobalSearchControllerCardBinding
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
import eu.kanade.tachiyomi.util.view.visible
|
import eu.kanade.tachiyomi.util.view.visible
|
||||||
import kotlinx.android.synthetic.main.source_global_search_controller_card.*
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holder that binds the [GlobalSearchItem] containing catalogue cards.
|
* Holder that binds the [GlobalSearchItem] containing catalogue cards.
|
||||||
@ -23,11 +23,13 @@ class GlobalSearchHolder(view: View, val adapter: GlobalSearchAdapter) :
|
|||||||
|
|
||||||
private var lastBoundResults: List<GlobalSearchMangaItem>? = null
|
private var lastBoundResults: List<GlobalSearchMangaItem>? = null
|
||||||
|
|
||||||
|
private val binding = SourceGlobalSearchControllerCardBinding.bind(view)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// Set layout horizontal.
|
// Set layout horizontal.
|
||||||
recycler.layoutManager =
|
binding.recycler.layoutManager =
|
||||||
androidx.recyclerview.widget.LinearLayoutManager(view.context, androidx.recyclerview.widget.LinearLayoutManager.HORIZONTAL, false)
|
androidx.recyclerview.widget.LinearLayoutManager(view.context, androidx.recyclerview.widget.LinearLayoutManager.HORIZONTAL, false)
|
||||||
recycler.adapter = mangaAdapter
|
binding.recycler.adapter = mangaAdapter
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,20 +45,20 @@ class GlobalSearchHolder(view: View, val adapter: GlobalSearchAdapter) :
|
|||||||
val langSuffix = if (source.lang.isNotEmpty()) " (${source.lang})" else ""
|
val langSuffix = if (source.lang.isNotEmpty()) " (${source.lang})" else ""
|
||||||
|
|
||||||
// Set Title with country code if available.
|
// Set Title with country code if available.
|
||||||
title.text = titlePrefix + source.name + langSuffix
|
binding.title.text = titlePrefix + source.name + langSuffix
|
||||||
|
|
||||||
when {
|
when {
|
||||||
results == null -> {
|
results == null -> {
|
||||||
progress.visible()
|
binding.progress.visible()
|
||||||
showHolder()
|
showHolder()
|
||||||
}
|
}
|
||||||
results.isEmpty() -> {
|
results.isEmpty() -> {
|
||||||
progress.gone()
|
binding.progress.gone()
|
||||||
no_results.visible()
|
binding.noResults.visible()
|
||||||
source_card.gone()
|
binding.sourceCard.gone()
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
progress.gone()
|
binding.progress.gone()
|
||||||
showHolder()
|
showHolder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,7 +95,7 @@ class GlobalSearchHolder(view: View, val adapter: GlobalSearchAdapter) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun showHolder() {
|
private fun showHolder() {
|
||||||
source_card.visible()
|
binding.sourceCard.visible()
|
||||||
no_results.gone()
|
binding.noResults.gone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,12 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
|||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.view.visibleIf
|
import eu.kanade.tachiyomi.util.view.visibleIf
|
||||||
import eu.kanade.tachiyomi.data.image.coil.CoverViewTarget
|
import eu.kanade.tachiyomi.data.image.coil.CoverViewTarget
|
||||||
import kotlinx.android.synthetic.main.source_global_search_controller_card_item.*
|
import eu.kanade.tachiyomi.databinding.SourceGlobalSearchControllerCardItemBinding
|
||||||
|
|
||||||
class GlobalSearchMangaHolder(view: View, adapter: GlobalSearchCardAdapter) :
|
class GlobalSearchMangaHolder(view: View, adapter: GlobalSearchCardAdapter) :
|
||||||
BaseFlexibleViewHolder(view, adapter) {
|
BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
|
private val binding = SourceGlobalSearchControllerCardItemBinding.bind(view)
|
||||||
init {
|
init {
|
||||||
// Call onMangaClickListener when item is pressed.
|
// Call onMangaClickListener when item is pressed.
|
||||||
itemView.setOnClickListener {
|
itemView.setOnClickListener {
|
||||||
@ -32,18 +33,18 @@ class GlobalSearchMangaHolder(view: View, adapter: GlobalSearchCardAdapter) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun bind(manga: Manga) {
|
fun bind(manga: Manga) {
|
||||||
title.text = manga.title
|
binding.title.text = manga.title
|
||||||
favorite_button.visibleIf(manga.favorite)
|
binding.favoriteButton.visibleIf(manga.favorite)
|
||||||
setImage(manga)
|
setImage(manga)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setImage(manga: Manga) {
|
fun setImage(manga: Manga) {
|
||||||
itemImage.clear()
|
binding.itemImage.clear()
|
||||||
if (!manga.thumbnail_url.isNullOrEmpty()) {
|
if (!manga.thumbnail_url.isNullOrEmpty()) {
|
||||||
val request = LoadRequest.Builder(itemView.context).data(manga)
|
val request = LoadRequest.Builder(itemView.context).data(manga)
|
||||||
.placeholder(android.R.color.transparent)
|
.placeholder(android.R.color.transparent)
|
||||||
.memoryCachePolicy(CachePolicy.DISABLED)
|
.memoryCachePolicy(CachePolicy.DISABLED)
|
||||||
.target(CoverViewTarget(itemImage, progress)).build()
|
.target(CoverViewTarget(binding.itemImage, binding.progress)).build()
|
||||||
Coil.imageLoader(itemView.context).execute(request)
|
Coil.imageLoader(itemView.context).execute(request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
android:id="@+id/close_right"
|
android:id="@+id/close_right"
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:tint="@color/md_white_1000"
|
app:tint="@color/md_white_1000"
|
||||||
android:layout_gravity="end|center"
|
android:layout_gravity="end|center"
|
||||||
android:contentDescription="@string/cancel"
|
android:contentDescription="@string/cancel"
|
||||||
android:layout_marginEnd="21dp"
|
android:layout_marginEnd="21dp"
|
||||||
@ -37,7 +37,7 @@
|
|||||||
android:contentDescription="@string/cancel"
|
android:contentDescription="@string/cancel"
|
||||||
android:layout_gravity="start|center"
|
android:layout_gravity="start|center"
|
||||||
android:layout_marginStart="21dp"
|
android:layout_marginStart="21dp"
|
||||||
android:tint="@color/md_white_1000"
|
app:tint="@color/md_white_1000"
|
||||||
android:src="@drawable/ic_close_24dp" />
|
android:src="@drawable/ic_close_24dp" />
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
@ -55,7 +55,7 @@
|
|||||||
android:layout_gravity="start"
|
android:layout_gravity="start"
|
||||||
android:contentDescription="@string/reorder"
|
android:contentDescription="@string/reorder"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
android:tint="?android:attr/textColorPrimary"
|
app:tint="?android:attr/textColorPrimary"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
@ -84,7 +84,7 @@
|
|||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textAppearance="@style/TextAppearance.Regular.Caption"
|
android:textAppearance="@style/TextAppearance.Regular.Caption"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/migration_menu"
|
app:layout_constraintEnd_toStartOf="@+id/download_menu"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
app:layout_constraintStart_toStartOf="@+id/title"
|
app:layout_constraintStart_toStartOf="@+id/title"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/title"
|
app:layout_constraintTop_toBottomOf="@+id/title"
|
||||||
@ -97,7 +97,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/migration_menu"
|
app:layout_constraintEnd_toStartOf="@+id/download_menu"
|
||||||
app:layout_constraintStart_toEndOf="@+id/reorder"
|
app:layout_constraintStart_toEndOf="@+id/reorder"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/chapter_title" />
|
app:layout_constraintTop_toBottomOf="@+id/chapter_title" />
|
||||||
@ -111,12 +111,12 @@
|
|||||||
android:textAppearance="@style/TextAppearance.Regular.Caption.Hint"
|
android:textAppearance="@style/TextAppearance.Regular.Caption.Hint"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/title"
|
app:layout_constraintBottom_toBottomOf="@+id/title"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/migration_menu"
|
app:layout_constraintEnd_toStartOf="@+id/download_menu"
|
||||||
app:layout_constraintTop_toTopOf="@+id/title"
|
app:layout_constraintTop_toTopOf="@+id/title"
|
||||||
tools:text="(0/10)" />
|
tools:text="(0/10)" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/migration_menu"
|
android:id="@+id/download_menu"
|
||||||
android:layout_width="44dp"
|
android:layout_width="44dp"
|
||||||
android:layout_height="@dimen/material_component_lists_single_line_with_avatar_height"
|
android:layout_height="@dimen/material_component_lists_single_line_with_avatar_height"
|
||||||
android:layout_toEndOf="@id/download_progress_text"
|
android:layout_toEndOf="@id/download_progress_text"
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
app:layout_constraintVertical_bias="1.0"
|
app:layout_constraintVertical_bias="1.0"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/imageView"
|
app:layout_constraintEnd_toStartOf="@id/imageView"
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
@ -26,9 +26,9 @@
|
|||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
android:layout_marginBottom="45dp"
|
android:layout_marginBottom="45dp"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/migration_manga_card_to"
|
app:layout_constraintEnd_toStartOf="@id/migration_manga_card_to"
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
app:layout_constraintStart_toEndOf="@+id/migration_manga_card_from"
|
app:layout_constraintStart_toEndOf="@id/migration_manga_card_from"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:srcCompat="@drawable/ic_chevron_right_24dp" />
|
app:srcCompat="@drawable/ic_chevron_right_24dp" />
|
||||||
|
|
||||||
@ -39,9 +39,9 @@
|
|||||||
android:layout_width="150dp"
|
android:layout_width="150dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/migration_menu"
|
app:layout_constraintEnd_toStartOf="@id/migration_menu"
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
app:layout_constraintStart_toEndOf="@+id/imageView"
|
app:layout_constraintStart_toEndOf="@id/imageView"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
@ -55,7 +55,7 @@
|
|||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
app:layout_constraintStart_toEndOf="@+id/migration_manga_card_to"
|
app:layout_constraintStart_toEndOf="@id/migration_manga_card_to"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:srcCompat="@drawable/ic_more_vert_24dp"
|
app:srcCompat="@drawable/ic_more_vert_24dp"
|
||||||
android:visibility="invisible"/>
|
android:visibility="invisible"/>
|
||||||
@ -65,9 +65,9 @@
|
|||||||
android:id="@+id/skip_manga"
|
android:id="@+id/skip_manga"
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/migration_menu"
|
app:layout_constraintBottom_toBottomOf="@id/migration_menu"
|
||||||
app:layout_constraintEnd_toEndOf="@+id/migration_menu"
|
app:layout_constraintEnd_toEndOf="@id/migration_menu"
|
||||||
app:layout_constraintStart_toStartOf="@+id/migration_menu"
|
app:layout_constraintStart_toStartOf="@id/migration_menu"
|
||||||
app:layout_constraintTop_toTopOf="@+id/migration_menu"
|
app:layout_constraintTop_toTopOf="@id/migration_menu"
|
||||||
app:srcCompat="@drawable/ic_close_24dp" />
|
app:srcCompat="@drawable/ic_close_24dp" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -51,9 +51,9 @@
|
|||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textAppearance="@style/TextAppearance.Regular.Body1"
|
android:textAppearance="@style/TextAppearance.Regular.Body1"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/chapter_title"
|
app:layout_constraintBottom_toTopOf="@id/chapter_title"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/download_button"
|
app:layout_constraintEnd_toStartOf="@id/download_button"
|
||||||
app:layout_constraintStart_toEndOf="@+id/manga_cover"
|
app:layout_constraintStart_toEndOf="@id/manga_cover"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintVertical_chainStyle="packed"
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
tools:text="Manga title" />
|
tools:text="Manga title" />
|
||||||
@ -68,13 +68,14 @@
|
|||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textAppearance="@style/TextAppearance.Regular.Caption"
|
android:textAppearance="@style/TextAppearance.Regular.Caption"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/download_button"
|
app:layout_constraintEnd_toStartOf="@id/download_button"
|
||||||
app:layout_constraintStart_toEndOf="@+id/manga_cover"
|
app:layout_constraintStart_toEndOf="@id/manga_cover"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/title"
|
app:layout_constraintTop_toBottomOf="@id/title"
|
||||||
tools:text="Chapter title" />
|
tools:text="Chapter title" />
|
||||||
|
|
||||||
<include
|
<include
|
||||||
layout="@layout/download_button"
|
layout="@layout/download_button"
|
||||||
|
android:id="@+id/download_button"
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user