package com.bwie.test.url;
import com.bwie.test.R;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
import com.nostra13.universalimageloader.cache.memory.impl.UsingFreqLimitedMemoryCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import android.app.Application;
public class ImgLoder extends Application {
@Override
public void onCreate() {
// TODO Auto-generated method stub
initImageLoaderConfig();
super.onCreate();
}
private void initImageLoaderConfig() {
// TODO Auto-generated method stub
DisplayImageOptions options = new DisplayImageOptions.Builder()
.cacheInMemory(true).cacheOnDisc(true)
.showImageOnFail(R.drawable.a163)
.showImageOnFail(R.drawable.a163)
.considerExifParams(true)
.resetViewBeforeLoading(true)
.showImageOnLoading(R.drawable.a163).build();
int max = (int) (Runtime.getRuntime().maxMemory() / 8);
ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(
getApplicationContext())
.memoryCache(new UsingFreqLimitedMemoryCache(max))
.discCache(new UnlimitedDiskCache(getCacheDir()))
.threadPoolSize(3).threadPriority(Thread.NORM_PRIORITY-1)
.defaultDisplayImageOptions(options)
.build();
ImageLoader.getInstance().init(configuration);
}
}
//调用
ImageLoader.getInstance().displayImage(im.getImageUrl(), img);
Android中ImageLoader
最新推荐文章于 2021-05-27 05:49:55 发布