Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix of LinkedHashMap visibility problem. #276

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/android/Library/src/ImageFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.Map;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.concurrent.ConcurrentHashMap;
Expand All @@ -44,12 +45,12 @@
/**
* This helper class download images from the Internet and binds those with the
* provided ImageView.
*
*
* <p>
* It requires the INTERNET permission, which should be added to your
* application's manifest file.
* </p>
*
*
* A local cache of downloaded images is maintained internally to improve
* performance.
*/
Expand Down Expand Up @@ -249,7 +250,7 @@ protected void onPostExecute(Bitmap bitmap) {
/**
* A fake Drawable that will be attached to the imageView while the download
* is in progress.
*
*
* <p>
* Contains a reference to the actual download task, so that a download task
* can be stopped if a new binding is required, and makes sure that only the
Expand Down Expand Up @@ -278,7 +279,7 @@ public BitmapFetcherTask getBitmapDownloaderTask() {

/*
* Cache-related fields and methods.
*
*
* We use a hard and a soft cache. A soft reference cache is too aggressively cleared by the
* Garbage Collector.
*/
Expand All @@ -290,7 +291,7 @@ public BitmapFetcherTask getBitmapDownloaderTask() {
private final HashMap<Integer, Bitmap> sHardBitmapCache = new LinkedHashMap<Integer, Bitmap>(
HARD_CACHE_CAPACITY / 2, 0.75f, true) {
@Override
protected boolean removeEldestEntry(LinkedHashMap.Entry<Integer, Bitmap> eldest) {
protected boolean removeEldestEntry(Map.Entry<Integer, Bitmap> eldest) {
if (size() > HARD_CACHE_CAPACITY) {
// Entries push-out of hard reference cache are transferred to
// soft reference cache
Expand All @@ -315,7 +316,7 @@ public void run() {

/**
* Adds this bitmap to the cache.
*
*
* @param bitmap
* The newly downloaded bitmap.
*/
Expand Down