Skip to content

Instantly share code, notes, and snippets.

@ryands
Forked from koalahamlet/gist:10499015
Last active August 29, 2015 13:59
Show Gist options
  • Save ryands/10499163 to your computer and use it in GitHub Desktop.
Save ryands/10499163 to your computer and use it in GitHub Desktop.
@Override
protected void onResume() {
super.onResume();
loadImageWhenReady(imageView, mPayload);
}
private static void loadImageWhenReady(final ImageView v, final String url) {
v.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Picasso.with(v.getContext())
.load(url)
.resize(imageView.getMeasuredWidth(), imageView.getMeasuredWidth())
.centerInside()
.into(v);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment