public void save(String url, Drawable drawable) throws IOException { String urlBase64 = getBase64(url); Bitmap bitmap = drawableToBitmap(drawable); OutputStream stream = cacheManager.cacheDataStream(urlBase64); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); stream.close(); }
public Drawable load(String url) throws IOException { String urlBase64 = getBase64(url); InputStream stream = cacheManager.retrieveDataStream(urlBase64); if (stream == null) { return null; } Drawable drawable = BitmapDrawable.createFromStream(stream, null); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); return drawable; }
public boolean inCache(String url) throws UnsupportedEncodingException { String urlBase64 = getBase64(url); return cacheManager.getFile(urlBase64).exists(); }