Bug fix
This commit is contained in:
@@ -40,9 +40,7 @@ import xyz.quaver.Code
|
||||
import xyz.quaver.hitomi.Reader
|
||||
import xyz.quaver.hitomi.getReferer
|
||||
import xyz.quaver.hitomi.imageUrlFromImage
|
||||
import xyz.quaver.hiyobi.cookie
|
||||
import xyz.quaver.hiyobi.createImgList
|
||||
import xyz.quaver.hiyobi.user_agent
|
||||
import xyz.quaver.io.util.readBytes
|
||||
import xyz.quaver.pupil.R
|
||||
import xyz.quaver.pupil.services.DownloadService
|
||||
@@ -116,10 +114,7 @@ class ReaderAdapter(private val activity: ReaderActivity,
|
||||
)
|
||||
, LazyHeaders.Builder().addHeader("Referer", getReferer(galleryID)).build())
|
||||
Code.HIYOBI ->
|
||||
GlideUrl(createImgList(galleryID, reader!!, lowQuality)[position].path, LazyHeaders.Builder()
|
||||
.addHeader("User-Agent", user_agent)
|
||||
.addHeader("Cookie", cookie)
|
||||
.build())
|
||||
GlideUrl(createImgList(galleryID, reader!!, lowQuality)[position].path)
|
||||
else -> null
|
||||
}
|
||||
holder.view.image.post {
|
||||
|
||||
@@ -307,8 +307,7 @@ class DownloadService : Service() {
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (progress.indexOfKey(galleryID) < 0)
|
||||
progress.put(galleryID, MutableList(reader.galleryInfo.files.size) { 0F })
|
||||
progress.put(galleryID, MutableList(reader.galleryInfo.files.size) { 0F })
|
||||
|
||||
cache.metadata.imageList?.forEachIndexed { index, image ->
|
||||
progress[galleryID]?.set(index, if (image != null) Float.POSITIVE_INFINITY else 0F)
|
||||
@@ -390,6 +389,8 @@ class DownloadService : Service() {
|
||||
COMMAND_DELETE -> intent.getIntExtra(KEY_ID, -1).let { if (it > 0) delete(it, startId) }
|
||||
}
|
||||
|
||||
startForeground(R.id.downloader_notification_id, serviceNotification.build())
|
||||
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
|
||||
@@ -401,7 +402,6 @@ class DownloadService : Service() {
|
||||
override fun onBind(p0: Intent?) = binder
|
||||
|
||||
override fun onCreate() {
|
||||
startForeground(R.id.downloader_notification_id, serviceNotification.build())
|
||||
interceptors[Tag::class] = interceptor
|
||||
}
|
||||
|
||||
|
||||
@@ -36,15 +36,17 @@ class GalleryList(private val file: File, private val list: MutableSet<Int> = mu
|
||||
fun load() {
|
||||
synchronized(this) {
|
||||
list.clear()
|
||||
list.addAll(
|
||||
kotlin.runCatching {
|
||||
Json.decodeFromString<List<Int>>(file.bufferedReader().use { it.readText() })
|
||||
)
|
||||
}.onSuccess {
|
||||
list.addAll(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun save() {
|
||||
synchronized(this) {
|
||||
file.writeText(Json.encodeToString(list))
|
||||
file.writeText(Json.encodeToString(list.toList()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,9 +37,7 @@ import xyz.quaver.Code
|
||||
import xyz.quaver.hitomi.Reader
|
||||
import xyz.quaver.hitomi.getReferer
|
||||
import xyz.quaver.hitomi.imageUrlFromImage
|
||||
import xyz.quaver.hiyobi.cookie
|
||||
import xyz.quaver.hiyobi.createImgList
|
||||
import xyz.quaver.hiyobi.user_agent
|
||||
import xyz.quaver.pupil.R
|
||||
import xyz.quaver.pupil.client
|
||||
import xyz.quaver.pupil.interceptors
|
||||
@@ -220,8 +218,6 @@ class DownloadWorker private constructor(context: Context) : ContextWrapper(cont
|
||||
}
|
||||
Code.HIYOBI -> {
|
||||
url(createImgList(galleryID, reader, lowQuality)[index].path)
|
||||
addHeader("User-Agent", user_agent)
|
||||
addHeader("Cookie", cookie)
|
||||
}
|
||||
else -> {
|
||||
//shouldn't be called anyway
|
||||
|
||||
@@ -22,11 +22,6 @@ import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import xyz.quaver.Code
|
||||
@@ -34,11 +29,7 @@ import xyz.quaver.hitomi.GalleryBlock
|
||||
import xyz.quaver.hitomi.Reader
|
||||
import xyz.quaver.hitomi.getReferer
|
||||
import xyz.quaver.hitomi.imageUrlFromImage
|
||||
import xyz.quaver.hiyobi.cookie
|
||||
import xyz.quaver.hiyobi.createImgList
|
||||
import xyz.quaver.hiyobi.user_agent
|
||||
import xyz.quaver.pupil.util.downloader.Cache
|
||||
import xyz.quaver.pupil.util.downloader.Metadata
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
@@ -134,8 +125,6 @@ val Reader.requestBuilders: List<Request.Builder>
|
||||
createImgList(galleryID, this, lowQuality).map {
|
||||
Request.Builder()
|
||||
.url(it.path)
|
||||
.header("User-Agent", user_agent)
|
||||
.header("Cookie", cookie)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,6 +325,8 @@ fun xyz.quaver.pupil.util.downloader.DownloadManager.migrate() {
|
||||
.mActions.clear()
|
||||
notificationManager.notify(R.id.notification_id_import, notification.build())
|
||||
|
||||
unregisterReceiver(receiver)
|
||||
kotlin.runCatching {
|
||||
unregisterReceiver(receiver)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user