I have the following code to load an image in Picasso, using a drawable for the placeholder to display while the image is downloading. What I want though is an animated spin
I made it working in following way:
Created a drawable (found somewhere on the Internet) and put it in the res/drawable:
In my item for the GridView added ProgressBar element:
In Adapter added Target Object with following parameters, where poster and spinner are references to ImageView and ProgressBar:
// Target to show/hide ProgressBar on ImageView
final Target target = new Target() {
@Override
public void onPrepareLoad(Drawable drawable) {
poster.setBackgroundResource(R.color.white);
spinner.setVisibility(View.VISIBLE);
}
@Override
public void onBitmapLoaded(Bitmap photo, Picasso.LoadedFrom from) {
poster.setBackgroundDrawable(new BitmapDrawable(photo));
spinner.setVisibility(View.GONE);
}
@Override
public void onBitmapFailed(Drawable drawable) {
poster.setBackgroundResource(R.color.white);
}
};
Results will be like that on loading - circle is rotating (sorry for this screenshot, but images are appearing too fast): ScreenShot