Search in sources :

Example 1 with WeakMemoryCache

use of com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache in project android by testpress.

the class TestpressApplication method initImageLoader.

public static void initImageLoader(Context context) {
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().cacheOnDisk(true).cacheInMemory(true).imageScaleType(ImageScaleType.EXACTLY).displayer(new FadeInBitmapDisplayer(300)).build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).defaultDisplayImageOptions(defaultOptions).memoryCache(new WeakMemoryCache()).diskCacheSize(500 * 1024 * 1024).build();
    ImageLoader.getInstance().init(config);
}
Also used : FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) WeakMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 2 with WeakMemoryCache

use of com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache in project teamward-client by Neamar.

the class LolApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    // Create default options which will be used for every
    // displayImage(...) call if no options will be passed to this method
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().cacheOnDisk(true).bitmapConfig(Bitmap.Config.RGB_565).build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).defaultDisplayImageOptions(defaultOptions).diskCacheFileCount(300).threadPoolSize(5).memoryCache(new WeakMemoryCache()).build();
    ImageLoader.getInstance().init(config);
    if (BuildConfig.DEBUG) {
        StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().permitDiskReads().penaltyLog().penaltyDeath().build());
        StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
    }
    // Tracking initialization
    final Runnable r = new Runnable() {

        public void run() {
            identifyOnAmplitude();
            identifyOnTrackers();
        }
    };
    Handler handler = new Handler();
    handler.post(r);
}
Also used : StrictMode(android.os.StrictMode) WeakMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache) Handler(android.os.Handler) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 3 with WeakMemoryCache

use of com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache in project KenBurnsView by flavioarfaria.

the class FromURLActivity method loadImage.

private void loadImage() {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        String cacheDirName = "." + getString(R.string.app_name);
        cacheDir = new File(Environment.getExternalStorageDirectory(), cacheDirName);
    } else {
        cacheDir = getCacheDir();
    }
    if (!cacheDir.exists()) {
        cacheDir.mkdirs();
    }
    config = new ImageLoaderConfiguration.Builder(this).memoryCache(new WeakMemoryCache()).denyCacheImageMultipleSizesInMemory().diskCache(new UnlimitedDiscCache(cacheDir)).threadPoolSize(5).build();
    options = new DisplayImageOptions.Builder().bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.IN_SAMPLE_INT).cacheOnDisk(true).cacheInMemory(true).build();
    imageLoader.init(config);
    imageLoader.displayImage("http://i.imgur.com/gysR4Ee.jpg", mImg, options, this);
}
Also used : UnlimitedDiscCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache) WeakMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache) File(java.io.File)

Example 4 with WeakMemoryCache

use of com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache in project JamsMusicPlayer by psaravan.

the class Common method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    //Application context.
    mContext = getApplicationContext();
    //SharedPreferences.
    mSharedPreferences = this.getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE);
    //Init the database.
    mDBAccessHelper = new DBAccessHelper(mContext);
    //Playback kickstarter.
    mPlaybackKickstarter = new PlaybackKickstarter(this.getApplicationContext());
    //Picasso.
    mPicasso = new Picasso.Builder(mContext).build();
    //ImageLoader.
    mImageLoader = ImageLoader.getInstance();
    mImageLoaderConfiguration = new ImageLoaderConfiguration.Builder(getApplicationContext()).memoryCache(new WeakMemoryCache()).memoryCacheSizePercentage(13).imageDownloader(new ByteArrayUniversalImageLoader(mContext)).build();
    mImageLoader.init(mImageLoaderConfiguration);
    //Init DisplayImageOptions.
    initDisplayImageOptions();
    //Log the user into Google Play Music only if the account is currently set up and active.
    if (mSharedPreferences.getBoolean("GOOGLE_PLAY_MUSIC_ENABLED", false) == true) {
        //Create a temp WebView to retrieve the user agent string.
        String userAgentString = "";
        if (mSharedPreferences.getBoolean("GOT_USER_AGENT", false) == false) {
            WebView webView = new WebView(getApplicationContext());
            webView.setVisibility(View.GONE);
            webView.loadUrl("http://www.google.com");
            userAgentString = webView.getSettings().getUserAgentString();
            mSharedPreferences.edit().putBoolean("GOT_USER_AGENT", true).commit();
            mSharedPreferences.edit().putString("USER_AGENT", userAgentString).commit();
            webView = null;
        }
        setGMusicClientCalls(GMusicClientCalls.getInstance(getApplicationContext()));
        GMusicClientCalls.setWebClientUserAgent(userAgentString);
        String accountName = mSharedPreferences.getString("GOOGLE_PLAY_MUSIC_ACCOUNT", "");
        //Authenticate with Google.
        AsyncGoogleMusicAuthenticationTask task = new AsyncGoogleMusicAuthenticationTask(mContext, false, accountName);
        task.execute();
    }
}
Also used : PlaybackKickstarter(com.jams.music.player.PlaybackKickstarter.PlaybackKickstarter) DBAccessHelper(com.jams.music.player.DBHelpers.DBAccessHelper) WeakMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache) AsyncGoogleMusicAuthenticationTask(com.jams.music.player.AsyncTasks.AsyncGoogleMusicAuthenticationTask) WebView(android.webkit.WebView) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Example 5 with WeakMemoryCache

use of com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache in project CustomViews by AndroidStudy233.

the class MyApplication method initImageLoader.

/**
 * 初始化ImageLoader
 */
private void initImageLoader() {
    File cacheDir = getCacheDir();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).memoryCacheExtraOptions(480, // max width, max height,即保存的每个缓存文件的最大长宽
    800).threadPoolSize(// 线程池内加载的数量
    3).threadPriority(// 线程优先级
    Thread.NORM_PRIORITY - 1).denyCacheImageMultipleSizesInMemory().memoryCache(new WeakMemoryCache()).memoryCacheSize(// 内存缓存2MB
    2 * 1024 * 1024).tasksProcessingOrder(QueueProcessingType.LIFO).diskCache(// 限制缓存时长
    new LimitedAgeDiskCache(cacheDir, 7 * 24 * 60 * 60)).diskCacheSize(// 本地缓存50MB
    50 * 1024 * 1024).diskCacheFileNameGenerator(// MD5加密名字
    new Md5FileNameGenerator()).defaultDisplayImageOptions(// 设置默认选项
    DisplayImageOptions.createSimple()).imageDownloader(// connectTimeout (5 s), readTimeout (30 s)超时时间
    new BaseImageDownloader(getApplicationContext(), 5 * 1000, 20 * 1000)).build();
    // 开始构建
    ImageLoader.getInstance().init(config);
}
Also used : WeakMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache) Md5FileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator) BaseImageDownloader(com.nostra13.universalimageloader.core.download.BaseImageDownloader) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) LimitedAgeDiskCache(com.nostra13.universalimageloader.cache.disc.impl.LimitedAgeDiskCache)

Aggregations

WeakMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache)6 ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)5 File (java.io.File)3 UnlimitedDiscCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache)2 Md5FileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator)2 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)2 Handler (android.os.Handler)1 StrictMode (android.os.StrictMode)1 WebView (android.webkit.WebView)1 AsyncGoogleMusicAuthenticationTask (com.jams.music.player.AsyncTasks.AsyncGoogleMusicAuthenticationTask)1 DBAccessHelper (com.jams.music.player.DBHelpers.DBAccessHelper)1 PlaybackKickstarter (com.jams.music.player.PlaybackKickstarter.PlaybackKickstarter)1 LimitedAgeDiskCache (com.nostra13.universalimageloader.cache.disc.impl.LimitedAgeDiskCache)1 FadeInBitmapDisplayer (com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)1 BaseImageDownloader (com.nostra13.universalimageloader.core.download.BaseImageDownloader)1