本文整理汇总了Java中com.nostra13.universalimageloader.cache.disc.impl.TotalSizeLimitedDiscCache类的典型用法代码示例。如果您正苦于以下问题:Java TotalSizeLimitedDiscCache类的具体用法?Java TotalSizeLimitedDiscCache怎么用?Java TotalSizeLimitedDiscCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TotalSizeLimitedDiscCache类属于com.nostra13.universalimageloader.cache.disc.impl包,在下文中一共展示了TotalSizeLimitedDiscCache类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupUIL
import com.nostra13.universalimageloader.cache.disc.impl.TotalSizeLimitedDiscCache; //导入依赖的package包/类
/**
* Universal Image Loader Setup
*/
private void setupUIL() {
File cacheDir = StorageUtils.getOwnCacheDirectory(
getApplicationContext(), "CafeCar/cache");
options = new DisplayImageOptions.Builder()
.cacheOnDisc(true).cacheInMemory(true).build();
cache = new TotalSizeLimitedDiscCache(cacheDir, 50 * 1024 * 1024);
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
getApplicationContext()).threadPoolSize(3)
.threadPriority(Thread.NORM_PRIORITY - 1)
.denyCacheImageMultipleSizesInMemory()
.memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024))
// You can pass your own memory cache implementation
.discCache(cache)
// You can pass your own disc cache implementation
.discCacheFileNameGenerator(new HashCodeFileNameGenerator())
.defaultDisplayImageOptions(options).build();
ImageLoader.getInstance().init(config);
}
示例2: configUIL
import com.nostra13.universalimageloader.cache.disc.impl.TotalSizeLimitedDiscCache; //导入依赖的package包/类
public static void configUIL(Context context) {
File cacheDir = new File(context.getExternalCacheDir(), UIL_CACHE);
DisplayImageOptions defaultOptions = defaultImageOptions();
HttpClientImageDownloader downloader = new HttpClientImageDownloader(context,
BuddycloudHTTPHelper.createHttpClient(context));
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
.discCache(new TotalSizeLimitedDiscCache(cacheDir, 50 * 1024 * 1024))
.imageDownloader(downloader)
.defaultDisplayImageOptions(defaultOptions)
.writeDebugLogs()
.build();
ImageLoader.getInstance().init(config);
}
示例3: createReserveDiscCache
import com.nostra13.universalimageloader.cache.disc.impl.TotalSizeLimitedDiscCache; //导入依赖的package包/类
/** Creates reserve disc cache which will be used if primary disc cache becomes unavailable */
public static DiscCacheAware createReserveDiscCache(File cacheDir) {
File individualDir = new File(cacheDir, "uil-images");
if (individualDir.exists() || individualDir.mkdir()) {
cacheDir = individualDir;
}
return new TotalSizeLimitedDiscCache(cacheDir, 2 * 1024 * 1024); // limit - 2 Mb
}
示例4: createReserveDiscCache
import com.nostra13.universalimageloader.cache.disc.impl.TotalSizeLimitedDiscCache; //导入依赖的package包/类
/** Creates reserve disc cache which will be used if primary disc cache becomes unavailable */
public static DiscCacheAware createReserveDiscCache(Context context) {
File cacheDir = context.getCacheDir();
File individualDir = new File(cacheDir, "uil-images");
if (individualDir.exists() || individualDir.mkdir()) {
cacheDir = individualDir;
}
return new TotalSizeLimitedDiscCache(cacheDir, 2 * 1024 * 1024); // limit - 2 Mb
}
示例5: initImageLoader
import com.nostra13.universalimageloader.cache.disc.impl.TotalSizeLimitedDiscCache; //导入依赖的package包/类
/**
* Android universal Image Loader
* Create global configuration and initialize ImageLoader with this configuration
*
* @TODO: test/fix caching size usage
*/
public void initImageLoader() {
boolean useDiscCache = sharedPreferences.getBoolean("pref_usedisccache", true);
boolean useMemCache = sharedPreferences.getBoolean("pref_usememcache", true);
ImageLoader il = ImageLoader.getInstance();
if(il.isInited()){
il.destroy();
}
DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
.cacheInMemory(useMemCache) //TODO
.cacheOnDisc(useDiscCache)
.showImageOnLoading(R.drawable.coffee) // resource or drawable
.showImageForEmptyUri(R.drawable.coffee)
.showImageOnFail(R.drawable.coffee)
.build();
File cacheDir = StorageUtils.getCacheDirectory(getApplicationContext());
cacheDir.mkdirs(); // needs android.permission.WRITE_EXTERNAL_STORAGE
//TODO max size from setting?
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.defaultDisplayImageOptions(defaultOptions)
.discCache(new TotalSizeLimitedDiscCache(cacheDir, 25 * 1024 * 1024))
.build();
ImageLoader.getInstance().init(config);
}
示例6: onCreate
import com.nostra13.universalimageloader.cache.disc.impl.TotalSizeLimitedDiscCache; //导入依赖的package包/类
@Override
public void onCreate() {
ACRA.init(this);
super.onCreate();
// Fire progress callbacks for every 3% of uploaded content
System.setProperty("in.yuvi.http.fluent.PROGRESS_TRIGGER_THRESHOLD", "3.0");
api = createMWApi();
ImageLoaderConfiguration imageLoaderConfiguration = new ImageLoaderConfiguration.Builder(getApplicationContext())
.discCache(new TotalSizeLimitedDiscCache(StorageUtils.getCacheDirectory(this), 128 * 1024 * 1024))
.build();
ImageLoader.getInstance().init(imageLoaderConfiguration);
try {
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
APPLICATION_VERSION = pInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
// LET US WIN THE AWARD FOR DUMBEST CHECKED EXCEPTION EVER!
throw new RuntimeException(e);
}
// Initialize EventLogging
EventLog.setApp(this);
DiskBasedCache cache = new DiskBasedCache(getCacheDir(), 16 * 1024 * 1024);
volleyQueue = new RequestQueue(cache, new BasicNetwork(new HurlStack()));
volleyQueue.start();
}
示例7: onCreate
import com.nostra13.universalimageloader.cache.disc.impl.TotalSizeLimitedDiscCache; //导入依赖的package包/类
@Override
public void onCreate() {
String storage = Environment.getExternalStorageState();
int limit;
File cacheBase;
if ( Environment.MEDIA_MOUNTED.equals(storage) ){
cacheBase = getExternalCacheDir();
limit = 30*1024*1024;
} else {
cacheBase = getCacheDir();
limit = 10*1024*1024;
}
File cacheDir = new File(cacheBase,"imageCache");
Log.i(TAG, String.format("Cache: %s", cacheDir.getAbsolutePath()));
if ( !cacheDir.exists() ){
cacheDir.mkdirs();
}
DisplayImageOptions defaultDisplayImageOptions = new DisplayImageOptions.Builder()
.cacheInMemory()
.cacheOnDisc()
.build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.defaultDisplayImageOptions(defaultDisplayImageOptions )
.discCache(new TotalSizeLimitedDiscCache(cacheDir, limit))
.build();
ImageLoader.getInstance().init(config);
RoboGuice.setBaseApplicationInjector(this, RoboGuice.DEFAULT_STAGE,
new CustomModule(),
RoboGuice.newDefaultRoboModule(this));
}
示例8: ImageLoader
import com.nostra13.universalimageloader.cache.disc.impl.TotalSizeLimitedDiscCache; //导入依赖的package包/类
private ImageLoader(Context context) {
File cacheDir = context.getCacheDir();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
context)
.threadPoolSize(3)
.denyCacheImageMultipleSizesInMemory()
.memoryCache(new LRULimitedMemoryCache(1 * 1024 * 1024))
// 1MB
.discCache(
new TotalSizeLimitedDiscCache(cacheDir,
10 * 1024 * 1024))
// 10MB
.discCacheFileNameGenerator(new Md5FileNameGenerator())
.imageDownloader(new ImageDownloader() {
@Override
protected InputStream getStreamFromNetwork(URI arg0)
throws IOException {
try {
URL imageUrl = arg0.toURL();
URLConnection conn = (URLConnection) imageUrl
.openConnection();
conn.setConnectTimeout(5000);
conn.setReadTimeout(20000);
conn.setUseCaches(true);
return conn.getInputStream();
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
}).defaultDisplayImageOptions(options).build();
loader.init(config);
}
示例9: DobroNetwork
import com.nostra13.universalimageloader.cache.disc.impl.TotalSizeLimitedDiscCache; //导入依赖的package包/类
public DobroNetwork(DobroApplication context) {
BasicHttpParams httpParams = new BasicHttpParams();
ConnManagerParams.setTimeout(httpParams, 10000);
ConnManagerParams.setMaxConnectionsPerRoute(httpParams, new ConnPerRouteBean(20));
ConnManagerParams.setMaxTotalConnections(httpParams, 20);
HttpConnectionParams.setSoTimeout(httpParams, 10000);
HttpConnectionParams.setTcpNoDelay(httpParams, true);
HttpConnectionParams.setSocketBufferSize(httpParams, 8192);
HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
HttpProtocolParams.setUserAgent(httpParams, getUserAgent());
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(httpParams, schemeRegistry);
m_http_context = new SyncBasicHttpContext(new BasicHttpContext());
m_httpclient = new DefaultHttpClient(cm, httpParams);
m_cookie_store = new BasicCookieStore();
loadCookies();
m_http_context.setAttribute(ClientContext.COOKIE_STORE, m_cookie_store);
createDownloadReceiver();
File cacheDir = StorageUtils.getIndividualCacheDirectory(context);
disc_cache = new TotalSizeLimitedDiscCache(cacheDir, 30 * 1024 * 1024);
memory_cache = new UsingFreqLimitedMemoryCache(2 * 1024 * 1024);
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
.threadPoolSize(5)
.threadPriority(Thread.NORM_PRIORITY - 2)
.memoryCache(memory_cache)
.discCache(disc_cache)
.imageDownloader(new HttpClientImageDownloader(context, m_httpclient))
.tasksProcessingOrder(QueueProcessingType.LIFO)
.defaultDisplayImageOptions(new DisplayImageOptions.Builder()
.cacheInMemory()
.cacheOnDisc()
.imageScaleType(ImageScaleType.IN_SAMPLE_INT)
.bitmapConfig(Bitmap.Config.ARGB_8888)
.displayer(new SimpleBitmapDisplayer())
.build())
.enableLogging()
.build();
ImageLoader.getInstance().init(config);
}