diff --git a/app/src/main/java/io/legado/app/help/CacheManager.kt b/app/src/main/java/io/legado/app/help/CacheManager.kt index 53039d4cc..547d3334a 100644 --- a/app/src/main/java/io/legado/app/help/CacheManager.kt +++ b/app/src/main/java/io/legado/app/help/CacheManager.kt @@ -2,6 +2,7 @@ package io.legado.app.help import io.legado.app.App import io.legado.app.data.entities.Cache +import io.legado.app.utils.ACache @Suppress("unused") object CacheManager { @@ -11,9 +12,13 @@ object CacheManager { */ @JvmOverloads fun put(key: String, value: Any, saveTime: Int = 0) { - val deadline = if (saveTime == 0) 0 else System.currentTimeMillis() + saveTime * 1000 - val cache = Cache(key, value.toString(), deadline) - App.db.cacheDao().insert(cache) + if (value is ByteArray) { + ACache.get(App.INSTANCE).put(key, value, saveTime) + } else { + val deadline = if (saveTime == 0) 0 else System.currentTimeMillis() + saveTime * 1000 + val cache = Cache(key, value.toString(), deadline) + App.db.cacheDao().insert(cache) + } } fun get(key: String): String? { @@ -36,4 +41,7 @@ object CacheManager { return get(key)?.toFloatOrNull() } + fun getByteArray(key: String) { + ACache.get(App.INSTANCE).getAsBinary(key) + } } \ No newline at end of file