picview/src/com/google/android/apps/picview/request/CachedImageFetcher.java
public Bitmap cachedFetchImage(URL url) {
    // Make sure we have a URL object that we can synchronize on.
    url = getSynchronizableInstance(url);

    // Synchronize per URL.
    synchronized (url) {
      // Get it from memory, if we still have it.
      if (cache.containsKey(url) && cache.get(url).get() != null) {
        return cache.get(url).get();
      }

      // If it's not in memory, try to load it from file system.
      Bitmap bitmap = fileSystemCache.get(url);

      // If it is also not found in the file system cache, try to fetch it
      // from the network.
      if (bitmap == null) {
        bitmap = fetchImageFromWeb(url);
        if (bitmap != null) {
          fileSystemCache.asyncPut(url, "TODO", bitmap);
        }
      }
      if (bitmap != null) {
        cache.put(url, new SoftReference<Bitmap>(bitmap));
      }
      return bitmap;
    }
  }
/**
   * Performs a cached fetch. If the image is in one of the caches (file-system
   * or in-memory), this version is returned. If the image could not be found in
   * cache, it's fetched and automatically put into both caches.
   */
Performs a cached fetch. If the image is in one of the caches (file-system
or in-memory), this version is returned. If the image could not be found in
cache, it's fetched and automatically put into both caches.
Performs a cached fetch . If the image is in one of the caches ( file - system or in - memory ) this version is returned . If the image could not be found in cache it ' s fetched and automatically put into both caches .
public Bitmap cachedFetchImage(URL url) {
    url = getSynchronizableInstance(url);
    synchronized (url) {
      if (cache.containsKey(url) && cache.get(url).get() != null) {
        return cache.get(url).get();
      }
      Bitmap bitmap = fileSystemCache.get(url);
      if (bitmap == null) {
        bitmap = fetchImageFromWeb(url);
        if (bitmap != null) {
          fileSystemCache.asyncPut(url, "TODO", bitmap);
        }
      }
      if (bitmap != null) {
        cache.put(url, new SoftReference<Bitmap>(bitmap));
      }
      return bitmap;
    }
  }
public Bitmap cachedFetchImage ( URL url ) { url = getSynchronizableInstance ( url ) ; synchronized ( url ) { if ( cache . containsKey ( url ) && cache . get ( url ) . get ( ) != null ) { return cache . get ( url ) . get ( ) ; } Bitmap bitmap = fileSystemCache . get ( url ) ; if ( bitmap == null ) { bitmap = fetchImageFromWeb ( url ) ; if ( bitmap != null ) { fileSystemCache . asyncPut ( url , "TODO" , bitmap ) ; } } if ( bitmap != null ) { cache . put ( url , new SoftReference < Bitmap > ( bitmap ) ) ; } return bitmap ; } }
Performs a cached fetch.
Performs a cached fetch .
// Make sure we have a URL object that we can synchronize on. // Synchronize per URL. // Get it from memory, if we still have it. // If it's not in memory, try to load it from file system. // If it is also not found in the file system cache, try to fetch it // from the network.