@Override @DebugLog public void onTrimMemory(int level) { if (level >= TRIM_MEMORY_BACKGROUND) { mL2Cache.onTrimMemory(); } }
/** Pulls bitmap from diskcache */ private @Nullable ParcelFileDescriptor createPipe(final ArtInfo artInfo) { final byte[] bytes = mL2Cache.getBytes(artInfo.cacheKey()); if (bytes == null) { return null; } try { final ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe(); final OutputStream out = new ParcelFileDescriptor.AutoCloseOutputStream(pipe[1]); final ParcelFileDescriptor in = pipe[0]; final Scheduler.Worker worker = mScheduler.createWorker(); worker.schedule( new Action0() { @Override public void call() { try { IOUtils.write(bytes, out); out.flush(); } catch (IOException e) { Timber.w("createPipe(e=%s) for %s", e.getMessage(), artInfo); } finally { IOUtils.closeQuietly(out); worker.unsubscribe(); } } }); return in; } catch (IOException e) { Timber.e(e, "createPipe() for %s", artInfo); return null; } }