Search in sources :

Example 11 with DisplayImageOptions

use of com.nostra13.universalimageloader.core.DisplayImageOptions in project SeaStar by 13120241790.

the class SealFragment method configImageLoader.

private void configImageLoader() {
    // 初始化ImageLoader
    DisplayImageOptions options = // 设置图片下载期间显示的图片
    new DisplayImageOptions.Builder().showStubImage(drawable.icon_stub).showImageForEmptyUri(// 设置图片Uri为空或是错误的时候显示的图片
    drawable.icon_stub).showImageOnFail(// 设置图片加载或解码过程中发生错误显示的图片
    drawable.icon_stub).cacheInMemory(// 设置下载的图片是否缓存在内存中
    true).cacheOnDisc(// 设置下载的图片是否缓存在SD卡中
    true).build();
    // 创建配置过得DisplayImageOption对象
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getContext()).defaultDisplayImageOptions(options).threadPriority(Thread.NORM_PRIORITY - 2).denyCacheImageMultipleSizesInMemory().discCacheFileNameGenerator(new Md5FileNameGenerator()).tasksProcessingOrder(QueueProcessingType.LIFO).build();
    ImageLoader.getInstance().init(config);
}
Also used : Md5FileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 12 with DisplayImageOptions

use of com.nostra13.universalimageloader.core.DisplayImageOptions in project ABPlayer by winkstu.

the class HomePageFragment method initImageLoader.

private void initImageLoader() {
    File cacheDir = com.nostra13.universalimageloader.utils.StorageUtils.getOwnCacheDirectory(this.getActivity().getApplicationContext(), IMAGE_CACHE_PATH);
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisc(true).build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this.getActivity()).defaultDisplayImageOptions(defaultOptions).memoryCache(new LruMemoryCache(12 * 1024 * 1024)).memoryCacheSize(12 * 1024 * 1024).discCacheSize(32 * 1024 * 1024).discCacheFileCount(100).discCache(new UnlimitedDiscCache(cacheDir)).threadPriority(Thread.NORM_PRIORITY - 2).tasksProcessingOrder(QueueProcessingType.LIFO).build();
    ImageLoader.getInstance().init(config);
}
Also used : UnlimitedDiscCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache) LruMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 13 with DisplayImageOptions

use of com.nostra13.universalimageloader.core.DisplayImageOptions in project fresco by facebook.

the class SampleUilFactory method getImageLoader.

public static ImageLoader getImageLoader(Context context) {
    if (sImageLoader == null) {
        DisplayImageOptions displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(Drawables.sPlaceholderDrawable).showImageOnFail(Drawables.sErrorDrawable).cacheInMemory(true).cacheOnDisk(true).build();
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).defaultDisplayImageOptions(displayImageOptions).diskCacheSize(ConfigConstants.MAX_DISK_CACHE_SIZE).memoryCacheSize(ConfigConstants.MAX_MEMORY_CACHE_SIZE).build();
        sImageLoader = ImageLoader.getInstance();
        sImageLoader.init(config);
    }
    return sImageLoader;
}
Also used : ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 14 with DisplayImageOptions

use of com.nostra13.universalimageloader.core.DisplayImageOptions in project android-ui-design-pattern by MathieuCalba.

the class UIDesignPatternApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    final DisplayImageOptions defaultDisplayImageOptions = //
    new DisplayImageOptions.Builder().cacheInMemory().cacheOnDisc().displayer(//
    new FadeInBitmapDisplayer(250)).showImageForEmptyUri(//
    R.drawable.ic_launcher).showStubImage(//
    R.drawable.ic_launcher).build();
    final File cacheDir = StorageUtils.getOwnCacheDirectory(getApplicationContext(), "YANA/ImageCache");
    final ImageLoaderConfiguration config = //
    new ImageLoaderConfiguration.Builder(getApplicationContext()).defaultDisplayImageOptions(//
    defaultDisplayImageOptions).discCache(//
    new TotalSizeLimitedDiscCache(cacheDir, new Md5FileNameGenerator(), 10 * 1024 * 1024)).imageDownloader(//
    new URLConnectionImageDownloader()).memoryCacheSize(// 2 Mb
    2 * 1024 * 1024).tasksProcessingOrder(//
    QueueProcessingType.LIFO).threadPoolSize(//
    3).threadPriority(//
    Thread.NORM_PRIORITY - 2).build();
    ImageLoader.getInstance().init(config);
}
Also used : TotalSizeLimitedDiscCache(com.nostra13.universalimageloader.cache.disc.impl.TotalSizeLimitedDiscCache) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) Md5FileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) URLConnectionImageDownloader(com.nostra13.universalimageloader.core.download.URLConnectionImageDownloader) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Example 15 with DisplayImageOptions

use of com.nostra13.universalimageloader.core.DisplayImageOptions in project JamsMusicPlayer by psaravan.

the class StackRemoteViewsFactory method getViewAt.

@Override
public RemoteViews getViewAt(int position) {
    RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.large_widget_listview_layout);
    if (position <= getCount()) {
        try {
            if (mApp.getService().getPlaybackIndecesList() != null && mApp.getService().getPlaybackIndecesList().size() != 0) {
                if (cursor.getCount() > mApp.getService().getPlaybackIndecesList().get(position)) {
                    cursor.moveToPosition(mApp.getService().getPlaybackIndecesList().get(position));
                } else {
                    return null;
                }
            } else {
                return null;
            }
        } catch (Exception e) {
            return null;
        }
        //Set the song title, album, and artist fields.
        String songTitle = cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_TITLE));
        String songAlbumArtPath = cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_ALBUM_ART_PATH));
        ImageSize imageSize = new ImageSize(100, 100);
        //Set the duration of the song.
        long songDurationInMillis = 0;
        try {
            songDurationInMillis = Long.parseLong(cursor.getString(cursor.getColumnIndex(DBAccessHelper.SONG_DURATION)));
        } catch (Exception e) {
            songDurationInMillis = 0;
        }
        rv.setTextViewText(R.id.widget_listview_song_name, songTitle);
        rv.setTextViewText(R.id.widget_listview_duration, convertMillisToMinsSecs(songDurationInMillis));
        if (mWidgetColor.equals("LIGHT")) {
            rv.setTextColor(R.id.widget_listview_song_name, Color.BLACK);
            rv.setTextColor(R.id.widget_listview_duration, Color.BLACK);
        }
        Bitmap bitmap = mApp.getImageLoader().loadImageSync(songAlbumArtPath, imageSize, displayImageOptions);
        rv.setImageViewBitmap(R.id.widget_listview_thumbnail, bitmap);
    }
    /* This intent latches itself onto the pendingIntentTemplate from 
         * LargeWidgetProvider.java and adds the extra "INDEX" argument to it. */
    Intent fillInIntent = new Intent();
    fillInIntent.putExtra("INDEX", position);
    rv.setOnClickFillInIntent(R.id.widget_listview_layout, fillInIntent);
    return rv;
}
Also used : RemoteViews(android.widget.RemoteViews) Bitmap(android.graphics.Bitmap) ImageSize(com.nostra13.universalimageloader.core.assist.ImageSize) Intent(android.content.Intent)

Aggregations

DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)21 ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)15 FadeInBitmapDisplayer (com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)9 LruMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache)7 File (java.io.File)7 Bitmap (android.graphics.Bitmap)4 BitmapFactory (android.graphics.BitmapFactory)4 View (android.view.View)4 Md5FileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator)4 UnlimitedDiscCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache)3 UnlimitedDiskCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache)3 ImageSize (com.nostra13.universalimageloader.core.assist.ImageSize)3 ActionBar (android.app.ActionBar)2 Tab (android.app.ActionBar.Tab)2 Intent (android.content.Intent)2 SpannableString (android.text.SpannableString)2 TypedValue (android.util.TypedValue)2 ImageView (android.widget.ImageView)2 DBAccessHelper (com.jams.music.player.DBHelpers.DBAccessHelper)2 HashCodeFileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator)2