package tv.tivilux.nativeplayer import android.app.Application import coil.ImageLoader import coil.ImageLoaderFactory import coil.disk.DiskCache import coil.memory.MemoryCache /** * Process-wide performance setup for the TV client. * * - Keep HTTP sockets alive so playlist/EPG/API requests can reuse TCP connections. * - Give Coil a real memory + disk cache so scrolling posters/logos does not keep * decoding/downloading the same artwork. */ class TiviLuxApplication : Application(), ImageLoaderFactory { override fun onCreate() { super.onCreate() System.setProperty("http.keepAlive", "true") System.setProperty("http.maxConnections", "24") } override fun newImageLoader(): ImageLoader = ImageLoader.Builder(this) .crossfade(false) .memoryCache { MemoryCache.Builder(this) .maxSizePercent(0.10) .build() } .diskCache { DiskCache.Builder() .directory(cacheDir.resolve("tivilux-image-cache")) .maxSizeBytes(160L * 1024L * 1024L) .build() } .build() }