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

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

Closed
blackiedm opened this issue Mar 30, 2015 · 5 comments

Comments

@blackiedm
Copy link

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

@tyronen
Copy link
Contributor

tyronen commented Mar 30, 2015

It is in the GenericDraweeHierarchy class.

@tyronen tyronen closed this as completed Mar 30, 2015
@plamenko
Copy link
Contributor

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

@blackiedm
Copy link
Author

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

@plamenko
Copy link
Contributor

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(...)

@blackiedm
Copy link
Author

@plamenko ok! I get it!

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

3 participants