Fresco: How to create a CloseableReference?

Created on 13 May 2016  路  2Comments  路  Source: facebook/fresco

i want to create a CloseableReference when i implement a PlatformBitmapFactory
the method .of have two implements, if i use the first one

private PlatformBitmapFactory bmpFactory = new PlatformBitmapFactory() {
        @Override
        public CloseableReference<Bitmap> createBitmap(int width, int height, Bitmap.Config bitmapConfig) {
            CloseableReference<Bitmap> cr = CloseableReference
                    .of(Bitmap.createBitmap(width, height, bitmapConfig));

            return cr;
        }
    };

it would be a compile error:
of(java.io.CloseableReference & android.graphics.Bitmap) in CloseableReference cannot be applied to (android.graphics.Bitmap)

But if i use the second one, i dont know how to make a ResourceReleaser .(actually its a interface , a super class of CloseableReference)

how should i put parameter in .of method?(and what the '&' mean in parameter?)

All 2 comments

Taking a step back, why would you want to implement PlatformBitmapFactory? You should really just be using one of the provided implementations.

It looks like you imported the wrong CloseableReference - you are using java.io.CloseableReference, not the Fresco one.

but the PlatformBitmapFactory do not have a subclass in API...?i want to create the abstract class so i need to implement that method.e e.
i make sure again, there is no java.io.CloseableReference, its a IDE mistake maybe.
i know Bitmap is not a closeable so that i need put SimpleBitmapReleaser.getInstance()when create refer object.Thanks anyway.

BUT a new question comes, i cant put non-closeable to cache.
Fresco.getImagePipelineFactory().getBitmapMemoryCache().cache(key, bmpFactory.createBitmap(width, height, config)));
(even i dont know what work it do)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hanhmh1203 picture hanhmh1203  路  4Comments

ykostova picture ykostova  路  3Comments

bigfreeZhou picture bigfreeZhou  路  4Comments

hbzhzw picture hbzhzw  路  3Comments

eldk picture eldk  路  3Comments