Fix Mangalib pages loading
This commit is contained in:
@@ -3,6 +3,7 @@ package org.koitharu.kotatsu.core.parser
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import androidx.collection.ArraySet
|
||||
import androidx.core.net.toFile
|
||||
import androidx.core.net.toUri
|
||||
import org.koin.core.KoinComponent
|
||||
@@ -97,7 +98,7 @@ class LocalMangaRepository : MangaRepository, KoinComponent {
|
||||
}
|
||||
// fallback
|
||||
val title = file.nameWithoutExtension.replace("_", " ").capitalize()
|
||||
val chapters = HashSet<String>()
|
||||
val chapters = ArraySet<String>()
|
||||
for (x in zip.entries()) {
|
||||
if (!x.isDirectory) {
|
||||
chapters += x.name.substringBeforeLast(File.separatorChar, "")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.koitharu.kotatsu.domain.favourites
|
||||
|
||||
import androidx.collection.ArraySet
|
||||
import androidx.room.withTransaction
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -12,7 +13,6 @@ import org.koitharu.kotatsu.core.db.entity.MangaEntity
|
||||
import org.koitharu.kotatsu.core.db.entity.TagEntity
|
||||
import org.koitharu.kotatsu.core.model.FavouriteCategory
|
||||
import org.koitharu.kotatsu.core.model.Manga
|
||||
import java.util.*
|
||||
|
||||
class FavouritesRepository : KoinComponent {
|
||||
|
||||
@@ -98,7 +98,7 @@ class FavouritesRepository : KoinComponent {
|
||||
|
||||
companion object {
|
||||
|
||||
private val listeners = HashSet<OnFavouritesChangeListener>()
|
||||
private val listeners = ArraySet<OnFavouritesChangeListener>()
|
||||
|
||||
fun subscribe(listener: OnFavouritesChangeListener) {
|
||||
listeners += listener
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.koitharu.kotatsu.domain.history
|
||||
|
||||
import androidx.collection.ArraySet
|
||||
import androidx.room.withTransaction
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
@@ -71,7 +72,7 @@ class HistoryRepository : KoinComponent {
|
||||
|
||||
companion object {
|
||||
|
||||
private val listeners = HashSet<OnHistoryChangeListener>()
|
||||
private val listeners = ArraySet<OnHistoryChangeListener>()
|
||||
|
||||
fun subscribe(listener: OnHistoryChangeListener) {
|
||||
listeners += listener
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.koitharu.kotatsu.ui.reader
|
||||
|
||||
import android.net.Uri
|
||||
import android.util.ArrayMap
|
||||
import kotlinx.coroutines.*
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
@@ -16,7 +17,7 @@ import kotlin.coroutines.CoroutineContext
|
||||
class PageLoader : KoinComponent, CoroutineScope, DisposableHandle {
|
||||
|
||||
private val job = SupervisorJob()
|
||||
private val tasks = HashMap<String, Deferred<File>>()
|
||||
private val tasks = ArrayMap<String, Deferred<File>>()
|
||||
private val okHttp by inject<OkHttpClient>()
|
||||
private val cache by inject<PagesCache>()
|
||||
|
||||
@@ -48,16 +49,17 @@ class PageLoader : KoinComponent, CoroutineScope, DisposableHandle {
|
||||
val request = Request.Builder()
|
||||
.url(url)
|
||||
.get()
|
||||
.header("Accept", "image/webp,image/png;q=0.9,image/jpeg,*/*;q=0.8")
|
||||
.cacheControl(CacheUtils.CONTROL_DISABLED)
|
||||
.build()
|
||||
okHttp.newCall(request).await().use { response ->
|
||||
val body = response.body
|
||||
checkNotNull(body) {
|
||||
"Null response"
|
||||
}
|
||||
check(response.isSuccessful) {
|
||||
"Invalid response: ${response.code} ${response.message}"
|
||||
}
|
||||
checkNotNull(body) {
|
||||
"Null response"
|
||||
}
|
||||
cache.put(url) { out ->
|
||||
body.byteStream().copyTo(out)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user