1

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?

andrehsouza
  • 479
  • 1
  • 5
  • 14

2 Answers2

2

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);
}
Rishabh Srivastava
  • 3,683
  • 2
  • 30
  • 58
0

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

stringURL.replaceAll(" ", "%20");
Arndroid
  • 314
  • 3
  • 13