• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TotalSizeLimitedDiscCache类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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);
}
 
开发者ID:jackrex,项目名称:AndroidCacheFoundation,代码行数:22,代码来源:MyApplication.java


示例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);
}
 
开发者ID:buddycloud,项目名称:buddycloud-android,代码行数:18,代码来源:ImageHelper.java


示例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
}
 
开发者ID:Apokrif,项目名称:morse,代码行数:9,代码来源:DefaultConfigurationFactory.java


示例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
}
 
开发者ID:jixieshi999,项目名称:juahya,代码行数:10,代码来源:DefaultConfigurationFactory.java


示例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);				

}
 
开发者ID:NanneHuiges,项目名称:androblip,代码行数:37,代码来源:ActivityMain.java


示例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();
}
 
开发者ID:yuvipanda,项目名称:apps-android-commons,代码行数:30,代码来源:CommonsApplication.java


示例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));
}
 
开发者ID:riotopsys,项目名称:malforandroid2,代码行数:39,代码来源:MalApplication.java


示例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);
}
 
开发者ID:valven,项目名称:devfest,代码行数:34,代码来源:ImageLoader.java


示例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);
	}
 
开发者ID:rdmwfs,项目名称:dobroreader-mod,代码行数:51,代码来源:DobroNetwork.java



注:本文中的com.nostra13.universalimageloader.cache.disc.impl.TotalSizeLimitedDiscCache类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DataType类代码示例发布时间:2022-05-22
下一篇:
Java StrictPreemptionContractProtoOrBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap