I'm using LRUCache to cache images that I retrieve from a server. I'm requesting them from a RecyclerView but till all the images are cached the LRUCache instance returns size 0.
Here's the Code
public void buildCache() {
for (Feed feed : mFeeds) {
List<User> users = new ArrayList<>();
users.add(feed.getAuthor());
try {
if (feed.getPostType() == Feed.PostType.Collab) {
for (User receiver : feed.getUsers())
users.add(receiver);
getImages(users);
Log.d(LOG_TAG, "Cache size: " + imagesLruCache.size());
} else if (feed.getPostType() == Feed.PostType.Search){
String receiverUsername = feed.getReceiver().getUsername();
getImages(users);
}
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
mCacheBuildingInterface.OnCacheBuilt();
dataSetChanged();
}
What should I do to fix the problem ?
Thx to everyone