Universal Image Loader did not apply the displayImageOptions in loadImage

sithmal_ picture sithmal_ · Jun 16, 2013 · Viewed 8k times · Source

Universal Image Loader did not apply the display image options in the imageLoader.loadImage This is my code

DisplayImageOptions options = new DisplayImageOptions.Builder()
        .showStubImage(R.drawable.loading_image_background)
        .showImageForEmptyUri(R.drawable.ic_launcher)
        .showImageOnFail(R.drawable.loading_image_background)
        .cacheInMemory()
        .cacheOnDisc()
        .bitmapConfig(Bitmap.Config.RGB_565)
        .displayer(new RoundedBitmapDisplayer (20))
        .build();

ImageSize targetSize = new ImageSize(50, 50);
        imageLoader.loadImage(image_poster_url, targetSize, options,
                new SimpleImageLoadingListener() {
                    @Override
                    public void onLoadingComplete(String imageUri,
                            View view, Bitmap loadedImage) {
                        holder.posterImage.setImageBitmap(loadedImage);
                    }
                });

Image is re sized and display perfectly in listview. but the display option(rounded bitmap diplayer)are does not applied to the image. any suggestions?

Answer

nostra13 picture nostra13 · Jun 17, 2013

.displayer(...) is applied only for ImageLoader.displayImage(...) calls. For ImageLoader.loadImage(...) you can use displayers yourself directly:

ImageSize targetSize = new ImageSize(50, 50);
imageLoader.loadImage(image_poster_url, targetSize, options,
            new SimpleImageLoadingListener() {
                @Override
                public void onLoadingComplete(String imageUri,
                        View view, Bitmap loadedImage) {
                    new RoundedBitmapDisplayer(20).display(holder.posterImage);
                }
            });