public Drawable getDrawable(String source) { File output = null; try { output = File.createTempFile("image", ".jpg", dir); HttpRequest request = createRequest(source); if (!request.ok()) throw new IOException("Unexpected response code: " + request.code()); request.receive(output); Bitmap bitmap = ImageUtils.getBitmap(output, width, MAX_VALUE); if (bitmap == null) return loading.getDrawable(source); BitmapDrawable drawable = new BitmapDrawable(context.getResources(), bitmap); drawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight()); return drawable; } catch (IOException e) { return loading.getDrawable(source); } catch (HttpRequestException e) { return loading.getDrawable(source); } finally { if (output != null) output.delete(); } }