|
|
|
@ -4,6 +4,7 @@ import org.koitharu.kotatsu.R
|
|
|
|
import org.koitharu.kotatsu.base.ui.widgets.ChipsView
|
|
|
|
import org.koitharu.kotatsu.base.ui.widgets.ChipsView
|
|
|
|
import org.koitharu.kotatsu.core.exceptions.CloudFlareProtectedException
|
|
|
|
import org.koitharu.kotatsu.core.exceptions.CloudFlareProtectedException
|
|
|
|
import org.koitharu.kotatsu.core.exceptions.resolve.ExceptionResolver
|
|
|
|
import org.koitharu.kotatsu.core.exceptions.resolve.ExceptionResolver
|
|
|
|
|
|
|
|
import org.koitharu.kotatsu.core.parser.MangaTagHighlighter
|
|
|
|
import org.koitharu.kotatsu.core.prefs.ListMode
|
|
|
|
import org.koitharu.kotatsu.core.prefs.ListMode
|
|
|
|
import org.koitharu.kotatsu.history.domain.PROGRESS_NONE
|
|
|
|
import org.koitharu.kotatsu.history.domain.PROGRESS_NONE
|
|
|
|
import org.koitharu.kotatsu.list.domain.ListExtraProvider
|
|
|
|
import org.koitharu.kotatsu.list.domain.ListExtraProvider
|
|
|
|
@ -13,7 +14,10 @@ import org.koitharu.kotatsu.utils.ext.ifZero
|
|
|
|
import java.net.SocketTimeoutException
|
|
|
|
import java.net.SocketTimeoutException
|
|
|
|
import java.net.UnknownHostException
|
|
|
|
import java.net.UnknownHostException
|
|
|
|
|
|
|
|
|
|
|
|
fun Manga.toListModel(counter: Int, progress: Float) = MangaListModel(
|
|
|
|
fun Manga.toListModel(
|
|
|
|
|
|
|
|
counter: Int,
|
|
|
|
|
|
|
|
progress: Float,
|
|
|
|
|
|
|
|
) = MangaListModel(
|
|
|
|
id = id,
|
|
|
|
id = id,
|
|
|
|
title = title,
|
|
|
|
title = title,
|
|
|
|
subtitle = tags.joinToString(", ") { it.title },
|
|
|
|
subtitle = tags.joinToString(", ") { it.title },
|
|
|
|
@ -23,7 +27,11 @@ fun Manga.toListModel(counter: Int, progress: Float) = MangaListModel(
|
|
|
|
progress = progress,
|
|
|
|
progress = progress,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
fun Manga.toListDetailedModel(counter: Int, progress: Float) = MangaListDetailedModel(
|
|
|
|
fun Manga.toListDetailedModel(
|
|
|
|
|
|
|
|
counter: Int,
|
|
|
|
|
|
|
|
progress: Float,
|
|
|
|
|
|
|
|
tagHighlighter: MangaTagHighlighter?,
|
|
|
|
|
|
|
|
) = MangaListDetailedModel(
|
|
|
|
id = id,
|
|
|
|
id = id,
|
|
|
|
title = title,
|
|
|
|
title = title,
|
|
|
|
subtitle = altTitle,
|
|
|
|
subtitle = altTitle,
|
|
|
|
@ -31,7 +39,15 @@ fun Manga.toListDetailedModel(counter: Int, progress: Float) = MangaListDetailed
|
|
|
|
manga = this,
|
|
|
|
manga = this,
|
|
|
|
counter = counter,
|
|
|
|
counter = counter,
|
|
|
|
progress = progress,
|
|
|
|
progress = progress,
|
|
|
|
tags = tags.map { ChipsView.ChipModel(0, it.title, false, false, it) },
|
|
|
|
tags = tags.map {
|
|
|
|
|
|
|
|
ChipsView.ChipModel(
|
|
|
|
|
|
|
|
tint = tagHighlighter?.getTint(it) ?: 0,
|
|
|
|
|
|
|
|
title = it.title,
|
|
|
|
|
|
|
|
isCheckable = false,
|
|
|
|
|
|
|
|
isChecked = false,
|
|
|
|
|
|
|
|
data = it,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
fun Manga.toGridModel(counter: Int, progress: Float) = MangaGridModel(
|
|
|
|
fun Manga.toGridModel(counter: Int, progress: Float) = MangaGridModel(
|
|
|
|
@ -46,18 +62,21 @@ fun Manga.toGridModel(counter: Int, progress: Float) = MangaGridModel(
|
|
|
|
suspend fun List<Manga>.toUi(
|
|
|
|
suspend fun List<Manga>.toUi(
|
|
|
|
mode: ListMode,
|
|
|
|
mode: ListMode,
|
|
|
|
extraProvider: ListExtraProvider,
|
|
|
|
extraProvider: ListExtraProvider,
|
|
|
|
): List<MangaItemModel> = toUi(ArrayList(size), mode, extraProvider)
|
|
|
|
tagHighlighter: MangaTagHighlighter?,
|
|
|
|
|
|
|
|
): List<MangaItemModel> = toUi(ArrayList(size), mode, extraProvider, tagHighlighter)
|
|
|
|
|
|
|
|
|
|
|
|
fun List<Manga>.toUi(
|
|
|
|
fun List<Manga>.toUi(
|
|
|
|
mode: ListMode,
|
|
|
|
mode: ListMode,
|
|
|
|
): List<MangaItemModel> = toUi(ArrayList(size), mode)
|
|
|
|
tagHighlighter: MangaTagHighlighter?,
|
|
|
|
|
|
|
|
): List<MangaItemModel> = toUi(ArrayList(size), mode, tagHighlighter)
|
|
|
|
|
|
|
|
|
|
|
|
fun <C : MutableCollection<in MangaItemModel>> List<Manga>.toUi(
|
|
|
|
fun <C : MutableCollection<in MangaItemModel>> List<Manga>.toUi(
|
|
|
|
destination: C,
|
|
|
|
destination: C,
|
|
|
|
mode: ListMode,
|
|
|
|
mode: ListMode,
|
|
|
|
|
|
|
|
tagHighlighter: MangaTagHighlighter?,
|
|
|
|
): C = when (mode) {
|
|
|
|
): C = when (mode) {
|
|
|
|
ListMode.LIST -> mapTo(destination) { it.toListModel(0, PROGRESS_NONE) }
|
|
|
|
ListMode.LIST -> mapTo(destination) { it.toListModel(0, PROGRESS_NONE) }
|
|
|
|
ListMode.DETAILED_LIST -> mapTo(destination) { it.toListDetailedModel(0, PROGRESS_NONE) }
|
|
|
|
ListMode.DETAILED_LIST -> mapTo(destination) { it.toListDetailedModel(0, PROGRESS_NONE, tagHighlighter) }
|
|
|
|
ListMode.GRID -> mapTo(destination) { it.toGridModel(0, PROGRESS_NONE) }
|
|
|
|
ListMode.GRID -> mapTo(destination) { it.toGridModel(0, PROGRESS_NONE) }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -65,13 +84,14 @@ suspend fun <C : MutableCollection<in MangaItemModel>> List<Manga>.toUi(
|
|
|
|
destination: C,
|
|
|
|
destination: C,
|
|
|
|
mode: ListMode,
|
|
|
|
mode: ListMode,
|
|
|
|
extraProvider: ListExtraProvider,
|
|
|
|
extraProvider: ListExtraProvider,
|
|
|
|
|
|
|
|
tagHighlighter: MangaTagHighlighter?,
|
|
|
|
): C = when (mode) {
|
|
|
|
): C = when (mode) {
|
|
|
|
ListMode.LIST -> mapTo(destination) {
|
|
|
|
ListMode.LIST -> mapTo(destination) {
|
|
|
|
it.toListModel(extraProvider.getCounter(it.id), extraProvider.getProgress(it.id))
|
|
|
|
it.toListModel(extraProvider.getCounter(it.id), extraProvider.getProgress(it.id))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ListMode.DETAILED_LIST -> mapTo(destination) {
|
|
|
|
ListMode.DETAILED_LIST -> mapTo(destination) {
|
|
|
|
it.toListDetailedModel(extraProvider.getCounter(it.id), extraProvider.getProgress(it.id))
|
|
|
|
it.toListDetailedModel(extraProvider.getCounter(it.id), extraProvider.getProgress(it.id), tagHighlighter)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ListMode.GRID -> mapTo(destination) {
|
|
|
|
ListMode.GRID -> mapTo(destination) {
|
|
|
|
|