mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-24 13:48:55 +03:00
Add view caching to view holders
This commit is contained in:
parent
d94dc68830
commit
8bcb14c65d
21 changed files with 183 additions and 171 deletions
|
@ -0,0 +1,15 @@
|
||||||
|
package eu.kanade.tachiyomi.ui.base.holder
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
|
import eu.davidea.viewholders.FlexibleViewHolder
|
||||||
|
import kotlinx.android.extensions.LayoutContainer
|
||||||
|
|
||||||
|
abstract class BaseFlexibleViewHolder(view: View,
|
||||||
|
adapter: FlexibleAdapter<*>,
|
||||||
|
stickyHeader: Boolean = false) :
|
||||||
|
FlexibleViewHolder(view, adapter, stickyHeader), LayoutContainer {
|
||||||
|
|
||||||
|
override val containerView: View?
|
||||||
|
get() = itemView
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package eu.kanade.tachiyomi.ui.base.holder
|
||||||
|
|
||||||
|
import android.support.v7.widget.RecyclerView
|
||||||
|
import android.view.View
|
||||||
|
import kotlinx.android.extensions.LayoutContainer
|
||||||
|
|
||||||
|
abstract class BaseViewHolder(view: View) : RecyclerView.ViewHolder(view), LayoutContainer {
|
||||||
|
|
||||||
|
override val containerView: View?
|
||||||
|
get() = itemView
|
||||||
|
}
|
|
@ -2,15 +2,16 @@ package eu.kanade.tachiyomi.ui.catalogue
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import kotlinx.android.synthetic.main.catalogue_main_controller_card.view.*
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
|
import kotlinx.android.synthetic.main.catalogue_main_controller_card.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class LangHolder(view: View, adapter: FlexibleAdapter<*>) : FlexibleViewHolder(view, adapter, true) {
|
class LangHolder(view: View, adapter: FlexibleAdapter<*>) :
|
||||||
|
BaseFlexibleViewHolder(view, adapter, true) {
|
||||||
|
|
||||||
fun bind(item: LangItem) {
|
fun bind(item: LangItem) {
|
||||||
itemView.title.text = when {
|
title.text = when {
|
||||||
item.code == "" -> itemView.context.getString(R.string.other_source)
|
item.code == "" -> itemView.context.getString(R.string.other_source)
|
||||||
else -> {
|
else -> {
|
||||||
val locale = Locale(item.code)
|
val locale = Locale(item.code)
|
||||||
|
|
|
@ -3,53 +3,51 @@ package eu.kanade.tachiyomi.ui.catalogue
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.source.online.LoginSource
|
import eu.kanade.tachiyomi.source.online.LoginSource
|
||||||
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.dpToPx
|
import eu.kanade.tachiyomi.util.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.getRound
|
import eu.kanade.tachiyomi.util.getRound
|
||||||
import eu.kanade.tachiyomi.util.gone
|
import eu.kanade.tachiyomi.util.gone
|
||||||
import eu.kanade.tachiyomi.util.visible
|
import eu.kanade.tachiyomi.util.visible
|
||||||
import io.github.mthli.slice.Slice
|
import io.github.mthli.slice.Slice
|
||||||
import kotlinx.android.synthetic.main.catalogue_main_controller_card_item.view.*
|
import kotlinx.android.synthetic.main.catalogue_main_controller_card_item.*
|
||||||
|
|
||||||
class SourceHolder(view: View, adapter: CatalogueAdapter) : FlexibleViewHolder(view, adapter) {
|
class SourceHolder(view: View, adapter: CatalogueAdapter) : BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
private val slice = Slice(itemView.card).apply {
|
private val slice = Slice(card).apply {
|
||||||
setColor(adapter.cardBackground)
|
setColor(adapter.cardBackground)
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
itemView.source_browse.setOnClickListener {
|
source_browse.setOnClickListener {
|
||||||
adapter.browseClickListener.onBrowseClick(adapterPosition)
|
adapter.browseClickListener.onBrowseClick(adapterPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
itemView.source_latest.setOnClickListener {
|
source_latest.setOnClickListener {
|
||||||
adapter.latestClickListener.onLatestClick(adapterPosition)
|
adapter.latestClickListener.onLatestClick(adapterPosition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bind(item: SourceItem) {
|
fun bind(item: SourceItem) {
|
||||||
val source = item.source
|
val source = item.source
|
||||||
with(itemView) {
|
setCardEdges(item)
|
||||||
setCardEdges(item)
|
|
||||||
|
|
||||||
// Set source name
|
// Set source name
|
||||||
title.text = source.name
|
title.text = source.name
|
||||||
|
|
||||||
// Set circle letter image.
|
// Set circle letter image.
|
||||||
post {
|
itemView.post {
|
||||||
image.setImageDrawable(image.getRound(source.name.take(1).toUpperCase(),false))
|
image.setImageDrawable(image.getRound(source.name.take(1).toUpperCase(),false))
|
||||||
}
|
}
|
||||||
|
|
||||||
// If source is login, show only login option
|
// If source is login, show only login option
|
||||||
if (source is LoginSource && !source.isLogged()) {
|
if (source is LoginSource && !source.isLogged()) {
|
||||||
source_browse.setText(R.string.login)
|
source_browse.setText(R.string.login)
|
||||||
source_latest.gone()
|
source_latest.gone()
|
||||||
} else {
|
} else {
|
||||||
source_browse.setText(R.string.browse)
|
source_browse.setText(R.string.browse)
|
||||||
source_latest.visible()
|
source_latest.visible()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +92,7 @@ class SourceHolder(view: View, adapter: CatalogueAdapter) : FlexibleViewHolder(v
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setMargins(left: Int, top: Int, right: Int, bottom: Int) {
|
private fun setMargins(left: Int, top: Int, right: Int, bottom: Int) {
|
||||||
val v = itemView.card
|
val v = card
|
||||||
if (v.layoutParams is ViewGroup.MarginLayoutParams) {
|
if (v.layoutParams is ViewGroup.MarginLayoutParams) {
|
||||||
val p = v.layoutParams as ViewGroup.MarginLayoutParams
|
val p = v.layoutParams as ViewGroup.MarginLayoutParams
|
||||||
p.setMargins(left, top, right, bottom)
|
p.setMargins(left, top, right, bottom)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.glide.GlideApp
|
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||||
import eu.kanade.tachiyomi.widget.StateImageViewTarget
|
import eu.kanade.tachiyomi.widget.StateImageViewTarget
|
||||||
import kotlinx.android.synthetic.main.catalogue_grid_item.view.*
|
import kotlinx.android.synthetic.main.catalogue_grid_item.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
@ -27,16 +27,16 @@ class CatalogueGridHolder(private val view: View, private val adapter: FlexibleA
|
||||||
*/
|
*/
|
||||||
override fun onSetValues(manga: Manga) {
|
override fun onSetValues(manga: Manga) {
|
||||||
// Set manga title
|
// Set manga title
|
||||||
view.title.text = manga.title
|
title.text = manga.title
|
||||||
|
|
||||||
// Set alpha of thumbnail.
|
// Set alpha of thumbnail.
|
||||||
view.thumbnail.alpha = if (manga.favorite) 0.3f else 1.0f
|
thumbnail.alpha = if (manga.favorite) 0.3f else 1.0f
|
||||||
|
|
||||||
setImage(manga)
|
setImage(manga)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setImage(manga: Manga) {
|
override fun setImage(manga: Manga) {
|
||||||
GlideApp.with(view.context).clear(view.thumbnail)
|
GlideApp.with(view.context).clear(thumbnail)
|
||||||
if (!manga.thumbnail_url.isNullOrEmpty()) {
|
if (!manga.thumbnail_url.isNullOrEmpty()) {
|
||||||
GlideApp.with(view.context)
|
GlideApp.with(view.context)
|
||||||
.load(manga)
|
.load(manga)
|
||||||
|
@ -44,7 +44,7 @@ class CatalogueGridHolder(private val view: View, private val adapter: FlexibleA
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.skipMemoryCache(true)
|
.skipMemoryCache(true)
|
||||||
.placeholder(android.R.color.transparent)
|
.placeholder(android.R.color.transparent)
|
||||||
.into(StateImageViewTarget(view.thumbnail, view.progress))
|
.into(StateImageViewTarget(thumbnail, progress))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,8 +2,8 @@ package eu.kanade.tachiyomi.ui.catalogue.browse
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic class used to hold the displayed data of a manga in the catalogue.
|
* Generic class used to hold the displayed data of a manga in the catalogue.
|
||||||
|
@ -12,7 +12,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
* @param adapter the adapter handling this holder.
|
* @param adapter the adapter handling this holder.
|
||||||
*/
|
*/
|
||||||
abstract class CatalogueHolder(view: View, adapter: FlexibleAdapter<*>) :
|
abstract class CatalogueHolder(view: View, adapter: FlexibleAdapter<*>) :
|
||||||
FlexibleViewHolder(view, adapter) {
|
BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called from [CatalogueAdapter.onBindViewHolder]. It updates the data for this
|
* Method called from [CatalogueAdapter.onBindViewHolder]. It updates the data for this
|
||||||
|
|
|
@ -6,7 +6,7 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.glide.GlideApp
|
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||||
import eu.kanade.tachiyomi.util.getResourceColor
|
import eu.kanade.tachiyomi.util.getResourceColor
|
||||||
import kotlinx.android.synthetic.main.catalogue_list_item.view.*
|
import kotlinx.android.synthetic.main.catalogue_list_item.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
@ -29,14 +29,14 @@ class CatalogueListHolder(private val view: View, adapter: FlexibleAdapter<*>) :
|
||||||
* @param manga the manga to bind.
|
* @param manga the manga to bind.
|
||||||
*/
|
*/
|
||||||
override fun onSetValues(manga: Manga) {
|
override fun onSetValues(manga: Manga) {
|
||||||
view.title.text = manga.title
|
title.text = manga.title
|
||||||
view.title.setTextColor(if (manga.favorite) favoriteColor else unfavoriteColor)
|
title.setTextColor(if (manga.favorite) favoriteColor else unfavoriteColor)
|
||||||
|
|
||||||
setImage(manga)
|
setImage(manga)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setImage(manga: Manga) {
|
override fun setImage(manga: Manga) {
|
||||||
GlideApp.with(view.context).clear(view.thumbnail)
|
GlideApp.with(view.context).clear(thumbnail)
|
||||||
if (!manga.thumbnail_url.isNullOrEmpty()) {
|
if (!manga.thumbnail_url.isNullOrEmpty()) {
|
||||||
GlideApp.with(view.context)
|
GlideApp.with(view.context)
|
||||||
.load(manga)
|
.load(manga)
|
||||||
|
@ -46,7 +46,7 @@ class CatalogueListHolder(private val view: View, adapter: FlexibleAdapter<*>) :
|
||||||
.dontAnimate()
|
.dontAnimate()
|
||||||
.skipMemoryCache(true)
|
.skipMemoryCache(true)
|
||||||
.placeholder(android.R.color.transparent)
|
.placeholder(android.R.color.transparent)
|
||||||
.into(view.thumbnail)
|
.into(thumbnail)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@ package eu.kanade.tachiyomi.ui.catalogue.global_search
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.glide.GlideApp
|
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||||
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.widget.StateImageViewTarget
|
import eu.kanade.tachiyomi.widget.StateImageViewTarget
|
||||||
import kotlinx.android.synthetic.main.catalogue_global_search_controller_card_item.view.*
|
import kotlinx.android.synthetic.main.catalogue_global_search_controller_card_item.*
|
||||||
|
|
||||||
class CatalogueSearchCardHolder(view: View, adapter: CatalogueSearchCardAdapter)
|
class CatalogueSearchCardHolder(view: View, adapter: CatalogueSearchCardAdapter)
|
||||||
: FlexibleViewHolder(view, adapter) {
|
: BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// Call onMangaClickListener when item is pressed.
|
// Call onMangaClickListener when item is pressed.
|
||||||
|
@ -22,13 +22,13 @@ class CatalogueSearchCardHolder(view: View, adapter: CatalogueSearchCardAdapter)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bind(manga: Manga) {
|
fun bind(manga: Manga) {
|
||||||
itemView.tvTitle.text = manga.title
|
tvTitle.text = manga.title
|
||||||
|
|
||||||
setImage(manga)
|
setImage(manga)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setImage(manga: Manga) {
|
fun setImage(manga: Manga) {
|
||||||
GlideApp.with(itemView.context).clear(itemView.itemImage)
|
GlideApp.with(itemView.context).clear(itemImage)
|
||||||
if (!manga.thumbnail_url.isNullOrEmpty()) {
|
if (!manga.thumbnail_url.isNullOrEmpty()) {
|
||||||
GlideApp.with(itemView.context)
|
GlideApp.with(itemView.context)
|
||||||
.load(manga)
|
.load(manga)
|
||||||
|
@ -36,7 +36,7 @@ class CatalogueSearchCardHolder(view: View, adapter: CatalogueSearchCardAdapter)
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.skipMemoryCache(true)
|
.skipMemoryCache(true)
|
||||||
.placeholder(android.R.color.transparent)
|
.placeholder(android.R.color.transparent)
|
||||||
.into(StateImageViewTarget(itemView.itemImage, itemView.progress))
|
.into(StateImageViewTarget(itemImage, progress))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@ package eu.kanade.tachiyomi.ui.catalogue.global_search
|
||||||
|
|
||||||
import android.support.v7.widget.LinearLayoutManager
|
import android.support.v7.widget.LinearLayoutManager
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder
|
|
||||||
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.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.getResourceColor
|
import eu.kanade.tachiyomi.util.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.gone
|
import eu.kanade.tachiyomi.util.gone
|
||||||
import eu.kanade.tachiyomi.util.setVectorCompat
|
import eu.kanade.tachiyomi.util.setVectorCompat
|
||||||
import eu.kanade.tachiyomi.util.visible
|
import eu.kanade.tachiyomi.util.visible
|
||||||
import kotlinx.android.synthetic.main.catalogue_global_search_controller_card.view.*
|
import kotlinx.android.synthetic.main.catalogue_global_search_controller_card.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holder that binds the [CatalogueSearchItem] containing catalogue cards.
|
* Holder that binds the [CatalogueSearchItem] containing catalogue cards.
|
||||||
|
@ -17,7 +17,8 @@ import kotlinx.android.synthetic.main.catalogue_global_search_controller_card.vi
|
||||||
* @param view view of [CatalogueSearchItem]
|
* @param view view of [CatalogueSearchItem]
|
||||||
* @param adapter instance of [CatalogueSearchAdapter]
|
* @param adapter instance of [CatalogueSearchAdapter]
|
||||||
*/
|
*/
|
||||||
class CatalogueSearchHolder(view: View, val adapter: CatalogueSearchAdapter) : FlexibleViewHolder(view, adapter) {
|
class CatalogueSearchHolder(view: View, val adapter: CatalogueSearchAdapter) :
|
||||||
|
BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter containing manga from search results.
|
* Adapter containing manga from search results.
|
||||||
|
@ -27,14 +28,12 @@ class CatalogueSearchHolder(view: View, val adapter: CatalogueSearchAdapter) : F
|
||||||
private var lastBoundResults: List<CatalogueSearchCardItem>? = null
|
private var lastBoundResults: List<CatalogueSearchCardItem>? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
with(itemView) {
|
// Set layout horizontal.
|
||||||
// Set layout horizontal.
|
recycler.layoutManager = LinearLayoutManager(view.context, LinearLayoutManager.HORIZONTAL, false)
|
||||||
recycler.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
recycler.adapter = mangaAdapter
|
||||||
recycler.adapter = mangaAdapter
|
|
||||||
|
|
||||||
nothing_found_icon.setVectorCompat(R.drawable.ic_search_black_112dp,
|
nothing_found_icon.setVectorCompat(R.drawable.ic_search_black_112dp,
|
||||||
context.getResourceColor(android.R.attr.textColorHint))
|
view.context.getResourceColor(android.R.attr.textColorHint))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,28 +45,26 @@ class CatalogueSearchHolder(view: View, val adapter: CatalogueSearchAdapter) : F
|
||||||
val source = item.source
|
val source = item.source
|
||||||
val results = item.results
|
val results = item.results
|
||||||
|
|
||||||
with(itemView) {
|
// Set Title witch country code if available.
|
||||||
// Set Title witch country code if available.
|
title.text = if (!source.lang.isEmpty()) "${source.name} (${source.lang})" else source.name
|
||||||
title.text = if (!source.lang.isEmpty()) "${source.name} (${source.lang})" else source.name
|
|
||||||
|
|
||||||
when {
|
when {
|
||||||
results == null -> {
|
results == null -> {
|
||||||
progress.visible()
|
progress.visible()
|
||||||
nothing_found.gone()
|
nothing_found.gone()
|
||||||
}
|
|
||||||
results.isEmpty() -> {
|
|
||||||
progress.gone()
|
|
||||||
nothing_found.visible()
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
progress.gone()
|
|
||||||
nothing_found.gone()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (results !== lastBoundResults) {
|
results.isEmpty() -> {
|
||||||
mangaAdapter.updateDataSet(results)
|
progress.gone()
|
||||||
lastBoundResults = results
|
nothing_found.visible()
|
||||||
}
|
}
|
||||||
|
else -> {
|
||||||
|
progress.gone()
|
||||||
|
nothing_found.gone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (results !== lastBoundResults) {
|
||||||
|
mangaAdapter.updateDataSet(results)
|
||||||
|
lastBoundResults = results
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
package eu.kanade.tachiyomi.ui.category
|
package eu.kanade.tachiyomi.ui.category
|
||||||
|
|
||||||
import android.graphics.Color
|
|
||||||
import android.graphics.Typeface
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import com.amulyakhare.textdrawable.TextDrawable
|
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator
|
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.Category
|
import eu.kanade.tachiyomi.data.database.models.Category
|
||||||
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.getRound
|
import eu.kanade.tachiyomi.util.getRound
|
||||||
import kotlinx.android.synthetic.main.categories_item.view.*
|
import kotlinx.android.synthetic.main.categories_item.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holder used to display category items.
|
* Holder used to display category items.
|
||||||
|
@ -16,16 +12,16 @@ import kotlinx.android.synthetic.main.categories_item.view.*
|
||||||
* @param view The view used by category items.
|
* @param view The view used by category items.
|
||||||
* @param adapter The adapter containing this holder.
|
* @param adapter The adapter containing this holder.
|
||||||
*/
|
*/
|
||||||
class CategoryHolder(view: View, val adapter: CategoryAdapter) : FlexibleViewHolder(view, adapter) {
|
class CategoryHolder(view: View, val adapter: CategoryAdapter) : BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// Create round letter image onclick to simulate long click
|
// Create round letter image onclick to simulate long click
|
||||||
itemView.image.setOnClickListener {
|
image.setOnClickListener {
|
||||||
// Simulate long click on this view to enter selection mode
|
// Simulate long click on this view to enter selection mode
|
||||||
onLongClick(view)
|
onLongClick(view)
|
||||||
}
|
}
|
||||||
|
|
||||||
setDragHandleView(itemView.reorder)
|
setDragHandleView(reorder)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,11 +31,11 @@ class CategoryHolder(view: View, val adapter: CategoryAdapter) : FlexibleViewHol
|
||||||
*/
|
*/
|
||||||
fun bind(category: Category) {
|
fun bind(category: Category) {
|
||||||
// Set capitalized title.
|
// Set capitalized title.
|
||||||
itemView.title.text = category.name.capitalize()
|
title.text = category.name.capitalize()
|
||||||
|
|
||||||
// Update circle letter image.
|
// Update circle letter image.
|
||||||
itemView.post {
|
itemView.post {
|
||||||
itemView.image.setImageDrawable(itemView.image.getRound(category.name.take(1).toUpperCase(),false))
|
image.setImageDrawable(image.getRound(category.name.take(1).toUpperCase(),false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package eu.kanade.tachiyomi.ui.download
|
package eu.kanade.tachiyomi.ui.download
|
||||||
|
|
||||||
import android.support.v7.widget.RecyclerView
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
|
import eu.kanade.tachiyomi.ui.base.holder.BaseViewHolder
|
||||||
import kotlinx.android.synthetic.main.download_item.view.*
|
import kotlinx.android.synthetic.main.download_item.view.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,7 +12,7 @@ import kotlinx.android.synthetic.main.download_item.view.*
|
||||||
* @param view the inflated view for this holder.
|
* @param view the inflated view for this holder.
|
||||||
* @constructor creates a new download holder.
|
* @constructor creates a new download holder.
|
||||||
*/
|
*/
|
||||||
class DownloadHolder(private val view: View) : RecyclerView.ViewHolder(view) {
|
class DownloadHolder(private val view: View) : BaseViewHolder(view) {
|
||||||
|
|
||||||
private lateinit var download: Download
|
private lateinit var download: Download
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.kanade.tachiyomi.data.glide.GlideApp
|
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||||
import eu.kanade.tachiyomi.source.LocalSource
|
import eu.kanade.tachiyomi.source.LocalSource
|
||||||
import kotlinx.android.synthetic.main.catalogue_grid_item.view.*
|
import kotlinx.android.synthetic.main.catalogue_grid_item.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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,30 +30,28 @@ class LibraryGridHolder(
|
||||||
*/
|
*/
|
||||||
override fun onSetValues(item: LibraryItem) {
|
override fun onSetValues(item: LibraryItem) {
|
||||||
// Update the title of the manga.
|
// Update the title of the manga.
|
||||||
view.title.text = item.manga.title
|
title.text = item.manga.title
|
||||||
|
|
||||||
// Update the unread count and its visibility.
|
// Update the unread count and its visibility.
|
||||||
with(view.unread_text) {
|
with(unread_text) {
|
||||||
visibility = if (item.manga.unread > 0) View.VISIBLE else View.GONE
|
visibility = if (item.manga.unread > 0) View.VISIBLE else View.GONE
|
||||||
text = item.manga.unread.toString()
|
text = item.manga.unread.toString()
|
||||||
}
|
}
|
||||||
// Update the download count and its visibility.
|
// Update the download count and its visibility.
|
||||||
with(view.download_text) {
|
with(download_text) {
|
||||||
visibility = if (item.downloadCount > 0) View.VISIBLE else View.GONE
|
visibility = if (item.downloadCount > 0) View.VISIBLE else View.GONE
|
||||||
text = item.downloadCount.toString()
|
text = item.downloadCount.toString()
|
||||||
}
|
}
|
||||||
//set local visibility if its local manga
|
//set local visibility if its local manga
|
||||||
with(view.local_text) {
|
local_text.visibility = if(item.manga.source == LocalSource.ID) View.VISIBLE else View.GONE
|
||||||
visibility = if(item.manga.source == LocalSource.ID) View.VISIBLE else View.GONE
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the cover.
|
// Update the cover.
|
||||||
GlideApp.with(view.context).clear(view.thumbnail)
|
GlideApp.with(view.context).clear(thumbnail)
|
||||||
GlideApp.with(view.context)
|
GlideApp.with(view.context)
|
||||||
.load(item.manga)
|
.load(item.manga)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.into(view.thumbnail)
|
.into(thumbnail)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.ui.library
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic class used to hold the displayed data of a manga in the library.
|
* Generic class used to hold the displayed data of a manga in the library.
|
||||||
|
@ -14,7 +14,7 @@ import eu.davidea.viewholders.FlexibleViewHolder
|
||||||
abstract class LibraryHolder(
|
abstract class LibraryHolder(
|
||||||
view: View,
|
view: View,
|
||||||
adapter: FlexibleAdapter<*>
|
adapter: FlexibleAdapter<*>
|
||||||
) : FlexibleViewHolder(view, adapter) {
|
) : BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method called from [LibraryCategoryAdapter.onBindViewHolder]. It updates the data for this
|
* Method called from [LibraryCategoryAdapter.onBindViewHolder]. It updates the data for this
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.kanade.tachiyomi.data.glide.GlideApp
|
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||||
import eu.kanade.tachiyomi.source.LocalSource
|
import eu.kanade.tachiyomi.source.LocalSource
|
||||||
import kotlinx.android.synthetic.main.catalogue_list_item.view.*
|
import kotlinx.android.synthetic.main.catalogue_list_item.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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,38 +30,36 @@ class LibraryListHolder(
|
||||||
*/
|
*/
|
||||||
override fun onSetValues(item: LibraryItem) {
|
override fun onSetValues(item: LibraryItem) {
|
||||||
// Update the title of the manga.
|
// Update the title of the manga.
|
||||||
itemView.title.text = item.manga.title
|
title.text = item.manga.title
|
||||||
|
|
||||||
// Update the unread count and its visibility.
|
// Update the unread count and its visibility.
|
||||||
with(itemView.unread_text) {
|
with(unread_text) {
|
||||||
visibility = if (item.manga.unread > 0) View.VISIBLE else View.GONE
|
visibility = if (item.manga.unread > 0) View.VISIBLE else View.GONE
|
||||||
text = item.manga.unread.toString()
|
text = item.manga.unread.toString()
|
||||||
}
|
}
|
||||||
// Update the download count and its visibility.
|
// Update the download count and its visibility.
|
||||||
with(itemView.download_text) {
|
with(download_text) {
|
||||||
visibility = if (item.downloadCount > 0) View.VISIBLE else View.GONE
|
visibility = if (item.downloadCount > 0) View.VISIBLE else View.GONE
|
||||||
text = "${item.downloadCount}"
|
text = "${item.downloadCount}"
|
||||||
}
|
}
|
||||||
//show local text badge if local manga
|
//show local text badge if local manga
|
||||||
with(itemView.local_text) {
|
local_text.visibility = if (item.manga.source == LocalSource.ID) View.VISIBLE else View.GONE
|
||||||
visibility = if (item.manga.source == LocalSource.ID) View.VISIBLE else View.GONE
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create thumbnail onclick to simulate long click
|
// Create thumbnail onclick to simulate long click
|
||||||
itemView.thumbnail.setOnClickListener {
|
thumbnail.setOnClickListener {
|
||||||
// Simulate long click on this view to enter selection mode
|
// Simulate long click on this view to enter selection mode
|
||||||
onLongClick(itemView)
|
onLongClick(itemView)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the cover.
|
// Update the cover.
|
||||||
GlideApp.with(itemView.context).clear(itemView.thumbnail)
|
GlideApp.with(itemView.context).clear(thumbnail)
|
||||||
GlideApp.with(itemView.context)
|
GlideApp.with(itemView.context)
|
||||||
.load(item.manga)
|
.load(item.manga)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.circleCrop()
|
.circleCrop()
|
||||||
.dontAnimate()
|
.dontAnimate()
|
||||||
.into(itemView.thumbnail)
|
.into(thumbnail)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,41 +2,41 @@ package eu.kanade.tachiyomi.ui.manga.chapter
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.PopupMenu
|
import android.widget.PopupMenu
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder
|
|
||||||
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.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.getResourceColor
|
import eu.kanade.tachiyomi.util.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.gone
|
import eu.kanade.tachiyomi.util.gone
|
||||||
import eu.kanade.tachiyomi.util.setVectorCompat
|
import eu.kanade.tachiyomi.util.setVectorCompat
|
||||||
import kotlinx.android.synthetic.main.chapters_item.view.*
|
import kotlinx.android.synthetic.main.chapters_item.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class ChapterHolder(
|
class ChapterHolder(
|
||||||
private val view: View,
|
private val view: View,
|
||||||
private val adapter: ChaptersAdapter
|
private val adapter: ChaptersAdapter
|
||||||
) : FlexibleViewHolder(view, adapter) {
|
) : BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
// We need to post a Runnable to show the popup to make sure that the PopupMenu is
|
// We need to post a Runnable to show the popup to make sure that the PopupMenu is
|
||||||
// correctly positioned. The reason being that the view may change position before the
|
// correctly positioned. The reason being that the view may change position before the
|
||||||
// PopupMenu is shown.
|
// PopupMenu is shown.
|
||||||
view.chapter_menu.setOnClickListener { it.post { showPopupMenu(it) } }
|
chapter_menu.setOnClickListener { it.post { showPopupMenu(it) } }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bind(item: ChapterItem, manga: Manga) = with(view) {
|
fun bind(item: ChapterItem, manga: Manga) {
|
||||||
val chapter = item.chapter
|
val chapter = item.chapter
|
||||||
|
|
||||||
chapter_title.text = when (manga.displayMode) {
|
chapter_title.text = when (manga.displayMode) {
|
||||||
Manga.DISPLAY_NUMBER -> {
|
Manga.DISPLAY_NUMBER -> {
|
||||||
val number = adapter.decimalFormat.format(chapter.chapter_number.toDouble())
|
val number = adapter.decimalFormat.format(chapter.chapter_number.toDouble())
|
||||||
context.getString(R.string.display_mode_chapter, number)
|
itemView.context.getString(R.string.display_mode_chapter, number)
|
||||||
}
|
}
|
||||||
else -> chapter.name
|
else -> chapter.name
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the correct drawable for dropdown and update the tint to match theme.
|
// Set the correct drawable for dropdown and update the tint to match theme.
|
||||||
view.chapter_menu.setVectorCompat(R.drawable.ic_more_horiz_black_24dp, view.context.getResourceColor(R.attr.icon_color))
|
chapter_menu.setVectorCompat(R.drawable.ic_more_horiz_black_24dp, view.context.getResourceColor(R.attr.icon_color))
|
||||||
|
|
||||||
// Set correct text color
|
// Set correct text color
|
||||||
chapter_title.setTextColor(if (chapter.read) adapter.readColor else adapter.unreadColor)
|
chapter_title.setTextColor(if (chapter.read) adapter.readColor else adapter.unreadColor)
|
||||||
|
@ -53,14 +53,14 @@ class ChapterHolder(
|
||||||
chapter_scanlator.text = chapter.scanlator
|
chapter_scanlator.text = chapter.scanlator
|
||||||
//allow longer titles if there is no scanlator (most sources)
|
//allow longer titles if there is no scanlator (most sources)
|
||||||
if (chapter_scanlator.text.isNullOrBlank()) {
|
if (chapter_scanlator.text.isNullOrBlank()) {
|
||||||
chapter_title.setMaxLines(2)
|
chapter_title.maxLines = 2
|
||||||
chapter_scanlator.gone()
|
chapter_scanlator.gone()
|
||||||
} else {
|
} else {
|
||||||
chapter_title.setMaxLines(1)
|
chapter_title.maxLines = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
chapter_pages.text = if (!chapter.read && chapter.last_page_read > 0) {
|
chapter_pages.text = if (!chapter.read && chapter.last_page_read > 0) {
|
||||||
context.getString(R.string.chapter_progress, chapter.last_page_read + 1)
|
itemView.context.getString(R.string.chapter_progress, chapter.last_page_read + 1)
|
||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ class ChapterHolder(
|
||||||
notifyStatus(item.status)
|
notifyStatus(item.status)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun notifyStatus(status: Int) = with(view.download_text) {
|
fun notifyStatus(status: Int) = with(download_text) {
|
||||||
when (status) {
|
when (status) {
|
||||||
Download.QUEUE -> setText(R.string.chapter_queued)
|
Download.QUEUE -> setText(R.string.chapter_queued)
|
||||||
Download.DOWNLOADING -> setText(R.string.chapter_downloading)
|
Download.DOWNLOADING -> setText(R.string.chapter_downloading)
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
package eu.kanade.tachiyomi.ui.manga.track
|
package eu.kanade.tachiyomi.ui.manga.track
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.support.v7.widget.RecyclerView
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import kotlinx.android.synthetic.main.track_item.view.*
|
import eu.kanade.tachiyomi.ui.base.holder.BaseViewHolder
|
||||||
|
import kotlinx.android.synthetic.main.track_item.*
|
||||||
|
|
||||||
class TrackHolder(view: View, adapter: TrackAdapter) : RecyclerView.ViewHolder(view) {
|
class TrackHolder(view: View, adapter: TrackAdapter) : BaseViewHolder(view) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val listener = adapter.rowClickListener
|
val listener = adapter.rowClickListener
|
||||||
view.title_container.setOnClickListener { listener.onTitleClick(adapterPosition) }
|
title_container.setOnClickListener { listener.onTitleClick(adapterPosition) }
|
||||||
view.status_container.setOnClickListener { listener.onStatusClick(adapterPosition) }
|
status_container.setOnClickListener { listener.onStatusClick(adapterPosition) }
|
||||||
view.chapters_container.setOnClickListener { listener.onChaptersClick(adapterPosition) }
|
chapters_container.setOnClickListener { listener.onChaptersClick(adapterPosition) }
|
||||||
view.score_container.setOnClickListener { listener.onScoreClick(adapterPosition) }
|
score_container.setOnClickListener { listener.onScoreClick(adapterPosition) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
fun bind(item: TrackItem) = with(itemView) {
|
fun bind(item: TrackItem) {
|
||||||
val track = item.track
|
val track = item.track
|
||||||
track_logo.setImageResource(item.service.getLogo())
|
track_logo.setImageResource(item.service.getLogo())
|
||||||
logo.setBackgroundColor(item.service.getLogoColor())
|
logo.setBackgroundColor(item.service.getLogoColor())
|
||||||
if (track != null) {
|
if (track != null) {
|
||||||
track_title.setTextAppearance(context, R.style.TextAppearance_Regular_Body1_Secondary)
|
track_title.setTextAppearance(itemView.context, R.style.TextAppearance_Regular_Body1_Secondary)
|
||||||
track_title.setAllCaps(false)
|
track_title.setAllCaps(false)
|
||||||
track_title.text = track.title
|
track_title.text = track.title
|
||||||
track_chapters.text = "${track.last_chapter_read}/" +
|
track_chapters.text = "${track.last_chapter_read}/" +
|
||||||
|
@ -31,7 +31,7 @@ class TrackHolder(view: View, adapter: TrackAdapter) : RecyclerView.ViewHolder(v
|
||||||
track_status.text = item.service.getStatus(track.status)
|
track_status.text = item.service.getStatus(track.status)
|
||||||
track_score.text = if (track.score == 0f) "-" else item.service.displayScore(track)
|
track_score.text = if (track.score == 0f) "-" else item.service.displayScore(track)
|
||||||
} else {
|
} else {
|
||||||
track_title.setTextAppearance(context, R.style.TextAppearance_Medium_Button)
|
track_title.setTextAppearance(itemView.context, R.style.TextAppearance_Medium_Button)
|
||||||
track_title.setText(R.string.action_edit)
|
track_title.setText(R.string.action_edit)
|
||||||
track_chapters.text = ""
|
track_chapters.text = ""
|
||||||
track_score.text = ""
|
track_score.text = ""
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
|
package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
|
||||||
|
|
||||||
import android.support.v7.widget.RecyclerView
|
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -11,10 +10,11 @@ import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||||
import com.hippo.unifile.UniFile
|
import com.hippo.unifile.UniFile
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
|
import eu.kanade.tachiyomi.ui.base.holder.BaseViewHolder
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.base.PageDecodeErrorLayout
|
import eu.kanade.tachiyomi.ui.reader.viewer.base.PageDecodeErrorLayout
|
||||||
import eu.kanade.tachiyomi.util.inflate
|
import eu.kanade.tachiyomi.util.inflate
|
||||||
import kotlinx.android.synthetic.main.reader_webtoon_item.view.*
|
import kotlinx.android.synthetic.main.reader_webtoon_item.*
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import rx.Subscription
|
import rx.Subscription
|
||||||
import rx.android.schedulers.AndroidSchedulers
|
import rx.android.schedulers.AndroidSchedulers
|
||||||
|
@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit
|
||||||
* @constructor creates a new webtoon holder.
|
* @constructor creates a new webtoon holder.
|
||||||
*/
|
*/
|
||||||
class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter) :
|
class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter) :
|
||||||
RecyclerView.ViewHolder(view) {
|
BaseViewHolder(view) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page of a chapter.
|
* Page of a chapter.
|
||||||
|
@ -54,7 +54,7 @@ class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter)
|
||||||
private var decodeErrorLayout: View? = null
|
private var decodeErrorLayout: View? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
with(view.image_view) {
|
with(image_view) {
|
||||||
setMaxTileSize(readerActivity.maxBitmapSize)
|
setMaxTileSize(readerActivity.maxBitmapSize)
|
||||||
setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED)
|
setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED)
|
||||||
setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE)
|
setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE)
|
||||||
|
@ -78,11 +78,11 @@ class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
view.progress_container.layoutParams = FrameLayout.LayoutParams(
|
progress_container.layoutParams = FrameLayout.LayoutParams(
|
||||||
MATCH_PARENT, webtoonReader.screenHeight)
|
MATCH_PARENT, webtoonReader.screenHeight)
|
||||||
|
|
||||||
view.setOnTouchListener(adapter.touchListener)
|
view.setOnTouchListener(adapter.touchListener)
|
||||||
view.retry_button.setOnTouchListener { _, event ->
|
retry_button.setOnTouchListener { _, event ->
|
||||||
if (event.action == MotionEvent.ACTION_UP) {
|
if (event.action == MotionEvent.ACTION_UP) {
|
||||||
readerActivity.presenter.retryPage(page)
|
readerActivity.presenter.retryPage(page)
|
||||||
}
|
}
|
||||||
|
@ -111,9 +111,9 @@ class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter)
|
||||||
(view as ViewGroup).removeView(it)
|
(view as ViewGroup).removeView(it)
|
||||||
decodeErrorLayout = null
|
decodeErrorLayout = null
|
||||||
}
|
}
|
||||||
view.image_view.recycle()
|
image_view.recycle()
|
||||||
view.image_view.visibility = View.GONE
|
image_view.visibility = View.GONE
|
||||||
view.progress_container.visibility = View.VISIBLE
|
progress_container.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -150,7 +150,7 @@ class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter)
|
||||||
.onBackpressureLatest()
|
.onBackpressureLatest()
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe { progress ->
|
.subscribe { progress ->
|
||||||
view.progress_text.text = if (progress > 0) {
|
progress_text.text = if (progress > 0) {
|
||||||
view.context.getString(R.string.download_progress, progress)
|
view.context.getString(R.string.download_progress, progress)
|
||||||
} else {
|
} else {
|
||||||
view.context.getString(R.string.downloading)
|
view.context.getString(R.string.downloading)
|
||||||
|
@ -279,14 +279,14 @@ class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter)
|
||||||
* Called when the image is decoded and going to be displayed.
|
* Called when the image is decoded and going to be displayed.
|
||||||
*/
|
*/
|
||||||
private fun onImageDecoded() {
|
private fun onImageDecoded() {
|
||||||
view.progress_container.visibility = View.GONE
|
progress_container.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the image fails to decode.
|
* Called when the image fails to decode.
|
||||||
*/
|
*/
|
||||||
private fun onImageDecodeError() {
|
private fun onImageDecodeError() {
|
||||||
view.progress_container.visibility = View.GONE
|
progress_container.visibility = View.GONE
|
||||||
|
|
||||||
val page = page ?: return
|
val page = page ?: return
|
||||||
if (decodeErrorLayout != null || !webtoonReader.isAdded) return
|
if (decodeErrorLayout != null || !webtoonReader.isAdded) return
|
||||||
|
|
|
@ -3,13 +3,13 @@ package eu.kanade.tachiyomi.ui.recent_updates
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.PopupMenu
|
import android.widget.PopupMenu
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder
|
|
||||||
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.data.glide.GlideApp
|
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||||
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.getResourceColor
|
import eu.kanade.tachiyomi.util.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.setVectorCompat
|
import eu.kanade.tachiyomi.util.setVectorCompat
|
||||||
import kotlinx.android.synthetic.main.recent_chapters_item.view.*
|
import kotlinx.android.synthetic.main.recent_chapters_item.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holder that contains chapter item
|
* Holder that contains chapter item
|
||||||
|
@ -22,7 +22,7 @@ import kotlinx.android.synthetic.main.recent_chapters_item.view.*
|
||||||
* @constructor creates a new recent chapter holder.
|
* @constructor creates a new recent chapter holder.
|
||||||
*/
|
*/
|
||||||
class RecentChapterHolder(private val view: View, private val adapter: RecentChaptersAdapter) :
|
class RecentChapterHolder(private val view: View, private val adapter: RecentChaptersAdapter) :
|
||||||
FlexibleViewHolder(view, adapter) {
|
BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Color of read chapter
|
* Color of read chapter
|
||||||
|
@ -43,8 +43,8 @@ class RecentChapterHolder(private val view: View, private val adapter: RecentCha
|
||||||
// We need to post a Runnable to show the popup to make sure that the PopupMenu is
|
// We need to post a Runnable to show the popup to make sure that the PopupMenu is
|
||||||
// correctly positioned. The reason being that the view may change position before the
|
// correctly positioned. The reason being that the view may change position before the
|
||||||
// PopupMenu is shown.
|
// PopupMenu is shown.
|
||||||
view.chapter_menu.setOnClickListener { it.post { showPopupMenu(it) } }
|
chapter_menu.setOnClickListener { it.post { showPopupMenu(it) } }
|
||||||
view.manga_cover.setOnClickListener {
|
manga_cover.setOnClickListener {
|
||||||
adapter.coverClickListener.onCoverClick(adapterPosition)
|
adapter.coverClickListener.onCoverClick(adapterPosition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,31 +58,31 @@ class RecentChapterHolder(private val view: View, private val adapter: RecentCha
|
||||||
this.item = item
|
this.item = item
|
||||||
|
|
||||||
// Set chapter title
|
// Set chapter title
|
||||||
view.chapter_title.text = item.chapter.name
|
chapter_title.text = item.chapter.name
|
||||||
|
|
||||||
// Set manga title
|
// Set manga title
|
||||||
view.manga_title.text = item.manga.title
|
manga_title.text = item.manga.title
|
||||||
|
|
||||||
// Set the correct drawable for dropdown and update the tint to match theme.
|
// Set the correct drawable for dropdown and update the tint to match theme.
|
||||||
view.chapter_menu_icon.setVectorCompat(R.drawable.ic_more_horiz_black_24dp, view.context.getResourceColor(R.attr.icon_color))
|
chapter_menu_icon.setVectorCompat(R.drawable.ic_more_horiz_black_24dp, view.context.getResourceColor(R.attr.icon_color))
|
||||||
|
|
||||||
// Set cover
|
// Set cover
|
||||||
GlideApp.with(itemView.context).clear(itemView.manga_cover)
|
GlideApp.with(itemView.context).clear(manga_cover)
|
||||||
if (!item.manga.thumbnail_url.isNullOrEmpty()) {
|
if (!item.manga.thumbnail_url.isNullOrEmpty()) {
|
||||||
GlideApp.with(itemView.context)
|
GlideApp.with(itemView.context)
|
||||||
.load(item.manga)
|
.load(item.manga)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
.circleCrop()
|
.circleCrop()
|
||||||
.into(itemView.manga_cover)
|
.into(manga_cover)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if chapter is read and set correct color
|
// Check if chapter is read and set correct color
|
||||||
if (item.chapter.read) {
|
if (item.chapter.read) {
|
||||||
view.chapter_title.setTextColor(readColor)
|
chapter_title.setTextColor(readColor)
|
||||||
view.manga_title.setTextColor(readColor)
|
manga_title.setTextColor(readColor)
|
||||||
} else {
|
} else {
|
||||||
view.chapter_title.setTextColor(unreadColor)
|
chapter_title.setTextColor(unreadColor)
|
||||||
view.manga_title.setTextColor(unreadColor)
|
manga_title.setTextColor(unreadColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set chapter status
|
// Set chapter status
|
||||||
|
@ -94,7 +94,7 @@ class RecentChapterHolder(private val view: View, private val adapter: RecentCha
|
||||||
*
|
*
|
||||||
* @param status download status
|
* @param status download status
|
||||||
*/
|
*/
|
||||||
fun notifyStatus(status: Int) = with(view.download_text) {
|
fun notifyStatus(status: Int) = with(download_text) {
|
||||||
when (status) {
|
when (status) {
|
||||||
Download.QUEUE -> setText(R.string.chapter_queued)
|
Download.QUEUE -> setText(R.string.chapter_queued)
|
||||||
Download.DOWNLOADING -> setText(R.string.chapter_downloading)
|
Download.DOWNLOADING -> setText(R.string.chapter_downloading)
|
||||||
|
|
|
@ -2,11 +2,11 @@ package eu.kanade.tachiyomi.ui.recently_read
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
import eu.davidea.viewholders.FlexibleViewHolder
|
|
||||||
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.glide.GlideApp
|
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||||
import kotlinx.android.synthetic.main.recently_read_item.view.*
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
|
import kotlinx.android.synthetic.main.recently_read_item.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,18 +21,18 @@ import java.util.*
|
||||||
class RecentlyReadHolder(
|
class RecentlyReadHolder(
|
||||||
view: View,
|
view: View,
|
||||||
val adapter: RecentlyReadAdapter
|
val adapter: RecentlyReadAdapter
|
||||||
) : FlexibleViewHolder(view, adapter) {
|
) : BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
itemView.remove.setOnClickListener {
|
remove.setOnClickListener {
|
||||||
adapter.removeClickListener.onRemoveClick(adapterPosition)
|
adapter.removeClickListener.onRemoveClick(adapterPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
itemView.resume.setOnClickListener {
|
resume.setOnClickListener {
|
||||||
adapter.resumeClickListener.onResumeClick(adapterPosition)
|
adapter.resumeClickListener.onResumeClick(adapterPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
itemView.cover.setOnClickListener {
|
cover.setOnClickListener {
|
||||||
adapter.coverClickListener.onCoverClick(adapterPosition)
|
adapter.coverClickListener.onCoverClick(adapterPosition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,24 +47,24 @@ class RecentlyReadHolder(
|
||||||
val (manga, chapter, history) = item
|
val (manga, chapter, history) = item
|
||||||
|
|
||||||
// Set manga title
|
// Set manga title
|
||||||
itemView.manga_title.text = manga.title
|
manga_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())
|
||||||
itemView.manga_source.text = itemView.context.getString(R.string.recent_manga_source)
|
manga_source.text = itemView.context.getString(R.string.recent_manga_source)
|
||||||
.format(adapter.sourceManager.get(manga.source)?.toString(), formattedNumber)
|
.format(adapter.sourceManager.get(manga.source)?.toString(), formattedNumber)
|
||||||
|
|
||||||
// Set last read timestamp title
|
// Set last read timestamp title
|
||||||
itemView.last_read.text = adapter.dateFormat.format(Date(history.last_read))
|
last_read.text = adapter.dateFormat.format(Date(history.last_read))
|
||||||
|
|
||||||
// Set cover
|
// Set cover
|
||||||
GlideApp.with(itemView.context).clear(itemView.cover)
|
GlideApp.with(itemView.context).clear(cover)
|
||||||
if (!manga.thumbnail_url.isNullOrEmpty()) {
|
if (!manga.thumbnail_url.isNullOrEmpty()) {
|
||||||
GlideApp.with(itemView.context)
|
GlideApp.with(itemView.context)
|
||||||
.load(manga)
|
.load(manga)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.into(itemView.cover)
|
.into(cover)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package eu.kanade.tachiyomi.ui.setting
|
package eu.kanade.tachiyomi.ui.setting
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
import android.content.Intent
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.preference.PreferenceScreen
|
import android.support.v7.preference.PreferenceScreen
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -22,8 +24,6 @@ import java.text.ParseException
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||||
import android.content.Intent
|
|
||||||
import android.net.Uri
|
|
||||||
|
|
||||||
|
|
||||||
class SettingsAboutController : SettingsController() {
|
class SettingsAboutController : SettingsController() {
|
||||||
|
|
|
@ -3,8 +3,6 @@ package eu.kanade.tachiyomi.ui.setting
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.support.v7.preference.PreferenceGroup
|
import android.support.v7.preference.PreferenceGroup
|
||||||
import android.support.v7.preference.PreferenceScreen
|
import android.support.v7.preference.PreferenceScreen
|
||||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
|
||||||
import com.bluelinelabs.conductor.ControllerChangeType
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
|
|
Loading…
Reference in a new issue