Java 类com.nostra13.universalimageloader.core.download.HttpClientImageDownloader 实例源码

项目:buddycloud-android    文件:ImageHelper.java   
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);
}
项目:dobroreader-mod    文件:DobroNetwork.java   
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);
    }