fresco icon indicating copy to clipboard operation
fresco copied to clipboard

fresco docs have a problem? 'hierarchy.setPlaceholderImage(R.drawable.placeholderId);' can't find it

Open blackiedm opened this issue 11 years ago • 5 comments

I can't find this method. 'hierarchy.setPlaceholderImage(R.drawable.placeholderId);

blackiedm avatar Mar 30 '15 12:03 blackiedm

It is in the GenericDraweeHierarchy class.

tyronen avatar Mar 30 '15 14:03 tyronen

mSimpleDraweeView.getHierarchy().setPlaceholderImage(...)

plamenko avatar Mar 30 '15 17:03 plamenko

ok!I use GenericDraweeHierarchyBuilder and just find this method setPlaceholderImage(Drawable).

blackiedm avatar Mar 31 '15 00:03 blackiedm

You can specify the placeholder image while building hierarchy:

GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(resources)
    .setPlaceholderImage(...)
    .build()
mDraweeView.setHierarchy(hierarchy);

But, you can also change the placeholder view of the existing hierarchy:

hierarchy.setPlaceholderImage(...);
OR
mDraweeView.getHierarchy().setPlaceholderImage(...);

Note: I suggest that you always use SimpleDraweeView. However, if you are using DraweeView, rather than SimpleDraweeView, make sure that you parametrize your DraweeView.

DraweeView<GenericDraweeHierarchy>

otherwise getHierarchy() won't return GenericDraweeHierarchy, but a more restricted interface DraweeHierarchy. In that case you would have to cast.

 // don't do that, this is not safe. parametrize your view instead
 ((GenericDraweeHierarchy) mDraweeView.getHierarchy()).setPlaceholderImage(...)

plamenko avatar Mar 31 '15 13:03 plamenko

@plamenko ok! I get it!

blackiedm avatar Mar 31 '15 14:03 blackiedm