I did the caching part, but I’m not able to think of a way to preload images. Any suggestions?
Here is the caching part:
val maxMemory = (Runtime.getRuntime().maxMemory() / 1024).toInt()
val cache = object: LruCache<String, Bitmap>(maxMemory) {
override fun sizeOf(key: String, value: Bitmap): Int {
return value.byteCount
}
}
lateinit var bitmap: Bitmap
if (cache.get(url) != null){
bitmap = cache.get(url)
}else{
bitmap = flickrFetchr.fetchPhoto(url) ?: return
cache.put(url,bitmap)
}