8a322ea28e
* Extract source api from app module
* Extract source online api from app module
(cherry picked from commit 86fe850794)
# Conflicts:
# app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupManager.kt
# core/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt
# source-api/src/main/java/eu/kanade/tachiyomi/source/Source.kt
# source-api/src/main/java/eu/kanade/tachiyomi/source/model/SManga.kt
45 lines
1.2 KiB
Kotlin
45 lines
1.2 KiB
Kotlin
package eu.kanade.tachiyomi.source
|
|
|
|
import eu.kanade.tachiyomi.network.ProgressListener
|
|
import eu.kanade.tachiyomi.source.model.SManga
|
|
import kotlinx.coroutines.flow.MutableStateFlow
|
|
import kotlinx.coroutines.flow.asStateFlow
|
|
import kotlinx.serialization.Serializable
|
|
import kotlinx.serialization.Transient
|
|
import okhttp3.CacheControl
|
|
import okhttp3.Response
|
|
|
|
interface PagePreviewSource : Source {
|
|
|
|
suspend fun getPagePreviewList(manga: SManga, page: Int): PagePreviewPage
|
|
|
|
suspend fun fetchPreviewImage(page: PagePreviewInfo, cacheControl: CacheControl? = null): Response
|
|
}
|
|
|
|
@Serializable
|
|
data class PagePreviewPage(
|
|
val page: Int,
|
|
val pagePreviews: List<PagePreviewInfo>,
|
|
val hasNextPage: Boolean,
|
|
val pagePreviewPages: Int?,
|
|
)
|
|
|
|
@Serializable
|
|
data class PagePreviewInfo(
|
|
val index: Int,
|
|
val imageUrl: String,
|
|
@Transient
|
|
private val _progress: MutableStateFlow<Int> = MutableStateFlow(-1),
|
|
) : ProgressListener {
|
|
@Transient
|
|
val progress = _progress.asStateFlow()
|
|
|
|
override fun update(bytesRead: Long, contentLength: Long, done: Boolean) {
|
|
_progress.value = if (contentLength > 0) {
|
|
(100 * bytesRead / contentLength).toInt()
|
|
} else {
|
|
-1
|
|
}
|
|
}
|
|
}
|