In my android application, I am using universal image loader to show images from url. During loading of image I want a gif image to be shown. But the gif image added is not showing any animation. Here is my code to display image.
private static final DisplayImageOptions.Builder DEFAULT_DISPLAY_IMAGE_OPTIONS_BUIDLER = new DisplayImageOptions.Builder()
.imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)
.displayer(new FadeInBitmapDisplayer(300, true, false, false))
.showImageForEmptyUri(R.drawable.default_image)
.showImageOnLoading(R.drawable.loadingx)
.showImageOnFail(sampleapp.sample.com.sampleapp.R.drawable.default_image).cacheOnDisk(true)
.cacheInMemory(true).bitmapConfig(Config.ARGB_8888);
what changes should I make to show an animated gif image during loading time image
Try to use glide for gif image loading...
Glide
.with( context )
.load( gifUrl )
.asGif()
.error( R.drawable.full_cake )
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.into( imageViewGif );
To understand follow the link - here
If you want to use ProgressBar then create a method like below -
public void loadImage(Context context, String url, ImageView img, final ProgressBar eProgressBar) {
eProgressBar.setVisibility(View.VISIBLE);
Glide.with(context)
.load(url)
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
eProgressBar.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
eProgressBar.setVisibility(View.GONE);
return false;
}
})
.crossFade()
.error(R.drawable.placeholder_image)
.into(img);
}
Use this method and pass your parameter value through it... :)