Add Parceler implementations for Manga classes.
This commit is contained in:
@@ -1,98 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.core.model.parcelable
|
|
||||||
|
|
||||||
import android.os.Parcel
|
|
||||||
import androidx.core.os.ParcelCompat
|
|
||||||
import org.koitharu.kotatsu.core.util.ext.readParcelableCompat
|
|
||||||
import org.koitharu.kotatsu.core.util.ext.readSerializableCompat
|
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaPage
|
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaTag
|
|
||||||
|
|
||||||
fun Manga.writeToParcel(out: Parcel, flags: Int, withChapters: Boolean) {
|
|
||||||
out.writeLong(id)
|
|
||||||
out.writeString(title)
|
|
||||||
out.writeString(altTitle)
|
|
||||||
out.writeString(url)
|
|
||||||
out.writeString(publicUrl)
|
|
||||||
out.writeFloat(rating)
|
|
||||||
ParcelCompat.writeBoolean(out, isNsfw)
|
|
||||||
out.writeString(coverUrl)
|
|
||||||
out.writeString(largeCoverUrl)
|
|
||||||
out.writeString(description)
|
|
||||||
out.writeParcelable(ParcelableMangaTags(tags), flags)
|
|
||||||
out.writeSerializable(state)
|
|
||||||
out.writeString(author)
|
|
||||||
if (withChapters) {
|
|
||||||
out.writeParcelable(chapters?.let(::ParcelableMangaChapters), flags)
|
|
||||||
} else {
|
|
||||||
out.writeString(null)
|
|
||||||
}
|
|
||||||
out.writeSerializable(source)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Parcel.readManga() = Manga(
|
|
||||||
id = readLong(),
|
|
||||||
title = requireNotNull(readString()),
|
|
||||||
altTitle = readString(),
|
|
||||||
url = requireNotNull(readString()),
|
|
||||||
publicUrl = requireNotNull(readString()),
|
|
||||||
rating = readFloat(),
|
|
||||||
isNsfw = ParcelCompat.readBoolean(this),
|
|
||||||
coverUrl = requireNotNull(readString()),
|
|
||||||
largeCoverUrl = readString(),
|
|
||||||
description = readString(),
|
|
||||||
tags = requireNotNull(readParcelableCompat<ParcelableMangaTags>()).tags,
|
|
||||||
state = readSerializableCompat(),
|
|
||||||
author = readString(),
|
|
||||||
chapters = readParcelableCompat<ParcelableMangaChapters>()?.chapters,
|
|
||||||
source = checkNotNull(readSerializableCompat()),
|
|
||||||
)
|
|
||||||
|
|
||||||
fun MangaPage.writeToParcel(out: Parcel) {
|
|
||||||
out.writeLong(id)
|
|
||||||
out.writeString(url)
|
|
||||||
out.writeString(preview)
|
|
||||||
out.writeSerializable(source)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Parcel.readMangaPage() = MangaPage(
|
|
||||||
id = readLong(),
|
|
||||||
url = requireNotNull(readString()),
|
|
||||||
preview = readString(),
|
|
||||||
source = checkNotNull(readSerializableCompat()),
|
|
||||||
)
|
|
||||||
|
|
||||||
fun MangaChapter.writeToParcel(out: Parcel) {
|
|
||||||
out.writeLong(id)
|
|
||||||
out.writeString(name)
|
|
||||||
out.writeInt(number)
|
|
||||||
out.writeString(url)
|
|
||||||
out.writeString(scanlator)
|
|
||||||
out.writeLong(uploadDate)
|
|
||||||
out.writeString(branch)
|
|
||||||
out.writeSerializable(source)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Parcel.readMangaChapter() = MangaChapter(
|
|
||||||
id = readLong(),
|
|
||||||
name = requireNotNull(readString()),
|
|
||||||
number = readInt(),
|
|
||||||
url = requireNotNull(readString()),
|
|
||||||
scanlator = readString(),
|
|
||||||
uploadDate = readLong(),
|
|
||||||
branch = readString(),
|
|
||||||
source = checkNotNull(readSerializableCompat()),
|
|
||||||
)
|
|
||||||
|
|
||||||
fun MangaTag.writeToParcel(out: Parcel) {
|
|
||||||
out.writeString(title)
|
|
||||||
out.writeString(key)
|
|
||||||
out.writeSerializable(source)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Parcel.readMangaTag() = MangaTag(
|
|
||||||
title = requireNotNull(readString()),
|
|
||||||
key = requireNotNull(readString()),
|
|
||||||
source = checkNotNull(readSerializableCompat()),
|
|
||||||
)
|
|
||||||
@@ -2,56 +2,83 @@ package org.koitharu.kotatsu.core.model.parcelable
|
|||||||
|
|
||||||
import android.os.Parcel
|
import android.os.Parcel
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
|
import androidx.core.os.ParcelCompat
|
||||||
|
import kotlinx.parcelize.IgnoredOnParcel
|
||||||
|
import kotlinx.parcelize.Parceler
|
||||||
|
import kotlinx.parcelize.Parcelize
|
||||||
|
import org.koitharu.kotatsu.core.util.ext.readParcelableCompat
|
||||||
|
import org.koitharu.kotatsu.core.util.ext.readSerializableCompat
|
||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
|
|
||||||
// Limits to avoid TransactionTooLargeException
|
// Limits to avoid TransactionTooLargeException
|
||||||
private const val MAX_SAFE_SIZE = 1024 * 100 // Assume that 100 kb is safe parcel size
|
private const val MAX_SAFE_SIZE = 1024 * 100 // Assume that 100 kb is safe parcel size
|
||||||
private const val MAX_SAFE_CHAPTERS_COUNT = 24 // this is 100% safe
|
private const val MAX_SAFE_CHAPTERS_COUNT = 24 // this is 100% safe
|
||||||
|
|
||||||
class ParcelableManga(
|
@Parcelize
|
||||||
|
data class ParcelableManga(
|
||||||
val manga: Manga,
|
val manga: Manga,
|
||||||
private val withChapters: Boolean,
|
@IgnoredOnParcel private val withChapters: Boolean = true,
|
||||||
) : Parcelable {
|
) : Parcelable {
|
||||||
|
companion object : Parceler<ParcelableManga> {
|
||||||
constructor(parcel: Parcel) : this(parcel.readManga(), true)
|
private fun Manga.writeToParcel(out: Parcel, flags: Int, withChapters: Boolean) {
|
||||||
|
out.writeLong(id)
|
||||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
out.writeString(title)
|
||||||
val chapters = manga.chapters
|
out.writeString(altTitle)
|
||||||
if (!withChapters || chapters == null) {
|
out.writeString(url)
|
||||||
manga.writeToParcel(parcel, flags, withChapters = false)
|
out.writeString(publicUrl)
|
||||||
return
|
out.writeFloat(rating)
|
||||||
}
|
ParcelCompat.writeBoolean(out, isNsfw)
|
||||||
if (chapters.size <= MAX_SAFE_CHAPTERS_COUNT) {
|
out.writeString(coverUrl)
|
||||||
// fast path
|
out.writeString(largeCoverUrl)
|
||||||
manga.writeToParcel(parcel, flags, withChapters = true)
|
out.writeString(description)
|
||||||
return
|
out.writeParcelable(ParcelableMangaTags(tags), flags)
|
||||||
}
|
out.writeSerializable(state)
|
||||||
val tempParcel = Parcel.obtain()
|
out.writeString(author)
|
||||||
manga.writeToParcel(tempParcel, flags, withChapters = true)
|
val parcelableChapters = if (withChapters) null else chapters?.let(::ParcelableMangaChapters)
|
||||||
val size = tempParcel.dataSize()
|
out.writeParcelable(parcelableChapters, flags)
|
||||||
if (size < MAX_SAFE_SIZE) {
|
out.writeSerializable(source)
|
||||||
parcel.appendFrom(tempParcel, 0, size)
|
|
||||||
} else {
|
|
||||||
manga.writeToParcel(parcel, flags, withChapters = false)
|
|
||||||
}
|
|
||||||
tempParcel.recycle()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun describeContents(): Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun toString(): String {
|
|
||||||
return "ParcelableManga(manga=$manga, withChapters=$withChapters)"
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object CREATOR : Parcelable.Creator<ParcelableManga> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): ParcelableManga {
|
|
||||||
return ParcelableManga(parcel)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<ParcelableManga?> {
|
override fun ParcelableManga.write(parcel: Parcel, flags: Int) {
|
||||||
return arrayOfNulls(size)
|
val chapters = manga.chapters
|
||||||
|
if (!withChapters || chapters == null) {
|
||||||
|
manga.writeToParcel(parcel, flags, withChapters = false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (chapters.size <= MAX_SAFE_CHAPTERS_COUNT) {
|
||||||
|
// fast path
|
||||||
|
manga.writeToParcel(parcel, flags, withChapters = true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val tempParcel = Parcel.obtain()
|
||||||
|
manga.writeToParcel(tempParcel, flags, withChapters = true)
|
||||||
|
val size = tempParcel.dataSize()
|
||||||
|
if (size < MAX_SAFE_SIZE) {
|
||||||
|
parcel.appendFrom(tempParcel, 0, size)
|
||||||
|
} else {
|
||||||
|
manga.writeToParcel(parcel, flags, withChapters = false)
|
||||||
|
}
|
||||||
|
tempParcel.recycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun create(parcel: Parcel) = ParcelableManga(
|
||||||
|
Manga(
|
||||||
|
id = parcel.readLong(),
|
||||||
|
title = parcel.readString()!!,
|
||||||
|
altTitle = parcel.readString(),
|
||||||
|
url = parcel.readString()!!,
|
||||||
|
publicUrl = parcel.readString()!!,
|
||||||
|
rating = parcel.readFloat(),
|
||||||
|
isNsfw = ParcelCompat.readBoolean(parcel),
|
||||||
|
coverUrl = parcel.readString()!!,
|
||||||
|
largeCoverUrl = parcel.readString(),
|
||||||
|
description = parcel.readString(),
|
||||||
|
tags = parcel.readParcelableCompat<ParcelableMangaTags>()!!.tags,
|
||||||
|
state = parcel.readSerializableCompat(),
|
||||||
|
author = parcel.readString(),
|
||||||
|
chapters = parcel.readParcelableCompat<ParcelableMangaChapters>()?.chapters,
|
||||||
|
source = parcel.readSerializableCompat()!!,
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,38 +2,36 @@ package org.koitharu.kotatsu.core.model.parcelable
|
|||||||
|
|
||||||
import android.os.Parcel
|
import android.os.Parcel
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
|
import kotlinx.parcelize.Parceler
|
||||||
|
import kotlinx.parcelize.Parcelize
|
||||||
|
import kotlinx.parcelize.TypeParceler
|
||||||
|
import org.koitharu.kotatsu.core.util.ext.readSerializableCompat
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
||||||
|
|
||||||
class ParcelableMangaChapters(
|
object MangaChapterParceler : Parceler<MangaChapter> {
|
||||||
val chapters: List<MangaChapter>,
|
override fun create(parcel: Parcel) = MangaChapter(
|
||||||
) : Parcelable {
|
id = parcel.readLong(),
|
||||||
|
name = parcel.readString()!!,
|
||||||
constructor(parcel: Parcel) : this(
|
number = parcel.readInt(),
|
||||||
List(parcel.readInt()) { parcel.readMangaChapter() }
|
url = parcel.readString()!!,
|
||||||
|
scanlator = parcel.readString(),
|
||||||
|
uploadDate = parcel.readLong(),
|
||||||
|
branch = parcel.readString(),
|
||||||
|
source = parcel.readSerializableCompat()!!,
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
override fun MangaChapter.write(parcel: Parcel, flags: Int) {
|
||||||
parcel.writeInt(chapters.size)
|
parcel.writeLong(id)
|
||||||
for (chapter in chapters) {
|
parcel.writeString(name)
|
||||||
chapter.writeToParcel(parcel)
|
parcel.writeInt(number)
|
||||||
}
|
parcel.writeString(url)
|
||||||
}
|
parcel.writeString(scanlator)
|
||||||
|
parcel.writeLong(uploadDate)
|
||||||
override fun describeContents(): Int {
|
parcel.writeString(branch)
|
||||||
return 0
|
parcel.writeSerializable(source)
|
||||||
}
|
|
||||||
|
|
||||||
override fun toString(): String {
|
|
||||||
return "ParcelableMangaChapters(chapters=$chapters)"
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object CREATOR : Parcelable.Creator<ParcelableMangaChapters> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): ParcelableMangaChapters {
|
|
||||||
return ParcelableMangaChapters(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<ParcelableMangaChapters?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
@TypeParceler<MangaChapter, MangaChapterParceler>
|
||||||
|
data class ParcelableMangaChapters(val chapters: List<MangaChapter>) : Parcelable
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package org.koitharu.kotatsu.core.model.parcelable
|
||||||
|
|
||||||
|
import android.os.Parcel
|
||||||
|
import android.os.Parcelable
|
||||||
|
import kotlinx.parcelize.Parceler
|
||||||
|
import kotlinx.parcelize.Parcelize
|
||||||
|
import kotlinx.parcelize.TypeParceler
|
||||||
|
import org.koitharu.kotatsu.core.util.ext.readSerializableCompat
|
||||||
|
import org.koitharu.kotatsu.parsers.model.MangaPage
|
||||||
|
|
||||||
|
object MangaPageParceler : Parceler<MangaPage> {
|
||||||
|
override fun create(parcel: Parcel) = MangaPage(
|
||||||
|
id = parcel.readLong(),
|
||||||
|
url = parcel.readString()!!,
|
||||||
|
preview = parcel.readString(),
|
||||||
|
source = parcel.readSerializableCompat()!!,
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun MangaPage.write(parcel: Parcel, flags: Int) {
|
||||||
|
parcel.writeLong(id)
|
||||||
|
parcel.writeString(url)
|
||||||
|
parcel.writeString(preview)
|
||||||
|
parcel.writeSerializable(source)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
@TypeParceler<MangaPage, MangaPageParceler>
|
||||||
|
class ParcelableMangaPage(val page: MangaPage) : Parcelable
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.core.model.parcelable
|
|
||||||
|
|
||||||
import android.os.Parcel
|
|
||||||
import android.os.Parcelable
|
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaPage
|
|
||||||
|
|
||||||
class ParcelableMangaPages(
|
|
||||||
val pages: List<MangaPage>,
|
|
||||||
) : Parcelable {
|
|
||||||
|
|
||||||
constructor(parcel: Parcel) : this(
|
|
||||||
List(parcel.readInt()) { parcel.readMangaPage() }
|
|
||||||
)
|
|
||||||
|
|
||||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
|
||||||
parcel.writeInt(pages.size)
|
|
||||||
for (page in pages) {
|
|
||||||
page.writeToParcel(parcel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun describeContents(): Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun toString(): String {
|
|
||||||
return "ParcelableMangaPages(pages=$pages)"
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object CREATOR : Parcelable.Creator<ParcelableMangaPages> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): ParcelableMangaPages {
|
|
||||||
return ParcelableMangaPages(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<ParcelableMangaPages?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,39 +2,26 @@ package org.koitharu.kotatsu.core.model.parcelable
|
|||||||
|
|
||||||
import android.os.Parcel
|
import android.os.Parcel
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import org.koitharu.kotatsu.core.util.ext.Set
|
import kotlinx.parcelize.Parceler
|
||||||
|
import kotlinx.parcelize.Parcelize
|
||||||
|
import kotlinx.parcelize.TypeParceler
|
||||||
|
import org.koitharu.kotatsu.core.util.ext.readSerializableCompat
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaTag
|
import org.koitharu.kotatsu.parsers.model.MangaTag
|
||||||
|
|
||||||
class ParcelableMangaTags(
|
object MangaTagParceler : Parceler<MangaTag> {
|
||||||
val tags: Set<MangaTag>,
|
override fun create(parcel: Parcel) = MangaTag(
|
||||||
) : Parcelable {
|
title = parcel.readString()!!,
|
||||||
|
key = parcel.readString()!!,
|
||||||
constructor(parcel: Parcel) : this(
|
source = parcel.readSerializableCompat()!!,
|
||||||
Set(parcel.readInt()) { parcel.readMangaTag() },
|
|
||||||
)
|
)
|
||||||
|
|
||||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
override fun MangaTag.write(parcel: Parcel, flags: Int) {
|
||||||
parcel.writeInt(tags.size)
|
parcel.writeString(title)
|
||||||
for (tag in tags) {
|
parcel.writeString(key)
|
||||||
tag.writeToParcel(parcel)
|
parcel.writeSerializable(source)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun describeContents(): Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun toString(): String {
|
|
||||||
return "ParcelableMangaTags(tags=$tags)"
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object CREATOR : Parcelable.Creator<ParcelableMangaTags> {
|
|
||||||
override fun createFromParcel(parcel: Parcel): ParcelableMangaTags {
|
|
||||||
return ParcelableMangaTags(parcel)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newArray(size: Int): Array<ParcelableMangaTags?> {
|
|
||||||
return arrayOfNulls(size)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Parcelize
|
||||||
|
@TypeParceler<MangaTag, MangaTagParceler>
|
||||||
|
data class ParcelableMangaTags(val tags: Set<MangaTag>) : Parcelable
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ class DetailsActivity :
|
|||||||
|
|
||||||
fun newIntent(context: Context, manga: Manga): Intent {
|
fun newIntent(context: Context, manga: Manga): Intent {
|
||||||
return Intent(context, DetailsActivity::class.java)
|
return Intent(context, DetailsActivity::class.java)
|
||||||
.putExtra(MangaIntent.KEY_MANGA, ParcelableManga(manga, withChapters = true))
|
.putExtra(MangaIntent.KEY_MANGA, ParcelableManga(manga))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun newIntent(context: Context, mangaId: Long): Intent {
|
fun newIntent(context: Context, mangaId: Long): Intent {
|
||||||
|
|||||||
@@ -405,7 +405,7 @@ class ReaderActivity :
|
|||||||
.setAction(ACTION_MANGA_READ)
|
.setAction(ACTION_MANGA_READ)
|
||||||
|
|
||||||
fun manga(manga: Manga) = apply {
|
fun manga(manga: Manga) = apply {
|
||||||
intent.putExtra(MangaIntent.KEY_MANGA, ParcelableManga(manga, withChapters = true))
|
intent.putExtra(MangaIntent.KEY_MANGA, ParcelableManga(manga))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun mangaId(mangaId: Long) = apply {
|
fun mangaId(mangaId: Long) = apply {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import com.google.android.material.slider.Slider
|
|||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.core.model.parcelable.ParcelableManga
|
import org.koitharu.kotatsu.core.model.parcelable.ParcelableManga
|
||||||
import org.koitharu.kotatsu.core.model.parcelable.ParcelableMangaPages
|
import org.koitharu.kotatsu.core.model.parcelable.ParcelableMangaPage
|
||||||
import org.koitharu.kotatsu.core.ui.BaseActivity
|
import org.koitharu.kotatsu.core.ui.BaseActivity
|
||||||
import org.koitharu.kotatsu.core.util.ext.decodeRegion
|
import org.koitharu.kotatsu.core.util.ext.decodeRegion
|
||||||
import org.koitharu.kotatsu.core.util.ext.enqueueWith
|
import org.koitharu.kotatsu.core.util.ext.enqueueWith
|
||||||
@@ -153,6 +153,6 @@ class ColorFilterConfigActivity :
|
|||||||
fun newIntent(context: Context, manga: Manga, page: MangaPage) =
|
fun newIntent(context: Context, manga: Manga, page: MangaPage) =
|
||||||
Intent(context, ColorFilterConfigActivity::class.java)
|
Intent(context, ColorFilterConfigActivity::class.java)
|
||||||
.putExtra(EXTRA_MANGA, ParcelableManga(manga, false))
|
.putExtra(EXTRA_MANGA, ParcelableManga(manga, false))
|
||||||
.putExtra(EXTRA_PAGES, ParcelableMangaPages(listOf(page)))
|
.putExtra(EXTRA_PAGES, ParcelableMangaPage(page))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import org.koitharu.kotatsu.core.model.parcelable.ParcelableManga
|
import org.koitharu.kotatsu.core.model.parcelable.ParcelableManga
|
||||||
import org.koitharu.kotatsu.core.model.parcelable.ParcelableMangaPages
|
import org.koitharu.kotatsu.core.model.parcelable.ParcelableMangaPage
|
||||||
import org.koitharu.kotatsu.core.parser.MangaDataRepository
|
import org.koitharu.kotatsu.core.parser.MangaDataRepository
|
||||||
import org.koitharu.kotatsu.core.ui.BaseViewModel
|
import org.koitharu.kotatsu.core.ui.BaseViewModel
|
||||||
import org.koitharu.kotatsu.core.util.ext.MutableEventFlow
|
import org.koitharu.kotatsu.core.util.ext.MutableEventFlow
|
||||||
@@ -26,7 +26,7 @@ class ColorFilterConfigViewModel @Inject constructor(
|
|||||||
private var initialColorFilter: ReaderColorFilter? = null
|
private var initialColorFilter: ReaderColorFilter? = null
|
||||||
val colorFilter = MutableStateFlow<ReaderColorFilter?>(null)
|
val colorFilter = MutableStateFlow<ReaderColorFilter?>(null)
|
||||||
val onDismiss = MutableEventFlow<Unit>()
|
val onDismiss = MutableEventFlow<Unit>()
|
||||||
val preview = savedStateHandle.require<ParcelableMangaPages>(ColorFilterConfigActivity.EXTRA_PAGES).pages.first()
|
val preview = savedStateHandle.require<ParcelableMangaPage>(ColorFilterConfigActivity.EXTRA_PAGES).page
|
||||||
|
|
||||||
val isChanged: Boolean
|
val isChanged: Boolean
|
||||||
get() = colorFilter.value != initialColorFilter
|
get() = colorFilter.value != initialColorFilter
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ class PagesThumbnailsSheet :
|
|||||||
|
|
||||||
fun show(fm: FragmentManager, manga: Manga, chapterId: Long, currentPage: Int = -1) {
|
fun show(fm: FragmentManager, manga: Manga, chapterId: Long, currentPage: Int = -1) {
|
||||||
PagesThumbnailsSheet().withArgs(3) {
|
PagesThumbnailsSheet().withArgs(3) {
|
||||||
putParcelable(ARG_MANGA, ParcelableManga(manga, true))
|
putParcelable(ARG_MANGA, ParcelableManga(manga))
|
||||||
putLong(ARG_CHAPTER_ID, chapterId)
|
putLong(ARG_CHAPTER_ID, chapterId)
|
||||||
putInt(ARG_CURRENT_PAGE, currentPage)
|
putInt(ARG_CURRENT_PAGE, currentPage)
|
||||||
}.showDistinct(fm, TAG)
|
}.showDistinct(fm, TAG)
|
||||||
|
|||||||
Reference in New Issue
Block a user