title: ListView asynchronous image loading strategy
body: <p>I currently have a ListView with a custom adapter that gets information describing the content of the rows asynchronously. Part of each row is an image URL, that I'm planning to download asynchronously and then display.</p>
  
  <p>My current plan for a strategy to download these images is:</p>
  
  <ul>
  <li>Keep a cache of soft references to downloaded Bitmap objects.</li>
  <li>When a getView() is called and the bitmap is in the cache, set the bitmap for the ImageView directly.</li>
  <li>If the bitmap isn't in the cache, start loading it in a separate thread, after the download is complete add it to the cache and call notifyDataSetChanged() on the adapter.</li>
  </ul>
  
  <p>I am also planning to kill pending downloads when the Activity object owning the ListView's onDestroy()-method (Or possibly even in the onPause()-method) is called, but most importantly I want to kill the download of pending images when the row goes off screen. I might only actually cancel the download after a short delay, so it can be resumed without wasting bandwidth if the row comes on-screen quickly again.</p>
  
  <p>I, however, am unsure about a few things:</p>
  
  <ul>
  <li>What is the best way to detect when a row goes off-screen so I can cancel the download?</li>
  <li>Is calling notifyDataSetChanged() the best thing to do after the download has completed or is there a better way?</li>
  </ul>
  
  <p>Also any comments on the whole strategy would be appreciated.</p>