|
|
|
|
@ -2,12 +2,10 @@ package org.koitharu.kotatsu.core.parser
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
|
|
import android.content.Context
|
|
|
|
|
import android.graphics.BitmapFactory
|
|
|
|
|
import android.util.Base64
|
|
|
|
|
import android.webkit.WebView
|
|
|
|
|
import androidx.annotation.MainThread
|
|
|
|
|
import androidx.core.os.LocaleListCompat
|
|
|
|
|
import com.davemorrissey.labs.subscaleview.decoder.ImageDecodeException
|
|
|
|
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
|
import kotlinx.coroutines.runBlocking
|
|
|
|
|
@ -17,6 +15,7 @@ import okhttp3.OkHttpClient
|
|
|
|
|
import okhttp3.Response
|
|
|
|
|
import okhttp3.ResponseBody.Companion.asResponseBody
|
|
|
|
|
import okio.Buffer
|
|
|
|
|
import org.koitharu.kotatsu.core.image.BitmapDecoderCompat
|
|
|
|
|
import org.koitharu.kotatsu.core.network.MangaHttpClient
|
|
|
|
|
import org.koitharu.kotatsu.core.network.cookies.MutableCookieJar
|
|
|
|
|
import org.koitharu.kotatsu.core.prefs.SourceSettings
|
|
|
|
|
@ -31,7 +30,6 @@ import org.koitharu.kotatsu.parsers.config.MangaSourceConfig
|
|
|
|
|
import org.koitharu.kotatsu.parsers.model.MangaSource
|
|
|
|
|
import org.koitharu.kotatsu.parsers.network.UserAgents
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.map
|
|
|
|
|
import org.koitharu.kotatsu.parsers.util.mimeType
|
|
|
|
|
import java.lang.ref.WeakReference
|
|
|
|
|
import java.util.Locale
|
|
|
|
|
import javax.inject.Inject
|
|
|
|
|
@ -80,15 +78,13 @@ class MangaLoaderContextImpl @Inject constructor(
|
|
|
|
|
|
|
|
|
|
override fun redrawImageResponse(response: Response, redraw: (image: Bitmap) -> Bitmap): Response {
|
|
|
|
|
return response.map { body ->
|
|
|
|
|
val opts = BitmapFactory.Options()
|
|
|
|
|
opts.inMutable = true
|
|
|
|
|
BitmapFactory.decodeStream(body.byteStream(), null, opts)?.use { bitmap ->
|
|
|
|
|
BitmapDecoderCompat.decode(body.byteStream(), body.contentType(), isMutable = true).use { bitmap ->
|
|
|
|
|
(redraw(BitmapWrapper.create(bitmap)) as BitmapWrapper).use { result ->
|
|
|
|
|
Buffer().also {
|
|
|
|
|
result.compressTo(it.outputStream())
|
|
|
|
|
}.asResponseBody("image/jpeg".toMediaType())
|
|
|
|
|
}
|
|
|
|
|
} ?: throw ImageDecodeException(response.request.url.toString(), response.mimeType)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|