Source:
public Bitmap getImage(String url) throws CantGetImageException { final File file = storedFile(url); byte[] bytes = null; if (null == file || !file.exists()) { try { final SSLSocketFactory factory = mConfig.getSSLSocketFactory(); bytes = mPoster.performRequest(url, null, factory); } catch (IOException e) { throw new CantGetImageException("Can't download bitmap", e); } catch (RemoteService.ServiceUnavailableException e) { throw new CantGetImageException("Couldn't download image due to service availability", e); } } final Bitmap bitmap; if (null != bytes) { if (null != file && bytes.length < MAX_BITMAP_SIZE) { OutputStream out = null; try { out = new FileOutputStream(file); out.write(bytes); } catch (FileNotFoundException e) { throw new CantGetImageException("It appears that ImageStore is misconfigured, or disk storage is unavailable- can't write to bitmap directory", e); } catch (IOException e) { throw new CantGetImageException("Can't store bitmap", e); } finally { if (null != out) { try { out.close(); } catch (IOException e) { Log.w(LOGTAG, "Problem closing output file", e); } } } } bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); if (null == bitmap) { throw new CantGetImageException("Downloaded data could not be interpreted as a bitmap"); } } else { BitmapFactory.Options option = new BitmapFactory.Options(); option.inJustDecodeBounds = true; BitmapFactory.decodeFile(file.getAbsolutePath(), option); Long imageSize = new Long(option.outHeight * option.outWidth); Long freeMemory = Runtime.getRuntime().freeMemory(); if (imageSize > freeMemory) { throw new CantGetImageException("Do not have enough memory for the image"); } option.inJustDecodeBounds = false; bitmap = BitmapFactory.decodeFile(file.getAbsolutePath(), option); if (null == bitmap) { final boolean ignored = file.delete(); throw new CantGetImageException("Bitmap on disk can't be opened or was corrupt"); } } return bitmap; }

Target:
public Bitmap getImage(String url) throws CantGetImageException { final File file = storedFile(url); byte[] bytes = null; if (null == file || !file.exists()) { try { final SSLSocketFactory factory = mConfig.getSSLSocketFactory(); bytes = mPoster.performRequest(url, null, factory); } catch (IOException e) { throw new CantGetImageException("Can't download bitmap", e); } catch (RemoteService.ServiceUnavailableException e) { throw new CantGetImageException("Couldn't download image due to service availability", e); } } final Bitmap bitmap; if (null != bytes) { if (null != file && bytes.length < MAX_BITMAP_SIZE) { OutputStream out = null; try { out = new FileOutputStream(file); out.write(bytes); } catch (FileNotFoundException e) { throw new CantGetImageException("It appears that ImageStore is misconfigured, or disk storage is unavailable- can't write to bitmap directory", e); } catch (IOException e) { throw new CantGetImageException("Can't store bitmap", e); } finally { if (null != out) { try { out.close(); } catch (IOException e) { Log.w(LOGTAG, "Problem closing output file", e); } } } } bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); if (null == bitmap) { throw new CantGetImageException("Downloaded data could not be interpreted as a bitmap"); } } else { BitmapFactory.Options option = new BitmapFactory.Options(); option.inJustDecodeBounds = true; BitmapFactory.decodeFile(file.getAbsolutePath(), option); Long imageSize = new Long(option.outHeight * option.outWidth); Long freeMemory = Runtime.getRuntime().freeMemory(); if (imageSize > freeMemory) { throw new CantGetImageException("Do not have enough memory for the image"); } bitmap = BitmapFactory.decodeFile(file.getAbsolutePath()); if (null == bitmap) { final boolean ignored = file.delete(); throw new CantGetImageException("Bitmap on disk can't be opened or was corrupt"); } } return bitmap; }