Search in sources :

Example 16 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).showImageOnLoading(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).showImageOnLoading(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(androidx.palette.graphics.Palette) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.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 17 with FadeInBitmapDisplayer

use of com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer 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 18 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 19 with FadeInBitmapDisplayer

use of com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer in project Slide by ccrama.

the class ImageLoaderUtils method initImageLoader.

public static void initImageLoader(Context context) {
    long discCacheSize = 1024 * 1024;
    DiskCache discCache;
    File dir = getCacheDirectory(context);
    discCacheSize *= 100;
    int threadPoolSize = 7;
    if (discCacheSize > 0) {
        try {
            dir.mkdir();
            discCache = new LruDiskCache(dir, new Md5FileNameGenerator(), discCacheSize);
        } catch (IOException e) {
            discCache = new UnlimitedDiskCache(dir);
        }
    } else {
        discCache = new UnlimitedDiskCache(dir);
    }
    options = new DisplayImageOptions.Builder().cacheOnDisk(true).bitmapConfig(SettingValues.highColorspaceImages ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565).imageScaleType(SettingValues.highColorspaceImages ? ImageScaleType.NONE_SAFE : ImageScaleType.IN_SAMPLE_POWER_OF_2).cacheInMemory(false).resetViewBeforeLoading(false).displayer(new FadeInBitmapDisplayer(250)).build();
    if (SettingValues.highColorspaceImages) {
        SubsamplingScaleImageView.setPreferredBitmapConfig(Bitmap.Config.ARGB_8888);
    }
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).threadPoolSize(threadPoolSize).denyCacheImageMultipleSizesInMemory().diskCache(discCache).threadPoolSize(4).imageDownloader(new OkHttpImageDownloader(context)).defaultDisplayImageOptions(options).build();
    if (ImageLoader.getInstance().isInited()) {
        ImageLoader.getInstance().destroy();
    }
    imageLoader = ImageLoaderUnescape.getInstance();
    imageLoader.init(config);
}
Also used : Md5FileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator) IOException(java.io.IOException) DiskCache(com.nostra13.universalimageloader.cache.disc.DiskCache) UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) LruDiskCache(com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache) UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) FadeInBitmapDisplayer(com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer) LruDiskCache(com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Aggregations

FadeInBitmapDisplayer (com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer)19 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)13 ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)10 File (java.io.File)6 UnlimitedDiskCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache)5 BitmapFactory (android.graphics.BitmapFactory)4 View (android.view.View)4 Md5FileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator)4 HashCodeFileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator)3 LruMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache)3 ActionBar (android.app.ActionBar)2 Tab (android.app.ActionBar.Tab)2 Bitmap (android.graphics.Bitmap)2 SpannableString (android.text.SpannableString)2 TypedValue (android.util.TypedValue)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 Palette (androidx.palette.graphics.Palette)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 ArtistInfoListener (com.naman14.timber.lastfmapi.callbacks.ArtistInfoListener)2