Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show indeterminate ProgressBar while loading image with Universal Image Loader

I was wondering if there is a mechanism to show a spinning "indeterminate" ProgressBar in place of the image while it's loading with Universal Image Loader.

Right now I'm using the showStubImage() option in DisplayImageOptions to show an image that says "No Image" while the image is being downloaded, but it would be really slick looking if there was a spinning indeterminate ProgressBar on top of the ImageView while the image was downloading.

like image 818
DiscDev Avatar asked Nov 30 '12 22:11

DiscDev


1 Answers

For reference

final View imageLayout = inflater.inflate(R.layout.item_pager_image, null);
final ImageView imageView = ...
final ProgressBar spinner = ...

imageLoader.displayImage(images[position], imageView, options, new SimpleImageLoadingListener() {
    @Override
    public void onLoadingStarted(String imageUri, View view) {
        spinner.setVisibility(View.VISIBLE);
    }

    @Override
    public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
        spinner.setVisibility(View.GONE);
    }

    @Override
    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
        spinner.setVisibility(View.GONE);
    }
});
like image 108
nostra13 Avatar answered Sep 28 '22 08:09

nostra13