1. 程式人生 > >介面卡設定圖片

介面卡設定圖片

public static ImageLoaderConfiguration getImageLoaderConfiguration(Context context) {
    ImageLoaderConfiguration configuration = 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 設定當前執行緒的優先順序
        //任務處理優先順序 Fist In Fist Out
        //.tasksProcessingOrder(QueueProcessingType.FIFO) // default
        //記憶體中不快取一張圖片的多個尺寸大小
        //.denyCacheImageMultipleSizesInMemory()
        //內在快取策略
        //.memoryCache(new LruMemoryCache(2 * 1024 * 1024)) //可以通過自己的記憶體快取實現
        //記憶體快取大小
        //.memoryCacheSize(2 * 1024 * 1024)  // 記憶體快取的最大值
        //內在快取大小:佔用百分比
        .memoryCacheSizePercentage(13) // default
        //磁碟快取策略
        //.diskCache(new LruDiskCache()) // default 可以自定義快取路徑
        //磁碟快取大小
        .diskCacheSize(50 * 1024 * 1024) // 50 Mb sd卡(本地)快取的最大值
        //.diskCacheFileCount(100)  // 可以快取的檔案數量
        // default為使用HASHCODE對UIL進行加密命名, 還可以用MD5(new Md5FileNameGenerator())加密
        //.diskCacheFileNameGenerator(new HashCodeFileNameGenerator())
        //.imageDownloader(new BaseImageDownloader(context)) // default
        //(new BaseImageDecoder(false)) // default
        //載入具體圖片時的一些配置
        .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
        .writeDebugLogs() // 列印debug log
        .build();

    return configuration;
  }

如果要滴定儀快取路徑的話 先

File file= new File(Environment.getExternalStorageDirectory().getPath()+"/aaa");
.diskCache(new UnlimitedDiscCache(file))//自定義sd快取目錄
public static DisplayImageOptions getDefaultDisplayImageOptions(Context context) {
    DisplayImageOptions displayImageOptions = new DisplayImageOptions.Builder()
        //是否快取
        .cacheInMemory(true)
        .cacheOnDisk(true)
        //RGB 565   r紅色佔5   g綠色佔6   b藍色佔5  -> 2位元組
        //alpha
        //ARGB 4444    4 4 4 4  -> 2位元組
        //ARGB 8888    -> 4位元組

        //10 * 10 用rgb565 -> 10*10*2

        .bitmapConfig(Bitmap.Config.RGB_565)
        //載入時、載入錯誤時展示什麼內容
        .showImageOnLoading(R.mipmap.ic_launcher)
        .showImageOnFail(R.mipmap.ic_launcher)
        //
        .imageScaleType(ImageScaleType.EXACTLY_STRETCHED)

        //載入效果
        //ctrl + p
        .displayer(new CircleBitmapDisplayer())
        .build();

    //ctrl + h
    //BitmapDisplayer;
    return displayImageOptions;
  }