Cache
This commit is contained in:
@@ -38,7 +38,7 @@ android {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 30
|
||||
versionCode 64
|
||||
versionName "5.1.7-beta1"
|
||||
versionName "6.0.0-alpha1"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
}
|
||||
|
||||
@@ -38,14 +38,12 @@ import com.facebook.drawee.drawable.ScalingUtils
|
||||
import com.facebook.drawee.interfaces.DraweeController
|
||||
import com.facebook.drawee.view.SimpleDraweeView
|
||||
import com.facebook.imagepipeline.image.ImageInfo
|
||||
import com.github.piasy.biv.loader.ImageLoader
|
||||
import com.github.piasy.biv.view.BigImageView
|
||||
import com.github.piasy.biv.view.ImageShownCallback
|
||||
import com.github.piasy.biv.view.ImageViewFactory
|
||||
import xyz.quaver.pupil.R
|
||||
import xyz.quaver.pupil.databinding.ReaderItemBinding
|
||||
import java.io.File
|
||||
import java.lang.Exception
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
data class ReaderItem(
|
||||
|
||||
@@ -25,14 +25,10 @@ import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.consumeAsFlow
|
||||
import okhttp3.Headers
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import org.kodein.di.DIAware
|
||||
import org.kodein.di.android.x.di
|
||||
import org.kodein.di.direct
|
||||
import org.kodein.di.instance
|
||||
import xyz.quaver.pupil.adapters.ReaderItem
|
||||
import xyz.quaver.pupil.sources.AnySource
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package xyz.quaver.pupil.util
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.channels.BufferOverflow
|
||||
@@ -49,7 +50,7 @@ class ImageCache(context: Context) : DIAware {
|
||||
suspend fun cleanup() = coroutineScope {
|
||||
val LIMIT = 100*1024*1024
|
||||
|
||||
cacheFolder.listFiles { it -> it.canonicalPath !in cache }?.forEach { it.delete() }
|
||||
cacheFolder.listFiles { it -> it.canonicalPath !in cache.values }?.forEach { it.delete() }
|
||||
|
||||
if (cacheFolder.size() > LIMIT)
|
||||
do {
|
||||
|
||||
@@ -35,7 +35,6 @@ class SavedSet <T: Any> (private val file: File, any: T, private val set: Mutabl
|
||||
|
||||
init {
|
||||
if (!file.exists()) {
|
||||
file.parentFile?.mkdirs()
|
||||
save()
|
||||
}
|
||||
load()
|
||||
@@ -53,6 +52,7 @@ class SavedSet <T: Any> (private val file: File, any: T, private val set: Mutabl
|
||||
|
||||
@Synchronized
|
||||
fun save() {
|
||||
file.parentFile?.mkdirs()
|
||||
if (!file.exists())
|
||||
file.createNewFile()
|
||||
|
||||
@@ -102,7 +102,6 @@ class SavedMap <K: Any, V: Any> (private val file: File, anyKey: K, anyValue: V,
|
||||
|
||||
init {
|
||||
if (!file.exists()) {
|
||||
file.parentFile?.mkdirs()
|
||||
save()
|
||||
}
|
||||
load()
|
||||
@@ -120,6 +119,7 @@ class SavedMap <K: Any, V: Any> (private val file: File, anyKey: K, anyValue: V,
|
||||
|
||||
@Synchronized
|
||||
fun save() {
|
||||
file.parentFile?.mkdirs()
|
||||
if (!file.exists())
|
||||
file.createNewFile()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user