正在使用通用圖像加載器來下載圖像。這是我的配置和顯示選項。直接獲取位圖而不是fileCacheUtil中的文件
File cacheDir = getApplicationContext().getCacheDir();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
getApplicationContext())
.discCache(new UnlimitedDiscCache(cacheDir)).threadPoolSize(3)
.denyCacheImageMultipleSizesInMemory()
.tasksProcessingOrder(QueueProcessingType.LIFO)
.discCacheFileNameGenerator(new HashCodeFileNameGenerator())
.build();
options = new DisplayImageOptions.Builder()
.cacheOnDisc().bitmapConfig(Bitmap.Config.RGB_565)
.imageScaleType(ImageScaleType.EXACTLY).resetViewBeforeLoading()
.showStubImage(R.drawable.bt_fine_dining).build();
一切工作正常。但我想檢查圖像是否已經存在或沒有。使用discCacheUtil能夠獲取圖像文件。 [DiscCacheUtil.findInCache(imageUri,discCache)]。但有沒有什麼辦法可以直接獲取位圖而不是文件?
而且,如果我同時指定cacheInMemory()和cacheOnDisc(),將圖像保存兩次?這裏是否有額外的內存消耗,因爲圖像將被保存在內存和光盤中?請幫幫我。
在此先感謝
繪製但是,這很可能會重複,你已經做了DiscCacheUtil.findInCache。所以從文件加載更簡單。 只要做 BitmapFactory.decodeStream(new FileInputStream(file)); – grebulon 2014-03-10 11:29:12