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


Java LruMemoryCache類代碼示例

本文整理匯總了Java中com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache的典型用法代碼示例。如果您正苦於以下問題:Java LruMemoryCache類的具體用法?Java LruMemoryCache怎麽用?Java LruMemoryCache使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LruMemoryCache類屬於com.nostra13.universalimageloader.cache.memory.impl包,在下文中一共展示了LruMemoryCache類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initImageLoader

import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache; //導入依賴的package包/類
@SuppressWarnings("deprecation")
private void initImageLoader() {
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            this)
            .memoryCacheExtraOptions(480, 800)
            // default = device screen dimensions
            .threadPoolSize(3)
            // default
            .threadPriority(Thread.NORM_PRIORITY - 1)
            // default
            .tasksProcessingOrder(QueueProcessingType.FIFO)
            // default
            .denyCacheImageMultipleSizesInMemory()
            .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
            .memoryCacheSize(2 * 1024 * 1024).memoryCacheSizePercentage(13) // default
            .discCacheSize(50 * 1024 * 1024) // 緩衝大小
            .discCacheFileCount(100) // 緩衝文件數目
            .discCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
            .imageDownloader(new BaseImageDownloader(this)) // default
            .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
            .writeDebugLogs().build();

    // 2.單例ImageLoader類的初始化
    ImageLoader imageLoader = ImageLoader.getInstance();
    imageLoader.init(config);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:MainActivity.java

示例2: initImageLoader

import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache; //導入依賴的package包/類
public void initImageLoader() {
        File cacheDir = StorageUtils.getCacheDirectory(this);
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
                .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
                .diskCacheExtraOptions(480, 800, null)
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
                .memoryCacheSize(2 * 1024 * 1024)
                .memoryCacheSizePercentage(13) // default
                .diskCache(new UnlimitedDiskCache(cacheDir)) // default
                .diskCacheSize(50 * 1024 * 1024)
                .diskCacheFileCount(100)
//                .writeDebugLogs()
                .build();

        ImageLoader.getInstance().init(config);
    }
 
開發者ID:rsetkus,項目名稱:rx-twitter-stream-android,代碼行數:18,代碼來源:RxTwitterApplication.java

示例3: initImageLoader

import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache; //導入依賴的package包/類
private void initImageLoader() {
    File cacheDir = com.nostra13.universalimageloader.utils.StorageUtils
            .getOwnCacheDirectory(getActivity(),
                    IMAGE_CACHE_PATH);

    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(true).cacheOnDisc(true).build();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            getActivity()).defaultDisplayImageOptions(defaultOptions)
            .memoryCache(new LruMemoryCache(12 * 1024 * 1024))
            .memoryCacheSize(12 * 1024 * 1024)
            .discCacheSize(32 * 1024 * 1024).discCacheFileCount(100)
            .discCache(new UnlimitedDiscCache(cacheDir))
            .threadPriority(Thread.NORM_PRIORITY - 2)
            .tasksProcessingOrder(QueueProcessingType.LIFO).build();

    ImageLoader.getInstance().init(config);
}
 
開發者ID:fikyair,項目名稱:musicplayer,代碼行數:20,代碼來源:Recommend.java

示例4: getMemoryCache

import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache; //導入依賴的package包/類
public static LruMemoryCache getMemoryCache(Context context) {
    int cacheSize = 4194304;
    try {
        int i;
        int memClass = ((ActivityManager) context.getSystemService("activity")).getMemoryClass();
        int availableSize = memClass >> 3;
        if (availableSize == 0) {
            i = 4;
        } else {
            i = availableSize;
        }
        cacheSize = 1048576 * i;
        Log.d("ljn", "getMemoryCache---memClass:" + memClass + "----availableSize:" + availableSize);
    } catch (Exception exception) {
        exception.printStackTrace();
    }
    return new LruMemoryCache(cacheSize);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:19,代碼來源:LetvCacheConfiguration.java

示例5: initImageLoader

import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache; //導入依賴的package包/類
/**
     * 初始化imageloader,請在application中調用此方法
     */
    public static void initImageLoader(Context context) {
//        File cacheDir = StorageUtils.getOwnCacheDirectory(context,
//                "AppDir/cache/images");
        File cacheDir = new File(context.getCacheDir(), "images/cache/");
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
                context).threadPriority(Thread.NORM_PRIORITY - 2) //降低線程的優先級保證主UI線程不受太大影響
                .denyCacheImageMultipleSizesInMemory()
                .diskCacheFileNameGenerator(new Md5FileNameGenerator()) //圖片名稱使用md5加密
                .tasksProcessingOrder(QueueProcessingType.LIFO)
                .diskCacheSize(1024 * 1024 * 50) // 硬盤存儲緩存大小
                .memoryCache(new LruMemoryCache(10 * 1024 * 1024)) //內存緩存
                .memoryCacheSize(10 * 1024 * 1024)//內存緩存
                .diskCache(new UnlimitedDiskCache(cacheDir))
                .imageDownloader(new BaseImageDownloader(context, 5 * 1000, 30 * 1000)) // connectTimeout (5 s), readTimeout (30 s)
                .taskExecutor(taskExecutor)
                .taskExecutorForCachedImages(executorForCachedImages)
                .threadPriority(Thread.NORM_PRIORITY - 1)
                .writeDebugLogs()
                .build();
        com.nostra13.universalimageloader.core.ImageLoader.getInstance().init(config);
    }
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:25,代碼來源:ImageLoaderUtils.java

示例6: initImageLoader

import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache; //導入依賴的package包/類
/**
 * 初始化圖片載入框架
 */
private void initImageLoader() {
    File cacheDir = StorageUtils.getCacheDirectory(this);
    int MAXMEMONRY = (int) (Runtime.getRuntime().maxMemory());
    // System.out.println("dsa-->"+MAXMEMONRY+"   "+(MAXMEMONRY/5));//.memoryCache(new
    // LruMemoryCache(50 * 1024 * 1024))
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(true)
            .cacheOnDisk(true)
            .build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            this).memoryCacheExtraOptions(480, 800).defaultDisplayImageOptions(defaultOptions)
            .diskCacheExtraOptions(480, 800, null).threadPoolSize(3)
            .threadPriority(Thread.NORM_PRIORITY - 2)
            .tasksProcessingOrder(QueueProcessingType.FIFO)
            .denyCacheImageMultipleSizesInMemory()
            .memoryCache(new LruMemoryCache(MAXMEMONRY / 5))
            .diskCache(new UnlimitedDiskCache(cacheDir))
            .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
            .imageDownloader(new BaseImageDownloader(this)) // default
            .imageDecoder(new BaseImageDecoder(false)) // default
            .defaultDisplayImageOptions(DisplayImageOptions.createSimple()).build();

    ImageLoader.getInstance().init(config);
}
 
開發者ID:viseator,項目名稱:MontageCam,代碼行數:28,代碼來源:BaseActivity.java

示例7: initImageLoader

import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache; //導入依賴的package包/類
private void initImageLoader() {
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
    .threadPoolSize(5)
    .threadPriority(Thread.NORM_PRIORITY - 2)
    .denyCacheImageMultipleSizesInMemory()
    .memoryCache(new LruMemoryCache(2 * 1024))
    .memoryCacheSize(2 * 1024)
    .defaultDisplayImageOptions(new DisplayImageOptions.Builder()
    .showImageForEmptyUri(R.drawable.no_photo_group)
    .showImageOnFail(R.drawable.no_photo_group)
    .resetViewBeforeLoading(true)
    .displayer(new FadeInBitmapDisplayer(300)).build())
    .tasksProcessingOrder(QueueProcessingType.LIFO).build();
    ImageLoader.getInstance().init(config);
    com.nostra13.universalimageloader.utils.L.writeLogs(false);
}
 
開發者ID:WorldBank-Transport,項目名稱:RoadLab-Pro,代碼行數:17,代碼來源:RAApplication.java

示例8: getDefaultConfig

import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache; //導入依賴的package包/類
private ImageLoaderConfiguration getDefaultConfig() throws IOException {
    int MAX_CACHE_MEMORY_SIZE = (int) (Runtime.getRuntime().maxMemory() / 8);
    File cacheDir = StorageUtils.getOwnCacheDirectory(context, context.getPackageName() + "/cache/image/");

    LogUtil.i(TAG, "ImageLoader memory cache size = " + MAX_CACHE_MEMORY_SIZE / M + "M");
    LogUtil.i(TAG, "ImageLoader disk cache directory = " + cacheDir.getAbsolutePath());

    ImageLoaderConfiguration config = new ImageLoaderConfiguration
            .Builder(context)
            .threadPoolSize(3) // 線程池內加載的數量
            .threadPriority(Thread.NORM_PRIORITY - 2) // 降低線程的優先級,減小對UI主線程的影響
            .denyCacheImageMultipleSizesInMemory()
            .memoryCache(new LruMemoryCache(MAX_CACHE_MEMORY_SIZE))
            .discCache(new LruDiskCache(cacheDir, new Md5FileNameGenerator(), 0))
            .defaultDisplayImageOptions(DisplayImageOptions.createSimple())
            .imageDownloader(new BaseImageDownloader(context, 5 * 1000, 30 * 1000)) // connectTimeout (5 s), readTimeout (30 s)超時時間
            .writeDebugLogs()
            .build();

    return config;
}
 
開發者ID:LegendKe,項目名稱:MyTravelingDiary,代碼行數:22,代碼來源:ImageLoaderKit.java

示例9: initImageLoader

import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache; //導入依賴的package包/類
private void initImageLoader() {
	DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
			.cacheInMemory(false)
			.imageScaleType(ImageScaleType.EXACTLY)
			.cacheOnDisk(true)
			.build();

	ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
			.threadPriority(Thread.NORM_PRIORITY - 2)
			.defaultDisplayImageOptions(defaultOptions)
			.denyCacheImageMultipleSizesInMemory()
			.diskCacheFileNameGenerator(new Md5FileNameGenerator())
			.diskCache(new UnlimitedDiskCache(StorageUtils.getOwnCacheDirectory(this, Constant.APP_IMAGE)))
			.diskCacheSize(100 * 1024 * 1024).tasksProcessingOrder(QueueProcessingType.LIFO)
			.memoryCache(new LruMemoryCache(2 * 1024 * 1024)).memoryCacheSize(2 * 1024 * 1024)
			.threadPoolSize(3)
			.build();
	ImageLoader.getInstance().init(config);
}
 
開發者ID:macyuan,項目名稱:TAG,代碼行數:20,代碼來源:DemoApplication.java

示例10: initImageLoader

import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache; //導入依賴的package包/類
/**
     * 初始化ImageLoader
     *
     * @param context 上下文對象
     */
    private void initImageLoader(Context context) {
        File cacheDir = StorageUtils.getCacheDirectory(context);
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
                .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
                .diskCacheExtraOptions(480, 800, null)
//                .taskExecutor(...)
//        .taskExecutorForCachedImages(...)
                .threadPoolSize(3) // default
                .threadPriority(Thread.NORM_PRIORITY - 2) // default
                .tasksProcessingOrder(QueueProcessingType.FIFO) // default
                .denyCacheImageMultipleSizesInMemory()
                .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
                .memoryCacheSize(2 * 1024 * 1024)
                .memoryCacheSizePercentage(13) // default
                .diskCache(new UnlimitedDiskCache(cacheDir)) // default
                .diskCacheSize(50 * 1024 * 1024)
                .diskCacheFileCount(100)
                .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
                .imageDownloader(new BaseImageDownloader(context)) // default
//                .imageDecoder(new BaseImageDecoder()) // default
                .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
                .writeDebugLogs()
                .build();
        ImageLoader.getInstance().init(config);
    }
 
開發者ID:291700351,項目名稱:WeCharEnglish,代碼行數:31,代碼來源:WeCharApplication.java

示例11: initImageLoader

import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache; //導入依賴的package包/類
public static void initImageLoader(Context context) {
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
            .memoryCacheExtraOptions(480, 800) // default = device screen dimensions
            .diskCacheExtraOptions(480, 800, null)
            .tasksProcessingOrder(QueueProcessingType.FIFO) // default
            .denyCacheImageMultipleSizesInMemory()
            .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
            .memoryCacheSize(2 * 1024 * 1024)
            .memoryCacheSizePercentage(13) // default
            .diskCacheSize(50 * 1024 * 1024)
            .diskCacheFileCount(100)
            .diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
            .imageDownloader(new BaseImageDownloader(context)) // default
            .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
            .writeDebugLogs()
            .build();
    // Initialize ImageLoader with configuration.
    ImageLoader.getInstance().init(config);
}
 
開發者ID:davyjoneswang,項目名稱:AndroidLearnDemos,代碼行數:20,代碼來源:MainActivity.java

示例12: initImageLoader

import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache; //導入依賴的package包/類
private void initImageLoader() {
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
            .cacheInMemory(false)
            .imageScaleType(ImageScaleType.EXACTLY)
            .cacheOnDisk(true)
            .build();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
            .threadPriority(Thread.NORM_PRIORITY - 2)
            .defaultDisplayImageOptions(defaultOptions)
            .denyCacheImageMultipleSizesInMemory()
            .diskCacheFileNameGenerator(new Md5FileNameGenerator())
            .diskCache(new UnlimitedDiskCache(StorageUtils.getOwnCacheDirectory(this, AppConstants.APP_IMAGE)))
            .diskCacheSize(100 * 1024 * 1024).tasksProcessingOrder(QueueProcessingType.LIFO)
            .memoryCache(new LruMemoryCache(2 * 1024 * 1024)).memoryCacheSize(2 * 1024 * 1024)
            .threadPoolSize(3)
            .build();
    ImageLoader.getInstance().init(config);
}
 
開發者ID:boliu-mobile,項目名稱:SmartFace,代碼行數:20,代碼來源:App.java

示例13: onCreate

import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache; //導入依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();

    File cacheDir = StorageUtils.getCacheDirectory(this);
    ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this)
            .threadPriority(Thread.NORM_PRIORITY - 2)
            .denyCacheImageMultipleSizesInMemory()
            .diskCache(new UnlimitedDiscCache(cacheDir))
            .diskCacheSize(50 * 1024 * 1024)
            .diskCacheFileCount(100)
            .diskCacheFileNameGenerator(new Md5FileNameGenerator())
            .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
            .memoryCacheSize(2 * 1024 * 1024)
            .memoryCacheSizePercentage(13)
            .tasksProcessingOrder(QueueProcessingType.LIFO)
            .build();
    ImageLoader.getInstance().init(configuration);
}
 
開發者ID:xulailing,項目名稱:android-open-project-demo-master,代碼行數:20,代碼來源:HuxianApplication.java

示例14: initUil

import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache; //導入依賴的package包/類
private void initUil() {
    File cacheDir = SdCacheTools.getOwnImageCacheDir(this);
    ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this)
            .threadPriority(Thread.NORM_PRIORITY - 2)
            .denyCacheImageMultipleSizesInMemory()
            .diskCache(new UnlimitedDiskCache(cacheDir))
            .diskCacheSize(50 * 1024 * 1024)
            .diskCacheFileCount(100)
            .diskCacheFileNameGenerator(new Md5FileNameGenerator())
            .memoryCache(new LruMemoryCache(2 * 1024 * 1024))
            .memoryCacheSize(2 * 1024 * 1024)
            .memoryCacheSizePercentage(13)
            .tasksProcessingOrder(QueueProcessingType.LIFO)
            .build();
    ImageLoader.getInstance().init(configuration);
}
 
開發者ID:BigAppOS,項目名稱:BigApp_WordPress_Android,代碼行數:17,代碼來源:BaseApplication.java

示例15: initImageLoader

import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache; //導入依賴的package包/類
/**
 * 初始化 UIL圖片加載框架
 */
private void initImageLoader() {
    ImageLoaderConfiguration imageLoaderConfig = new ImageLoaderConfiguration.Builder(getApplicationContext())
            // 對於同一張圖片有多種尺寸的圖, 隻存儲其中一個
            .denyCacheImageMultipleSizesInMemory()
            // 內存緩存使用 LRU 算法進行存儲和刪除, 容量10MB
            .memoryCache(new LruMemoryCache(10 * 1024 * 1024))
            // 硬盤緩存容量 50MB
            .diskCacheSize(50 * 1024 * 1024)
            // 硬盤上緩存的圖片名稱是經過使用 md5 轉換後的名稱.
            .diskCacheFileNameGenerator(new Md5FileNameGenerator())
            // 線程池按照LIFO的順序進行圖片的加載, 即: 越是後加入到線程池隊列中的圖片, 越是優先進行加載.
            .tasksProcessingOrder(QueueProcessingType.LIFO)
            // 設置線程池最大並發數為5
            .threadPoolSize(5)
            // 打開調試日誌的開關
            .writeDebugLogs()
            .build();
    ImageLoader.getInstance().init(imageLoaderConfig);
}
 
開發者ID:clevergump,項目名稱:Android-ProgressCircle,代碼行數:23,代碼來源:MyApplication.java


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