mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-07-04 18:40:39 +02:00
increases disk cache to 1GB and adds a memory cache policy.
This commit is contained in:
@ -30,6 +30,7 @@ import android.util.Log
|
|||||||
import androidx.security.crypto.EncryptedSharedPreferences
|
import androidx.security.crypto.EncryptedSharedPreferences
|
||||||
import coil.ImageLoader
|
import coil.ImageLoader
|
||||||
import coil.disk.DiskCache
|
import coil.disk.DiskCache
|
||||||
|
import coil.memory.MemoryCache
|
||||||
import com.vitorpamplona.amethyst.service.ots.OkHttpBlockstreamExplorer
|
import com.vitorpamplona.amethyst.service.ots.OkHttpBlockstreamExplorer
|
||||||
import com.vitorpamplona.amethyst.service.ots.OkHttpCalendarBuilder
|
import com.vitorpamplona.amethyst.service.ots.OkHttpCalendarBuilder
|
||||||
import com.vitorpamplona.amethyst.service.playback.VideoCache
|
import com.vitorpamplona.amethyst.service.playback.VideoCache
|
||||||
@ -66,7 +67,14 @@ class Amethyst : Application() {
|
|||||||
.Builder()
|
.Builder()
|
||||||
.directory(applicationContext.safeCacheDir.resolve("image_cache"))
|
.directory(applicationContext.safeCacheDir.resolve("image_cache"))
|
||||||
.maxSizePercent(0.2)
|
.maxSizePercent(0.2)
|
||||||
.maximumMaxSizeBytes(500L * 1024 * 1024) // 250MB
|
.maximumMaxSizeBytes(1024 * 1024 * 1024) // 1GB
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
val coilMemCache: MemoryCache by lazy {
|
||||||
|
MemoryCache
|
||||||
|
.Builder(this)
|
||||||
|
.maxSizePercent(0.40) // memory heavy app due to profile pics and videos.
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +114,7 @@ class Amethyst : Application() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun imageLoaderBuilder(): ImageLoader.Builder = ImageLoader.Builder(applicationContext).diskCache { coilCache }
|
fun imageLoaderBuilder(): ImageLoader.Builder = ImageLoader.Builder(this).diskCache { coilCache }.memoryCache { coilMemCache }
|
||||||
|
|
||||||
fun encryptedStorage(npub: String? = null): EncryptedSharedPreferences = EncryptedStorage.preferences(instance, npub)
|
fun encryptedStorage(npub: String? = null): EncryptedSharedPreferences = EncryptedStorage.preferences(instance, npub)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user