malevich
malevich copied to clipboard
Wrong behavior in ListView
Hi there, I faced in issue with using this library with ListView or RecyclerView: if listView have a few of duplicate images on first page than images goest to the wrong imageView. If you use
public Bitmap onImageDecoded(String data, int reqWidth, int reqHeight, Bitmap bitmap) {
return Malevich.Utils.getCircleBitmap(bitmap);
}
than app crashes with java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap
.
I can't found the reason of issue, but for fix this you can disable memoryCache:
ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(context, "images");
cacheParams.memoryCacheEnabled = false;
malevich = new Malevich.Builder(context).CacheParams(cacheParams).build();
Minimal sample to reproduce an issue: https://github.com/akadatsky/testMalevich
Screenshot actual VS expected:
Oh( I am not sure, may be add some checks on recycled, before rendering? pseudocode:
if (bitmap != null && !bitmap.isRecycled()) do some with bitmap
@recoilme for fix crash I found workaround:
public Bitmap onImageDecoded(String data, int reqWidth, int reqHeight, Bitmap bitmap) {
Bitmap bitmapCopy = bitmap.copy(bitmap.getConfig(), true);
return Malevich.Utils.getCircleBitmap(bitmapCopy);
}
But I still have an issues with that images go to wrong imageView (like on screenshot). Only on first 7 items. If I start scrolling it becomes ok. I feel that it happens because for first 7 items load called at the same time and there some problems with multithreading.