Questions tagged [android-lru-cache]

LruCache holds strong references to a limited number of values. Each time a value is accessed, it is moved to the head of a queue. When a value is added to a full cache, the value at the end of that queue is evicted and may become eligible for garbage collection.

LruCache holds strong references to a limited number of values. Each time a value is accessed, it is moved to the head of a queue. When a value is added to a full cache, the value at the end of that queue is evicted and may become eligible for garbage collection.

109 questions
2
votes
2 answers

Scroll fast viewPager with images in LruCache

I have a viewPager that have 4 images that need to resize. I implemented different options but no options run. I write the different options: In getView put: image.setImageBitmap(bitmap); The bitmap obtain: BitmapFactory.Options options = new…
2
votes
1 answer

caching images with LruCache

I am trying to use LruCache in android to cache some images, but its not caching here is the code int cacheSize1 = 4 * 1024 * 1024; // 4MiB bitmapCache = new LruCache(cacheSize1) { protected int sizeOf(String key, Bitmap value) { …
Raheel Sadiq
  • 9,847
  • 6
  • 42
  • 54
1
vote
0 answers

kotlin, is there a data structure like LinkedHashMap but thread safe

Need to have a queue and like mapSet to having unique key, so that it supports queue.put(key, value) //<== put in the queue and keep the order (it become last in the queue) queue.get(key) queue.remove(key) and it can also do something…
lannyf
  • 9,865
  • 12
  • 70
  • 152
1
vote
1 answer

LRUCache BitmapDrawable

I'm using an LruCache to cache a lot of small BitmapDrawables used throughout my app. The problem is that the sizes differ for the different places I use the images. I set the bounds when I retrieve the drawable from the cache before setting it to…
Pierre
  • 8,397
  • 4
  • 64
  • 80
1
vote
1 answer

DiskLRUCache for Bitmaps (and others) in Android

In android many image loading libraries (like Picasso -- which uses 2% of the storage for disk cache, Glide) use disk cache in addition to in memory lru cache. I can understand why this might be useful for images downloaded from the network -- if…
1
vote
1 answer

Android cache read-only REST API responses when offline

I'm pondering 2 approaches Caching the JSON responses as JSON files Caching the Java POJOs (the JSON responses are already de-serialised using Retrofit) using Reservoir. Description of the data: The data I want to cache here are a list of 20…
ericn
  • 12,476
  • 16
  • 84
  • 127
1
vote
2 answers

picasso doesn't cache for the first load but it's ok for the second time

I implemented a routine which saves data from a json into database and after that if user gets offline, he can see all data. but picasso doesn't load the images after the first run. but when i run the application twice in online mode, after that…
masoud vali
  • 1,528
  • 2
  • 18
  • 29
1
vote
0 answers

How to clear the cache in Android Volley's LRUImageCache for image reloading?

I'm using Volleys library for image downloading. When the user changes the profile image, I upload the image to the server to replace the previous image, since I'm using the user's ID in the database the link to the profile image is always the same.…
user3564573
  • 680
  • 1
  • 12
  • 24
1
vote
1 answer

java.lang.NoClassDefFoundError while initializing class in application onCreate

I am trying to instantiate a class on my applications onCreate method as follows: volleyQueueInstance = VolleySingleton.getInstance(getApplicationContext()); Following is my VolleySingleton class public class VolleySingleton { private static…
Amyth
  • 32,527
  • 26
  • 93
  • 135
1
vote
0 answers

Android Disk LRU Cache reset when app is closed

Is this really the intended behavior? I can't found any documentation on this issue.
Hanny Udayana
  • 388
  • 3
  • 21
1
vote
1 answer

Picasso image downloading & caching behavior

So I recently wanted to try out the caching feature of the Picasso library, & I got into this confusing situation: I retrieve the images' file names & paths from my web server (using Retrofit2), & I store them into ImageComponent objects…
Mohammed Aouf Zouag
  • 17,042
  • 4
  • 41
  • 67
1
vote
1 answer

Android BaseAdapter With LruCache Some ui problems

I am trying to implement to a list view with all contact images with the help of base adapter and LruCache. But on a long scroll on screen all the images(corresponding to that view) are displayed before setting actual image. eg: list view with 5…
Vishnu V
  • 382
  • 5
  • 16
1
vote
1 answer

links to images are stored in sqllite DB, how to cache

links to images are stored in an sqllite DB, I need to display them in a gridView. However, I was told they need to be cached to disk. my questions is what steps do i follow ? Do I first store the links from the DB into the disk Cache object, then…
gaer darrd
  • 35
  • 6
1
vote
1 answer

Android LRU Cache out of memory error

I'm using LRu Cache to download and display images from http protocol. My app is one Activity with 5 fragments. Each fragment load a Custom ListView with images and text. My app always crashes after a while. This is my LogCat: 11-03 18:00:22.613:…
antpr
  • 21
  • 2
1
vote
1 answer

Implementing a global LruCache vs many local LruCaches

Several Activitys in my app display images in a ListView where each row of the ListView contains an ImageView. An example of this would be a search screen where the user searches, gets results, and a picture of each result is shown. I'm trying to…
Andrew
  • 20,756
  • 32
  • 99
  • 177