I have gone through many questions similar to mine of images flickering problem. I am not able to correct it. Being a beginner,I am not able to understand what to do.
Here is my code.. where I set thumbnail for a image.
private void setThumbnail(final ContentResolver contentResolver, final ViewHolder aHolder,
final Uri uri) {
new AsyncTask<String, Void, Bitmap>() {
@Override
protected Bitmap doInBackground(String... params) {
Bitmap result = mBitmapCache.get(uri.toString());
if (result == null)
return getThumbnail(contentResolver, uri);
else
return result;
}
@Override
protected void onPostExecute(Bitmap result) {
if (uri != null && result != null) {
// Log.d(TAG, "setThumbnail result not null");
// Log.d(TAG, "uri= "+uri);
// Log.d(TAG, "aHolder.mMediaUri= "+aHolder.mMediaUri);
mBitmapCache.put(uri.toString(), result);
// confirm the holder is still paired to this uri
if (!uri.equals(aHolder.mMediaUri)) {
return;
}
// set the thumbnail
ImageLoader imageLoader=ImageLoader.getInstance();
imageLoader.init(ImageLoaderConfiguration.createDefault(getContext()));
DisplayImageOptions options = new DisplayImageOptions.Builder()
// .showImageForEmptyUri(R.drawable.ic_empty)
// .showImageOnFail(R.drawable.ic_error)
.resetViewBeforeLoading(true).cacheOnDisk(true)
.imageScaleType(ImageScaleType.EXACTLY)
.bitmapConfig(Bitmap.Config.RGB_565).considerExifParams(true)
.cacheInMemory(true)
.displayer(new FadeInBitmapDisplayer(300)).build();
imageLoader.displayImage(uri.toString(), aHolder.mMediaThumbnail, options);
// aHolder.mMediaThumbnail.setImageBitmap(result);
} else {
// Log.d(TAG, "setThumbnail result null");
}
}
}.execute();
}