@@ -185,11 +185,8 @@ class PageLoader @Inject constructor(
|
|||||||
prefetchLock.withLock {
|
prefetchLock.withLock {
|
||||||
while (prefetchQueue.isNotEmpty()) {
|
while (prefetchQueue.isNotEmpty()) {
|
||||||
val page = prefetchQueue.pollFirst() ?: return@launch
|
val page = prefetchQueue.pollFirst() ?: return@launch
|
||||||
if (cache.get(page.url) == null) { // FIXME use pageUrl
|
synchronized(tasks) {
|
||||||
synchronized(tasks) {
|
tasks[page.id] = loadPageAsyncImpl(page, skipCache = false, isPrefetch = true)
|
||||||
tasks[page.id] = loadPageAsyncImpl(page, skipCache = false, isPrefetch = true)
|
|
||||||
}
|
|
||||||
return@launch
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -202,13 +199,14 @@ class PageLoader @Inject constructor(
|
|||||||
): ProgressDeferred<Uri, Float> {
|
): ProgressDeferred<Uri, Float> {
|
||||||
val progress = MutableStateFlow(PROGRESS_UNDEFINED)
|
val progress = MutableStateFlow(PROGRESS_UNDEFINED)
|
||||||
val deferred = loaderScope.async {
|
val deferred = loaderScope.async {
|
||||||
if (!skipCache) {
|
|
||||||
// FIXME use pageUrl
|
|
||||||
cache.get(page.url)?.let { return@async it.toUri() }
|
|
||||||
}
|
|
||||||
counter.incrementAndGet()
|
counter.incrementAndGet()
|
||||||
try {
|
try {
|
||||||
loadPageImpl(page, progress, isPrefetch)
|
loadPageImpl(
|
||||||
|
page = page,
|
||||||
|
progress = progress,
|
||||||
|
isPrefetch = isPrefetch,
|
||||||
|
skipCache = skipCache,
|
||||||
|
)
|
||||||
} finally {
|
} finally {
|
||||||
if (counter.decrementAndGet() == 0) {
|
if (counter.decrementAndGet() == 0) {
|
||||||
onIdle()
|
onIdle()
|
||||||
@@ -232,9 +230,13 @@ class PageLoader @Inject constructor(
|
|||||||
page: MangaPage,
|
page: MangaPage,
|
||||||
progress: MutableStateFlow<Float>,
|
progress: MutableStateFlow<Float>,
|
||||||
isPrefetch: Boolean,
|
isPrefetch: Boolean,
|
||||||
|
skipCache: Boolean,
|
||||||
): Uri = semaphore.withPermit {
|
): Uri = semaphore.withPermit {
|
||||||
val pageUrl = getPageUrl(page)
|
val pageUrl = getPageUrl(page)
|
||||||
check(pageUrl.isNotBlank()) { "Cannot obtain full image url for $page" }
|
check(pageUrl.isNotBlank()) { "Cannot obtain full image url for $page" }
|
||||||
|
if (!skipCache) {
|
||||||
|
cache.get(pageUrl)?.let { return it.toUri() }
|
||||||
|
}
|
||||||
val uri = Uri.parse(pageUrl)
|
val uri = Uri.parse(pageUrl)
|
||||||
return when {
|
return when {
|
||||||
uri.isZipUri() -> if (uri.scheme == URI_SCHEME_ZIP) {
|
uri.isZipUri() -> if (uri.scheme == URI_SCHEME_ZIP) {
|
||||||
|
|||||||
Reference in New Issue
Block a user