title: Load image and set it when it's finish loading
body: <p>I have an <code>AsyncTask</code> that gets a URL as a parameter, and returns a <code>Bitmap</code> of an image from that URL when it finishes. When I start the activity, I want to show a text (instead of the image) saying "loading...", run the <code>ImageFetcher</code> in the background, and when it finishes, set the image to the <code>ImageView</code>.   </p>
  
  <p>The problem is, if I run:</p>
  
  <pre><code>ivPoster.setImageBitmap(imgFetcher.execute(m.getPosterUrl()).get());
  </code></pre>
  
  <p>It doesn't load the entire activity until the image is loaded. It skips frames.   </p>
  
  <p>So I set an on finish listener on the task, that returns the bitmap, and tried to set the image after the bitmap is retrieved: </p>
  
  <pre><code>imgFetcher.setOnFinishListener(new OnTaskFinished() {
  
      @Override
      public void onFinish(Bitmap bm) {
          // hide the loading image text
          tvLoading.setVisibility(View.INVISIBLE);
          // place the image
          ivPoster.setImageBitmap(bm);
      }
  });
  
  imgFetcher.execute(m.getPosterUrl());
  </code></pre>
  
  <p>Yet it still skips frames and 'does too much work on the main thread'.<br>
  How can I prevent the frame skipping?</p>