Search in sources :

Example 16 with ImageLoader

use of com.nostra13.universalimageloader.core.ImageLoader in project GalleryFinal by pengjianbo.

the class MainActivity method initImageLoader.

// @Override
// protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// super.onActivityResult(requestCode, resultCode, data);
// if (requestCode == GalleryFinal.GALLERY_REQUEST_CODE) {
// if (resultCode == GalleryFinal.GALLERY_RESULT_SUCCESS) {
// List<PhotoInfo> photoInfoList = (List<PhotoInfo>) data.getSerializableExtra(GalleryFinal.GALLERY_RESULT_LIST_DATA);
// if (photoInfoList != null) {
// mPhotoList.addAll(photoInfoList);
// mChoosePhotoListAdapter.notifyDataSetChanged();
// }
// }
// }
// }
private void initImageLoader(Context context) {
    // This configuration tuning is custom. You can tune every option, you may tune some of them,
    // or you can create default configuration by
    // ImageLoaderConfiguration.createDefault(this);
    // method.
    ImageLoaderConfiguration.Builder config = new ImageLoaderConfiguration.Builder(context);
    config.threadPriority(Thread.NORM_PRIORITY - 2);
    config.denyCacheImageMultipleSizesInMemory();
    config.diskCacheFileNameGenerator(new Md5FileNameGenerator());
    // 50 MiB
    config.diskCacheSize(50 * 1024 * 1024);
    config.tasksProcessingOrder(QueueProcessingType.LIFO);
    // Remove for release app
    config.writeDebugLogs();
    // Initialize ImageLoader with configuration.
    ImageLoader.getInstance().init(config.build());
}
Also used : Md5FileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Example 17 with ImageLoader

use of com.nostra13.universalimageloader.core.ImageLoader in project DanmakuFlameMaster by Bilibili.

the class UglyViewCacheStufferSampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Create global configuration and initialize ImageLoader with this config
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).memoryCache(new LruMemoryCache(2 * 1024 * 1024)).memoryCacheSize(2 * 1024 * 1024).memoryCacheSizePercentage(13).build();
    ImageLoader.getInstance().init(config);
    setContentView(R.layout.activity_main);
    findViews();
}
Also used : SpannableStringBuilder(android.text.SpannableStringBuilder) LruMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Example 18 with ImageLoader

use of com.nostra13.universalimageloader.core.ImageLoader in project android-page-transition by xmuSistone.

the class MainActivity method initImageLoader.

@SuppressWarnings("deprecation")
private void initImageLoader() {
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).memoryCacheExtraOptions(480, 800).threadPoolSize(3).threadPriority(Thread.NORM_PRIORITY - 1).tasksProcessingOrder(QueueProcessingType.FIFO).denyCacheImageMultipleSizesInMemory().memoryCache(new LruMemoryCache(2 * 1024 * 1024)).memoryCacheSize(2 * 1024 * 1024).memoryCacheSizePercentage(// default
    13).discCacheSize(// 缓冲大小
    50 * 1024 * 1024).discCacheFileCount(// 缓冲文件数目
    100).discCacheFileNameGenerator(// default
    new HashCodeFileNameGenerator()).imageDownloader(// default
    new BaseImageDownloader(this)).defaultDisplayImageOptions(// default
    DisplayImageOptions.createSimple()).writeDebugLogs().build();
    // 2.单例ImageLoader类的初始化
    ImageLoader imageLoader = ImageLoader.getInstance();
    imageLoader.init(config);
}
Also used : HashCodeFileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator) LruMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache) BaseImageDownloader(com.nostra13.universalimageloader.core.download.BaseImageDownloader) ImageLoader(com.nostra13.universalimageloader.core.ImageLoader) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Example 19 with ImageLoader

use of com.nostra13.universalimageloader.core.ImageLoader in project 9GAG by stormzhang.

the class App method initImageLoader.

// 初始化ImageLoader
public static void initImageLoader(Context context) {
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).threadPriority(Thread.NORM_PRIORITY - 2).denyCacheImageMultipleSizesInMemory().memoryCache(new LruMemoryCache(2 * 1024 * 1024)).discCacheSize(10 * 1024 * 1024).discCacheFileNameGenerator(new Md5FileNameGenerator()).tasksProcessingOrder(QueueProcessingType.LIFO).build();
    ImageLoader.getInstance().init(config);
}
Also used : Md5FileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator) LruMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Example 20 with ImageLoader

use of com.nostra13.universalimageloader.core.ImageLoader 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)

Aggregations

ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)20 Md5FileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator)10 ImageLoader (com.nostra13.universalimageloader.core.ImageLoader)8 LruMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache)6 BaseImageDownloader (com.nostra13.universalimageloader.core.download.BaseImageDownloader)5 File (java.io.File)5 HashCodeFileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator)4 View (android.view.View)3 UnlimitedDiskCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache)3 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)3 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 WeakMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache)2 FadeInBitmapDisplayer (com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)2 IOException (java.io.IOException)2 DataSetObserver (android.database.DataSetObserver)1 Bitmap (android.graphics.Bitmap)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 Toolbar (android.support.v7.widget.Toolbar)1