Fresco: Images Dissapear After Scrolling Recylcerview
Solution 1:
From the logcat you can see that you are using the same instance of DraweeHierarchy with multiple controllers. Do not do that.
AbstractDraweeController: controller c077610 8: setHierarchy:com.facebook.drawee.generic.GenericDraweeHierarchy@d36ab12AbstractDraweeController:controller87baf9cnull->9:initializeAbstractDraweeController: controller c077610 8: setHierarchy:nullAbstractDraweeController: controller 87baf9c 9: setHierarchy:com.facebook.drawee.generic.GenericDraweeHierarchy@d36ab12
As explained in the documentation, do not re-use DraweeHierarchies
. Each DraweeView
needs to have its own instance of a DraweeHierarchy
. Do not store the hierarchy in mHierarchy
, just set the hierarchy to the view.
Also, each view needs its own hierarchy but that doesn't mean you have to build a new hierarchy each time you want to set a new image. You build the hierarchy only once, when you create the view and that's it. Later on when you need to set/change an image, just set a new controller to the view.
From your example it seems that you do not need to build the hierarchy programmatically at all. You can specify both the fade duration and the placeholder in XML. Btw, default value for fade-duration is 300ms so you can actually omit that part too.
So, just remove the code that builds and sets the hierarchy (mDraweeView.setHierarchy(mHierarchy)
).
If you are only using the Uri without any additional options, you do not need to build the controller. Just do mDraweeView.setImageURI(uri)
and SimpleDraweeView
will create the controller for you.
Post a Comment for "Fresco: Images Dissapear After Scrolling Recylcerview"