本文整理匯總了Java中android.content.ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN屬性的典型用法代碼示例。如果您正苦於以下問題:Java ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN屬性的具體用法?Java ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN怎麽用?Java ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.content.ComponentCallbacks2
的用法示例。
在下文中一共展示了ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN屬性的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onTrimMemory
@Override
public void onTrimMemory(int level) {
ImageLoader imageLoader = SubsonicActivity.getStaticImageLoader(this);
if(imageLoader != null) {
Log.i(TAG, "Memory Trim Level: " + level);
if (level < ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) {
imageLoader.onLowMemory(0.75f);
} else if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW) {
imageLoader.onLowMemory(0.50f);
} else if(level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE) {
imageLoader.onLowMemory(0.25f);
}
} else if (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE) {
imageLoader.onLowMemory(0.25f);
} else if(level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
imageLoader.onLowMemory(0.75f);
}
}
}
示例2: registerComponentCallbacks
/**
* Register ComponentCallbacks2 to receive memory pressure signals.
*
*/
@CalledByNative
private static void registerComponentCallbacks() {
sCallbacks = new ComponentCallbacks2() {
@Override
public void onTrimMemory(int level) {
if (level != ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
nativeOnTrimMemory(level);
}
}
@Override
public void onLowMemory() {
// Don't support old onLowMemory().
}
@Override
public void onConfigurationChanged(Configuration config) {
}
};
ContextUtils.getApplicationContext().registerComponentCallbacks(sCallbacks);
}
示例3: onTrimMemory
@Override
public void onTrimMemory(int level) {
ImageLoader imageLoader = SubsonicActivity.getStaticImageLoader(this);
if(imageLoader != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
Log.i(TAG, "Memory Trim Level: " + level);
if (level < ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) {
imageLoader.onLowMemory(0.75f);
} else if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW) {
imageLoader.onLowMemory(0.50f);
} else if(level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE) {
imageLoader.onLowMemory(0.25f);
}
} else if (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE) {
imageLoader.onLowMemory(0.25f);
} else if(level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
imageLoader.onLowMemory(0.75f);
}
}
}
示例4: onTrimMemory
@Override
public void onTrimMemory(int level) {
switch (level) {
case ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN:
releaseUnUsedBitmaps(3);
break;
case ComponentCallbacks2.TRIM_MEMORY_BACKGROUND:
releaseUnUsedBitmaps(1);
break;
case ComponentCallbacks2.TRIM_MEMORY_MODERATE:
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE:
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL:
case ComponentCallbacks2.TRIM_MEMORY_COMPLETE:
releaseUnUsedBitmaps(0);
break;
}
}
示例5: getTrimLevelName
/**
* 獲取修剪級別的名稱
*/
public static String getTrimLevelName(int level) {
switch (level) {
case ComponentCallbacks2.TRIM_MEMORY_COMPLETE:
return "COMPLETE";
case ComponentCallbacks2.TRIM_MEMORY_MODERATE:
return "MODERATE";
case ComponentCallbacks2.TRIM_MEMORY_BACKGROUND:
return "BACKGROUND";
case ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN:
return "UI_HIDDEN";
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL:
return "RUNNING_CRITICAL";
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
return "RUNNING_LOW";
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE:
return "RUNNING_MODERATE";
default:
return "UNKNOWN";
}
}
示例6: onTrimMemory
@Override
public void onTrimMemory(int level) {
super.onTrimMemory(level);
if (level >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
// The widget preview db can result in holding onto over
// 3MB of memory for caching which isn't necessary.
SQLiteDatabase.releaseMemory();
// This clears all widget bitmaps from the widget tray
// TODO(hyunyoungs)
}
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onTrimMemory(level);
}
}
示例7: onTrimMemory
/**
* Memory availability callback. TRIM_MEMORY_UI_HIDDEN means the app's UI is no longer visible.
* This is triggered when the user navigates out of the app and primarily used to free resources used by the UI.
* http://developer.android.com/training/articles/memory.html
*/
@Override
public void onTrimMemory(final int i) {
if(i == ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
this.koala.trackAppClose();
this.isInBackground = true;
}
}
示例8: onTrimMemory
@Override
public void onTrimMemory(final int level) {
if (level == ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
// We're in the Background
isInBackground = true;
String lastActivityString = AppPrefs.getLastActivityStr();
ActivityId lastActivity = ActivityId.getActivityIdFromName(lastActivityString);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("last_visible_screen", lastActivity.toString());
if (mApplicationOpenedDate != null) {
Date now = new Date();
properties.put("time_in_app", DateTimeUtils.secondsBetween(now, mApplicationOpenedDate));
mApplicationOpenedDate = null;
}
AnalyticsTracker.track(AnalyticsTracker.Stat.APPLICATION_CLOSED, properties);
AnalyticsTracker.endSession(false);
} else {
isInBackground = false;
}
boolean evictBitmaps = false;
switch (level) {
case TRIM_MEMORY_COMPLETE:
case TRIM_MEMORY_MODERATE:
case TRIM_MEMORY_RUNNING_MODERATE:
case TRIM_MEMORY_RUNNING_CRITICAL:
case TRIM_MEMORY_RUNNING_LOW:
evictBitmaps = true;
break;
default:
break;
}
if (evictBitmaps && mBitmapCache != null) {
mBitmapCache.evictAll();
}
}
示例9: onTrimMemory
@Override
public void onTrimMemory(int level) {
if (ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN == level) {
TP.i("Application goes to background");
idleWatcher.reloadInterval();
scheduler.scheduleImmediate( idleWatcher );
}
}
示例10: onTrimMemory
public void onTrimMemory(int level) {
Log.d(LOGTAG, "onTrimMemory() notification received with level " + level);
if (Versions.preICS) {
// This won't even get called pre-ICS.
return;
}
if (level == ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
// We seem to get this just by entering the task switcher or hitting the home button.
// Seems bogus, because we are the foreground app, or at least not at the end of the LRU list.
// Just ignore it, and if there is a real memory pressure event (CRITICAL, MODERATE, etc),
// we'll respond appropriately.
return;
}
switch (level) {
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL:
case ComponentCallbacks2.TRIM_MEMORY_MODERATE:
// TRIM_MEMORY_MODERATE is the highest level we'll respond to while backgrounded
increaseMemoryPressure(MEMORY_PRESSURE_HIGH);
break;
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE:
increaseMemoryPressure(MEMORY_PRESSURE_MEDIUM);
break;
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
increaseMemoryPressure(MEMORY_PRESSURE_LOW);
break;
case ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN:
case ComponentCallbacks2.TRIM_MEMORY_BACKGROUND:
increaseMemoryPressure(MEMORY_PRESSURE_CLEANUP);
break;
default:
Log.d(LOGTAG, "Unhandled onTrimMemory() level " + level);
break;
}
}
示例11: onTrimMemory
@Override
public void onTrimMemory(int level) {
super.onTrimMemory(level);
if (level >= ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
// The widget preview db can result in holding onto over
// 3MB of memory for caching which isn't necessary.
SQLiteDatabase.releaseMemory();
// This clears all widget bitmaps from the widget tray
if (mAppsCustomizeTabHost != null) {
mAppsCustomizeTabHost.trimMemory();
}
}
}
示例12: onTrimMemory
@Override
public void onTrimMemory(int i) {
if (i == ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
Logger.d(TAG, "Application is in the background");
isInBackground = true;
try {
Tracker tracker = Tracker.instance();
int index = backgroundIndex.addAndGet(1);
// Update Session
if (tracker.getSession() != null) {
tracker.getSession().setIsBackground(true);
}
// Send Background Event
if (tracker.getLifecycleEvents()) {
Map<String, Object> data = new HashMap<>();
Util.addToMap(Parameters.APP_BACKGROUND_INDEX, index, data);
tracker.track(SelfDescribing.builder()
.eventData(new SelfDescribingJson(TrackerConstants.APPLICATION_BACKGROUND_SCHEMA, data))
.build()
);
}
} catch (Exception e) {
Logger.e(TAG, e.getMessage());
}
}
}
示例13: onTrimMemory
@Override public void onTrimMemory(int level) {
super.onTrimMemory(level);
if (level == ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN) {
isNeedPassCodeConfirmation = true;
}
}