1package soy.iko.opencode
3import android.app.Application
5import coil.ImageLoaderFactory
6import coil.disk.DiskCache
7import coil.memory.MemoryCache
8import soy.iko.opencode.data.repo.CrashLogger
9import soy.iko.opencode.di.AppContainer
10import java.util.concurrent.atomic.AtomicBoolean
12class OpencodeApp : Application(), ImageLoaderFactory {
13 lateinit var container: AppContainer
16 private val shutdownCalled = AtomicBoolean(false)
18 override fun onCreate() {
20 CrashLogger.get(this).install()
21 container = AppContainer(this)
22 // onTerminate() is only called in emulated process environments, not on real
23 // devices. Register a JVM shutdown hook so cleanup (network callback unregister,
24 // scope cancellation, connection close) runs when the process is actually killed.
25 Runtime.getRuntime().addShutdownHook(Thread {
30 // Process-wide Coil singleton. The defaults are sane; the explicit factory adds a
31 // disk cache so scrolling back to an image-bearing message doesn't re-fetch it over
32 // the (auth-protected) network every time. Data-URI (base64) images skip the disk
33 // cache automatically; only resolved HTTP/S URLs are cached, keyed by URL.
34 override fun newImageLoader(): ImageLoader = ImageLoader.Builder(this)
36 MemoryCache.Builder(this)
42 .directory(cacheDir.resolve("image_cache"))
43 .maxSizeBytes(50L * 1024 * 1024)
48 override fun onTerminate() {
53 private fun shutdown() {
54 // Guard against double shutdown — onTerminate and the shutdown hook can both
55 // fire in emulated environments.
56 if (!shutdownCalled.compareAndSet(false, true)) return
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list