當前位置: 首頁>>代碼示例>>Java>>正文


Java ComponentCallbacks2.TRIM_MEMORY_COMPLETE屬性代碼示例

本文整理匯總了Java中android.content.ComponentCallbacks2.TRIM_MEMORY_COMPLETE屬性的典型用法代碼示例。如果您正苦於以下問題:Java ComponentCallbacks2.TRIM_MEMORY_COMPLETE屬性的具體用法?Java ComponentCallbacks2.TRIM_MEMORY_COMPLETE怎麽用?Java ComponentCallbacks2.TRIM_MEMORY_COMPLETE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.content.ComponentCallbacks2的用法示例。


在下文中一共展示了ComponentCallbacks2.TRIM_MEMORY_COMPLETE屬性的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
        }
    }
}
 
開發者ID:nvllsvm,項目名稱:Audinaut,代碼行數:20,代碼來源:DownloadService.java

示例2: onTrimMemory

@Override
public void onTrimMemory(int level) {
    switch(level) {
        // Trims memory when it reaches a moderate level and the session is inactive
        case ComponentCallbacks2.TRIM_MEMORY_MODERATE:
        case ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE:
            if(session.isActive()) break;

        // Trims memory when it reaches a critical level
        case ComponentCallbacks2.TRIM_MEMORY_COMPLETE:
        case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL:

            Log.w("MusicControl", "Control resources are being removed due to system's low memory (Level: " + level + ")");
            destroy();
            break;
    }
}
 
開發者ID:tanguyantoine,項目名稱:react-native-music-control,代碼行數:17,代碼來源:MusicControlModule.java

示例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);
		}
	}
}
 
開發者ID:popeen,項目名稱:Popeens-DSub,代碼行數:20,代碼來源:DownloadService.java

示例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;
    }
}
 
開發者ID:ArthurHub,項目名稱:Android-Fast-Image-Loader,代碼行數:18,代碼來源:MemoryPoolImpl.java

示例5: trimMemory

/**
 * @inheritDoc
 */
@Override
public void trimMemory(int level) {

    if(level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
        emptyCache(); //dump the cache
    }
    else if (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE){
        trimCache(0.5f); // trim to half the max size
    }
    else if (level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND){
        trimCache(0.7f); // trim to one seventh max size
    }
    else if (level >= ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL){
        trimCache(0.2f); // trim to one fifth max size
    }
}
 
開發者ID:patrick-doyle,項目名稱:CrossBow,代碼行數:19,代碼來源:DefaultImageCache.java

示例6: 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";
    }
}
 
開發者ID:panpf,項目名稱:sketch,代碼行數:23,代碼來源:SketchUtils.java

示例7: maybeNotifyMemoryPresure

public static void maybeNotifyMemoryPresure(int level) {
    if (level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
        nativeOnMemoryPressure(MemoryPressureLevel.CRITICAL);
    } else if (level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND
            || level == ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) {
        // Don't notifiy on TRIM_MEMORY_UI_HIDDEN, since this class only
        // dispatches actionable memory pressure signals to native.
        nativeOnMemoryPressure(MemoryPressureLevel.MODERATE);
    }
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:10,代碼來源:MemoryPressureListener.java

示例8: trimMemory

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);
  }
}
 
開發者ID:john1jan,項目名稱:ReactNativeSignatureExample,代碼行數:7,代碼來源:MemoryPressureRouter.java

示例9: 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;
    }
}
 
開發者ID:jrconlin,項目名稱:mc_backup,代碼行數:36,代碼來源:MemoryMonitor.java

示例10: maybeNotifyMemoryPresure

private static void maybeNotifyMemoryPresure(int level) {
    if (level == ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
        nativeOnMemoryPressure(MemoryPressureLevelList.MEMORY_PRESSURE_CRITICAL);
    } else if (level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND ||
            level == ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) {
        nativeOnMemoryPressure(MemoryPressureLevelList.MEMORY_PRESSURE_MODERATE);
    }
}
 
開發者ID:openresearch,項目名稱:android-chromium-view,代碼行數:8,代碼來源:MemoryPressureListener.java

示例11: maybeNotifyMemoryPresure

public static void maybeNotifyMemoryPresure(int level) {
    if (level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
        nativeOnMemoryPressure(MemoryPressureLevelList.MEMORY_PRESSURE_CRITICAL);
    } else if (level >= ComponentCallbacks2.TRIM_MEMORY_BACKGROUND ||
            level == ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL) {
        // Don't notifiy on TRIM_MEMORY_UI_HIDDEN, since this class only
        // dispatches actionable memory pressure signals to native.
        nativeOnMemoryPressure(MemoryPressureLevelList.MEMORY_PRESSURE_MODERATE);
    }
}
 
開發者ID:morristech,項目名稱:android-chromium,代碼行數:10,代碼來源:MemoryPressureListener.java

示例12: onTrimMemory

public void onTrimMemory(int level) {
    if (level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE) {
        mArtworkHelper.evictL1();
        saveState(true);
    }
}
 
開發者ID:OpenSilk,項目名稱:Orpheus,代碼行數:6,代碼來源:PlaybackService.java


注:本文中的android.content.ComponentCallbacks2.TRIM_MEMORY_COMPLETE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。