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

Wrong behavior in ListView #6

Open
akadatsky opened this issue Feb 9, 2017 · 2 comments
Open

Wrong behavior in ListView #6

akadatsky opened this issue Feb 9, 2017 · 2 comments

Comments

@akadatsky
Copy link

akadatsky commented Feb 9, 2017

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:
ex

@akadatsky akadatsky reopened this Feb 9, 2017
@recoilme
Copy link
Owner

recoilme commented Feb 9, 2017

Oh( I am not sure, may be add some checks on recycled, before rendering?
pseudocode:

if (bitmap != null && !bitmap.isRecycled())  do some with bitmap

@akadatsky
Copy link
Author

akadatsky commented Feb 9, 2017

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants