Android Open Source - Demo-YouTuBe-Android Image Loader Util






From Project

Back to project page Demo-YouTuBe-Android.

License

The source code is released under:

Apache License

If you think the Android project Demo-YouTuBe-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.lqg.youtube.support.util;
/*w  ww.  j  a  va2s . c o m*/
import android.content.Context;

import com.lqg.youtube.R;
import com.lqg.youtube.support.GlobalApplication;
import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache;
import com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;

import java.io.File;

public class ImageLoaderUtil {

    private static String CACHEPATH = GlobalApplication.getInstance().getExternalCacheDir() + "/ImageCache/";

    public static DisplayImageOptions createListPicDisplayImageOptions() {

        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .showImageOnLoading(R.drawable.wb_pic_loading_large)
                .showImageForEmptyUri(R.drawable.wb_pic_loading_large)
                .showImageOnFail(R.drawable.wb_pic_loading_large)
                .cacheInMemory(true)
                .cacheOnDisc(true)
                        // .displayer(new FadeInBitmapDisplayer(100)).build();
                .build();

        return options;
    }

    public static ImageLoader getImageLoader() {
        ImageLoader loader = ImageLoader.getInstance();
        if (!loader.isInited())
            initImageLoader(GlobalApplication.getInstance(), loader);
        return loader;
    }

    private static void initImageLoader(Context context, ImageLoader imageLoader) {
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
                .threadPriority(Thread.NORM_PRIORITY - 2)
                .denyCacheImageMultipleSizesInMemory()
                .diskCacheFileNameGenerator(new HashCodeFileNameGenerator())
                .diskCache(new UnlimitedDiscCache(new File(CACHEPATH)))
                .diskCacheFileCount(500)
                .diskCacheSize(500 * 1024 * 1024)
                .tasksProcessingOrder(QueueProcessingType.LIFO)
                .build();
        imageLoader.init(config);
    }
}




Java Source Code List

com.lqg.youtube.support.GlobalApplication.java
com.lqg.youtube.support.http.Search.java
com.lqg.youtube.support.player.Format.java
com.lqg.youtube.support.player.UrlParser.java
com.lqg.youtube.support.player.VideoId.java
com.lqg.youtube.support.player.VideoStream.java
com.lqg.youtube.support.util.ImageLoaderUtil.java
com.lqg.youtube.support.util.LogUtil.java
com.lqg.youtube.support.util.SearchSetting.java
com.lqg.youtube.ui.play.PlayVideoUsingVideoViewActivity.java
com.lqg.youtube.ui.play.PlayVideoUsingYouTuBeActivity.java
com.lqg.youtube.ui.search.MainActivity.java
com.lqg.youtube.ui.search.SearchFragment.java
com.lqg.youtube.ui.search.SearchResultAdapter.java
com.lqg.youtube.ui.search.SearchSetingFragment.java