I have custom listview. In listview contain 200 items. When i am scrolling fast from top to bottom Or bottom to top listview showing wrong image. If i am scrolling slowly then its work fine.
SimpleDraweeView in XML :
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/fake_image_list_group"
android:layout_width="match_parent"
android:layout_height="@dimen/note_list_item_height"
android:background="@android:color/transparent"
android:contentDescription="@string/app_name" />
Set Image URI to SimpleDraweeView :
GenericDraweeHierarchy hierarchy = setHierarchyForDraweeView(mImageView, 300);
hierarchy.setPlaceholderImage(new AsyncColorDrawable(context.getResources()));
hierarchy.setFailureImage(mContext.getResources().getDrawable(R.drawable.broken_image_black));
ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(new File(mPath/*local path*/)))
.setResizeOptions(new ResizeOptions(width, height))
.setLocalThumbnailPreviewsEnabled(true)
.build();
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
.setImageRequest(imageRequest)
.setOldController(mImageView.getController())
.setAutoPlayAnimations(false)
.build();
mImageView.setController(draweeController);
SetHierarchyForDraweeView Function :
private GenericDraweeHierarchy setHierarchyForDraweeView(SimpleDraweeView draweeView, int duration) {
if (draweeView != null) {
if (draweeView.getHierarchy() == null) {
GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(mContext.getResources());
GenericDraweeHierarchy hierarchy = builder
.setFadeDuration(duration)
.setPlaceholderImage(new AsyncColorDrawable(mContext.getResources()))
.setFailureImage(mContext.getResources().getDrawable(R.drawable.broken_image_black))
.build();
draweeView.setHierarchy(hierarchy);
} else {
GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
hierarchy.setFadeDuration(duration);
return hierarchy;
}
}
return null;
}
AsyncColorDrawable Class :
private class AsyncColorDrawable extends ColorDrawable {
public AsyncColorDrawable(Resources res) {
super(res.getColor(R.color.application_container_background_color));
}
}
If i did anything wrong please figure it out. Thanks for advance.