don't cancel me shit
This commit is contained in:
@@ -4,10 +4,8 @@ package eu.kanade.tachiyomi.network
|
||||
// import eu.kanade.tachiyomi.BuildConfig
|
||||
// import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import android.content.Context
|
||||
import okhttp3.Dispatcher
|
||||
// import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.OkHttpClient
|
||||
import java.util.concurrent.Executors
|
||||
// import okhttp3.dnsoverhttps.DnsOverHttps
|
||||
// import okhttp3.logging.HttpLoggingInterceptor
|
||||
// import uy.kohesive.injekt.injectLazy
|
||||
|
||||
@@ -34,7 +34,7 @@ fun Call.asObservable(): Observable<Response> {
|
||||
}
|
||||
|
||||
override fun unsubscribe() {
|
||||
call.cancel()
|
||||
// call.cancel()
|
||||
}
|
||||
|
||||
override fun isUnsubscribed(): Boolean {
|
||||
@@ -81,12 +81,12 @@ fun Call.asObservable(): Observable<Response> {
|
||||
|
||||
fun Call.asObservableSuccess(): Observable<Response> {
|
||||
return asObservable()
|
||||
// .doOnNext { response ->
|
||||
// if (!response.isSuccessful) {
|
||||
// response.close()
|
||||
// throw Exception("HTTP error ${response.code}")
|
||||
// }
|
||||
// }
|
||||
.doOnNext { response ->
|
||||
if (!response.isSuccessful) {
|
||||
response.close()
|
||||
throw Exception("HTTP error ${response.code}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fun OkHttpClient.newCallWithProgress(request: Request, listener: ProgressListener): Call {
|
||||
|
||||
@@ -4,8 +4,6 @@ package ir.armor.tachidesk.util
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import eu.kanade.tachiyomi.network.asObservableSuccess
|
||||
import eu.kanade.tachiyomi.network.newCallWithProgress
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import ir.armor.tachidesk.database.table.ChapterTable
|
||||
@@ -60,12 +58,7 @@ fun getPageImage(mangaId: Int, chapterId: Int, index: Int): Pair<InputStream, St
|
||||
)
|
||||
}
|
||||
|
||||
// Note: line bellow somehow closes the okhttp reqest!
|
||||
// val response = source.fetchImage(tachiPage).toBlocking().first()
|
||||
// Note: also this which is the same
|
||||
// val response = source.client.newCallWithProgress(source.imageRequest(tachiPage), tachiPage)
|
||||
// .asObservableSuccess().toBlocking().first()
|
||||
val response = source.client.newCall(source.imageRequest(tachiPage)).execute()
|
||||
val response = source.fetchImage(tachiPage).toBlocking().first()
|
||||
|
||||
if (response.code == 200) {
|
||||
val contentType = response.headers["content-type"]!!
|
||||
|
||||
Reference in New Issue
Block a user