Show available manga info on view load (closes #3367)
This commit is contained in:
parent
0258422527
commit
d44503cb19
@ -40,8 +40,8 @@ class MangaInfoHeaderAdapter(
|
|||||||
) :
|
) :
|
||||||
RecyclerView.Adapter<MangaInfoHeaderAdapter.HeaderViewHolder>() {
|
RecyclerView.Adapter<MangaInfoHeaderAdapter.HeaderViewHolder>() {
|
||||||
|
|
||||||
private var manga: Manga? = null
|
private var manga: Manga = controller.presenter.manga
|
||||||
private var source: Source? = null
|
private var source: Source = controller.presenter.source
|
||||||
private var numChapters: Int? = null
|
private var numChapters: Int? = null
|
||||||
|
|
||||||
private val scope = CoroutineScope(Job() + Dispatchers.Main)
|
private val scope = CoroutineScope(Job() + Dispatchers.Main)
|
||||||
@ -66,7 +66,7 @@ class MangaInfoHeaderAdapter(
|
|||||||
* @param manga manga object containing information about manga.
|
* @param manga manga object containing information about manga.
|
||||||
* @param source the source of the manga.
|
* @param source the source of the manga.
|
||||||
*/
|
*/
|
||||||
fun update(manga: Manga, source: Source?) {
|
fun update(manga: Manga, source: Source) {
|
||||||
this.manga = manga
|
this.manga = manga
|
||||||
this.source = source
|
this.source = source
|
||||||
|
|
||||||
@ -81,10 +81,6 @@ class MangaInfoHeaderAdapter(
|
|||||||
|
|
||||||
inner class HeaderViewHolder(private val view: View) : RecyclerView.ViewHolder(view) {
|
inner class HeaderViewHolder(private val view: View) : RecyclerView.ViewHolder(view) {
|
||||||
fun bind() {
|
fun bind() {
|
||||||
if (manga == null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// For rounded corners
|
// For rounded corners
|
||||||
binding.mangaCover.clipToOutline = true
|
binding.mangaCover.clipToOutline = true
|
||||||
|
|
||||||
@ -177,7 +173,7 @@ class MangaInfoHeaderAdapter(
|
|||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
|
|
||||||
setMangaInfo(manga!!, source)
|
setMangaInfo(manga, source)
|
||||||
setChapterInfo()
|
setChapterInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,20 +233,16 @@ class MangaInfoHeaderAdapter(
|
|||||||
setFavoriteButtonState(manga.favorite)
|
setFavoriteButtonState(manga.favorite)
|
||||||
|
|
||||||
// Set cover if it wasn't already.
|
// Set cover if it wasn't already.
|
||||||
val mangaThumbnail = manga.toMangaThumbnail()
|
if (binding.mangaCover.drawable == null) {
|
||||||
|
val mangaThumbnail = manga.toMangaThumbnail()
|
||||||
GlideApp.with(view.context)
|
listOf(binding.mangaCover, binding.backdrop)
|
||||||
.load(mangaThumbnail)
|
.forEach {
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
GlideApp.with(view.context)
|
||||||
.centerCrop()
|
.load(mangaThumbnail)
|
||||||
.into(binding.mangaCover)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
|
.centerCrop()
|
||||||
binding.backdrop?.let {
|
.into(it)
|
||||||
GlideApp.with(view.context)
|
}
|
||||||
.load(mangaThumbnail)
|
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
|
||||||
.centerCrop()
|
|
||||||
.into(it)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manga info section
|
// Manga info section
|
||||||
|
Loading…
Reference in New Issue
Block a user