andrehsouza
andrehsouza

Reputation: 519

Image not displaying sometimes with Universal Image Loader

I have an activity that contains an ImageView, I call this activity every time I want to open an image for better viewing. The problem is that sometimes my ImageLoader works fine but sometimes it does not display the image. I use universal-image-loader-1.8.4.jar and android 4.2.2

When my ImageLoader not display my image I get in the log:

ImageView is reused for another image. Task is cancelled.

My configuration:

ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
.enableLogging()
.threadPriority(Thread.MAX_PRIORITY)
.build();       
imageLoader.init(config);

My method:

private void getImage() {
 Bundle bundle = getIntent().getExtras();
 String dir= bundle.getString("poster");
 imageLoader.displayImage(dir, imgPoster);
}

Can anyone help me?

Upvotes: 1

Views: 3755

Answers (2)

xiqiangxiaoguai
xiqiangxiaoguai

Reputation: 36

I meet the problem too, this is because you want to set the adapter or show the image before the activity was created.

Try this:

String dir = "";

Handler mHandler = new Handler(){
        public void handleMessage(android.os.Message msg) {
            switch(msg.what){
                case 0:
                    imageLoader.displayImage(dir, imgPoster);
                    break;
            }
        };
    };

private void getImage() {
       Bundle bundle = getIntent().getExtras();
       dir= bundle.getString("poster");
       mHandler.sendEmptyMessageDelayed(0,500);
}

Upvotes: 2

Arndroid
Arndroid

Reputation: 314

Try and check if the image url's have spaces in them. In that case, replace the spaces with "%20".

stringURL.replaceAll(" ", "%20");

Upvotes: 0

Related Questions