imageload简单配置

package com.bawie.application;

import android.app.Application;
import android.os.Environment;

import com.bawie.test.R;
import com.mob.MobApplication;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;

import org.xutils.DbManager;
import org.xutils.db.table.TableEntity;
import org.xutils.x;

import java.io.File;
import java.util.ArrayList;

/**
* Created by win on 2017/9/4.
*/

public class MyApplication extends MobApplication {

@Override
public void onCreate() {
super.onCreate();


/**
* 初始化ImageLoader
*/
String path = Environment.getExternalStorageDirectory() + "/1507DAccess";

File cacheDir = new File(path);
//创建配置ImageLoader(所有的选项都是可选的,只使用那些你真的想定制),这个可以设定在APPLACATION里面,设置为全局的配置参数
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
.threadPriority(100)
.threadPoolSize(3)
.memoryCacheExtraOptions(200, 200)
.memoryCacheSize(2 * 1024 * 1024)
.diskCache(new UnlimitedDiskCache(cacheDir))
.diskCacheFileNameGenerator(new Md5FileNameGenerator())
.diskCacheSize(50 * 1024 * 1024)
.build();
ImageLoader.getInstance().init(config);
}


public static DisplayImageOptions getOptions() {
DisplayImageOptions options = new DisplayImageOptions.Builder()
.cacheOnDisk(true)
.cacheInMemory(true)
.showImageForEmptyUri(R.mipmap.ic_launcher)
.showImageOnLoading(R.mipmap.ic_launcher)
.showImageOnFail(R.mipmap.ic_launcher)
.build();
return options;
}


}

你可能感兴趣的:(imageload简单配置)