@Override public void handleMemoryPressure(MemoryPressure level) { if (mDestroyed) { return; } switch (level) { case UI_HIDDEN: handleMemoryPressureUiHidden(); break; case MODERATE: handleMemoryPressureModerate(); break; case CRITICAL: handleMemoryPressureCritical(); break; } }
@Override public void handleMemoryPressure(MemoryPressure level) { if (mDestroyed) { return; } switch(level) { case UI_HIDDEN: handleMemoryPressureUiHidden(); break; case MODERATE: handleMemoryPressureModerate(); break; case CRITICAL: handleMemoryPressureCritical(); break; } }
private void trimMemory(int level) { if (level >= TRIM_MEMORY_COMPLETE) { dispatchMemoryPressure(MemoryPressure.CRITICAL); } else if (level >= TRIM_MEMORY_BACKGROUND || level == TRIM_MEMORY_RUNNING_CRITICAL) { dispatchMemoryPressure(MemoryPressure.MODERATE); } else if (level == TRIM_MEMORY_UI_HIDDEN) { dispatchMemoryPressure(MemoryPressure.UI_HIDDEN); } }
private void dispatchMemoryPressure(MemoryPressure level) { // copy listeners array to avoid ConcurrentModificationException if any of the listeners remove // themselves in handleMemoryPressure() MemoryPressureListener[] listeners = mListeners.toArray(new MemoryPressureListener[mListeners.size()]); for (MemoryPressureListener listener : listeners) { listener.handleMemoryPressure(level); } }
private void trimMemory(int level) { if (level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) { dispatchMemoryPressure(MemoryPressure.CRITICAL); } else if (level >= TRIM_MEMORY_BACKGROUND || level == TRIM_MEMORY_RUNNING_CRITICAL) { dispatchMemoryPressure(MemoryPressure.MODERATE); } }