Search in sources :

Example 11 with FadeInBitmapDisplayer

use of com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer in project QuickAndroid by ImKarl.

the class QAImageLoaderConfig method getConfig.

/**
     * 获取加载配置
     * @param context
     * @param imageOnLoadingRes 加载中显示的图片
     * @param imageOnFailRes 加载失败显示的图片
     * @return
     */
public static ImageLoaderConfiguration getConfig(Context context, int imageOnLoadingRes, int imageOnFailRes) {
    DisplayImageOptions options = new DisplayImageOptions.Builder().showImageOnLoading(// 加载中
    imageOnLoadingRes).showImageForEmptyUri(// 图片Uri为空或是错误的时候显示的图片
    imageOnFailRes).showImageOnFail(// resource or drawable
    imageOnFailRes).resetViewBeforeLoading(// default
    false).delayBeforeLoading(// 加载前延迟时长
    50).cacheInMemory(// default = false 是否使用内存缓存
    true).cacheOnDisk(// default = false 是否使用文件缓存
    true).considerExifParams(// default = false
    false).imageScaleType(// default
    ImageScaleType.IN_SAMPLE_POWER_OF_2).bitmapConfig(// default
    Bitmap.Config.ARGB_8888).displayer(// default = new SimpleBitmapDisplayer()
    new FadeInBitmapDisplayer(100)).build();
    File cacheDir = new File(QAFileManager.getUsableDir(context.getPackageName()));
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).threadPoolSize(// default 线程池大小
    3).threadPriority(// default 线程优先级
    Thread.NORM_PRIORITY - 2).denyCacheImageMultipleSizesInMemory().memoryCache(// 内存缓存
    new LruMemoryCache(8 * 1024 * 1024)).diskCache(// default 磁盘缓存
    new UnlimitedDiskCache(cacheDir)).diskCacheSize(// 磁盘缓存大小
    30 * 1024 * 1024).diskCacheFileNameGenerator(// default 磁盘缓存文件名
    new HashCodeFileNameGenerator()).imageDownloader(// default 图片下载器
    new BaseImageDownloader(context)).imageDecoder(// default 图片解码器
    new BaseImageDecoder(QACore.isDebug())).defaultDisplayImageOptions(// default=DisplayImageOptions.createSimple() 图片显示选项
    options).build();
    return config;
}
Also used : UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) HashCodeFileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) LruMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache) BaseImageDownloader(com.nostra13.universalimageloader.core.download.BaseImageDownloader) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) BaseImageDecoder(com.nostra13.universalimageloader.core.decode.BaseImageDecoder)

Example 12 with FadeInBitmapDisplayer

use of com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer in project Timber by naman14.

the class ArtistAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final ItemHolder itemHolder, int i) {
    final Artist localItem = arraylist.get(i);
    itemHolder.name.setText(localItem.name);
    String albumNmber = TimberUtils.makeLabel(mContext, R.plurals.Nalbums, localItem.albumCount);
    String songCount = TimberUtils.makeLabel(mContext, R.plurals.Nsongs, localItem.songCount);
    itemHolder.albums.setText(TimberUtils.makeCombinedString(mContext, albumNmber, songCount));
    LastFmClient.getInstance(mContext).getArtistInfo(new ArtistQuery(localItem.name), new ArtistInfoListener() {

        @Override
        public void artistInfoSucess(LastfmArtist artist) {
            if (artist != null && artist.mArtwork != null) {
                if (isGrid) {
                    ImageLoader.getInstance().displayImage(artist.mArtwork.get(2).mUrl, itemHolder.artistImage, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build(), new SimpleImageLoadingListener() {

                        @Override
                        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                            if (isGrid && loadedImage != null) {
                                new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {

                                    @Override
                                    public void onGenerated(Palette palette) {
                                        int color = palette.getVibrantColor(Color.parseColor("#66000000"));
                                        itemHolder.footer.setBackgroundColor(color);
                                        Palette.Swatch swatch = palette.getVibrantSwatch();
                                        int textColor;
                                        if (swatch != null) {
                                            textColor = getOpaqueColor(swatch.getTitleTextColor());
                                        } else
                                            textColor = Color.parseColor("#ffffff");
                                        itemHolder.name.setTextColor(textColor);
                                        itemHolder.albums.setTextColor(textColor);
                                    }
                                });
                            }
                        }

                        @Override
                        public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
                            if (isGrid) {
                                itemHolder.footer.setBackgroundColor(0);
                                if (mContext != null) {
                                    int textColorPrimary = Config.textColorPrimary(mContext, Helpers.getATEKey(mContext));
                                    itemHolder.name.setTextColor(textColorPrimary);
                                    itemHolder.albums.setTextColor(textColorPrimary);
                                }
                            }
                        }
                    });
                } else {
                    ImageLoader.getInstance().displayImage(artist.mArtwork.get(1).mUrl, itemHolder.artistImage, new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisk(true).showImageOnFail(R.drawable.ic_empty_music2).resetViewBeforeLoading(true).displayer(new FadeInBitmapDisplayer(400)).build());
                }
            }
        }

        @Override
        public void artistInfoFailed() {
        }
    });
    if (TimberUtils.isLollipop())
        itemHolder.artistImage.setTransitionName("transition_artist_art" + i);
}
Also used : LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist) Artist(com.naman14.timber.models.Artist) Palette(android.support.v7.graphics.Palette) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ArtistQuery(com.naman14.timber.lastfmapi.models.ArtistQuery) LastfmArtist(com.naman14.timber.lastfmapi.models.LastfmArtist) SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) ArtistInfoListener(com.naman14.timber.lastfmapi.callbacks.ArtistInfoListener) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)

Example 13 with FadeInBitmapDisplayer

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

the class App method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    // rongcloud 初始化
    RongIM.init(this);
    if (getApplicationInfo().packageName.equals(getCurProcessName(getApplicationContext()))) {
        RongCloudEvent.init(this);
        RongIM.registerMessageType(AgreedFriendRequestMessage.class);
        RongIM.registerMessageTemplate(new ContactNotificationMessageProvider());
    }
    // BugTags 初始化
    Bugtags.start(BUGTAGS_APPKEY, this, Bugtags.BTGInvocationEventBubble);
    //友盟session时间间隔
    MobclickAgent.setSessionContinueMillis(30 * 60 * 1000);
    //oneCore 打印参数
    NLog.setDebug(true);
    options = new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.rp_default_head).showImageOnFail(R.drawable.rp_default_head).showImageOnLoading(R.drawable.rp_default_head).displayer(new FadeInBitmapDisplayer(300)).cacheInMemory(true).cacheOnDisk(true).build();
    //初始化图片下载组件
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).threadPriority(Thread.NORM_PRIORITY - 2).denyCacheImageMultipleSizesInMemory().diskCacheSize(50 * 1024 * 1024).diskCacheFileCount(200).diskCacheFileNameGenerator(new Md5FileNameGenerator()).defaultDisplayImageOptions(options).build();
    //Initialize ImageLoader with configuration.
    ImageLoader.getInstance().init(config);
}
Also used : ContactNotificationMessageProvider(com.rongseal.message.ContactNotificationMessageProvider) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) Md5FileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Example 14 with FadeInBitmapDisplayer

use of com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer in project YourAppIdea by Michenux.

the class YourApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    this.injectSelf();
    // Enable tutorial sync
    this.tutorialSyncHelper.createTutorialAccount(this);
    // Initialize Universal Image Loader
    // Create global configuration and initialize ImageLoader with this configuration
    DisplayImageOptions options = new DisplayImageOptions.Builder().cacheInMemory(// default
    true).cacheOnDisk(// default
    true).displayer(// default SimpleBitmapDisplayer,RoundedBitmapDisplayer(10),FadeInBitmapDisplayer
    new FadeInBitmapDisplayer(5000)).build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).memoryCache(new LruMemoryCache(2 * 1024 * 1024)).memoryCacheSizePercentage(// default
    13).defaultDisplayImageOptions(// default
    options).build();
    ImageLoader.getInstance().init(config);
}
Also used : FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) LruMemoryCache(com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Aggregations

FadeInBitmapDisplayer (com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)14 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)10 ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)6 BitmapFactory (android.graphics.BitmapFactory)4 View (android.view.View)4 LruMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache)3 File (java.io.File)3 ActionBar (android.app.ActionBar)2 Tab (android.app.ActionBar.Tab)2 Bitmap (android.graphics.Bitmap)2 Palette (android.support.v7.graphics.Palette)2 RecyclerView (android.support.v7.widget.RecyclerView)2 SpannableString (android.text.SpannableString)2 TypedValue (android.util.TypedValue)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 ArtistInfoListener (com.naman14.timber.lastfmapi.callbacks.ArtistInfoListener)2 ArtistQuery (com.naman14.timber.lastfmapi.models.ArtistQuery)2 LastfmArtist (com.naman14.timber.lastfmapi.models.LastfmArtist)2 Album (com.naman14.timber.models.Album)2