Search in sources :

Example 1 with Builder

use of com.nostra13.universalimageloader.core.DisplayImageOptions.Builder in project UltimateAndroid by cymcsg.

the class UniversalImageLoader method getDefaultImageLoaderConfiguration.

public static ImageLoaderConfiguration getDefaultImageLoaderConfiguration(Context context, boolean isWriteLog) {
    ImageLoaderConfiguration.Builder builder = getDefaultImageLoaderConfigurationBuilder(context);
    if (isWriteLog) {
        builder.writeDebugLogs();
    }
    ImageLoaderConfiguration config = builder.build();
    return config;
}
Also used : ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration)

Example 2 with Builder

use of com.nostra13.universalimageloader.core.DisplayImageOptions.Builder in project UltimateAndroid by cymcsg.

the class UniversalImageLoader method getDefaultImageLoaderConfigurationBuilder.

public static ImageLoaderConfiguration.Builder getDefaultImageLoaderConfigurationBuilder(Context context) {
    File cacheDir = StorageUtils.getCacheDirectory(context);
    ImageLoaderConfiguration.Builder builder = new ImageLoaderConfiguration.Builder(context).threadPoolSize(// default
    3).threadPriority(// default
    Thread.NORM_PRIORITY - 1).tasksProcessingOrder(// default
    QueueProcessingType.FIFO).denyCacheImageMultipleSizesInMemory().memoryCacheSizePercentage(// default
    13).discCache(// default
    new UnlimitedDiscCache(cacheDir)).discCacheFileCount(1000).discCacheFileNameGenerator(// default
    new HashCodeFileNameGenerator()).imageDownloader(// default
    new BaseImageDownloader(context)).imageDecoder(// default
    new BaseImageDecoder(false)).defaultDisplayImageOptions(getDefaultImageOptions());
    return builder;
}
Also used : UnlimitedDiscCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache) HashCodeFileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator) BaseImageDownloader(com.nostra13.universalimageloader.core.download.BaseImageDownloader) File(java.io.File) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) BaseImageDecoder(com.nostra13.universalimageloader.core.decode.BaseImageDecoder)

Example 3 with Builder

use of com.nostra13.universalimageloader.core.DisplayImageOptions.Builder in project Memento-Calendar by alexstyl.

the class UILImageLoader method load.

@NonNull
@Override
public Request load(@NonNull final URI imagePath) {
    final DisplayImageOptions.Builder builder = standardBuilder();
    return new Request() {

        @Override
        public void into(@NonNull ImageView imageView) {
            uil.displayImage(imagePath.toString(), imageView, builder.build());
        }

        @NonNull
        @Override
        public Request asCircle() {
            builder.displayer(defaultCircleDisplayer);
            return this;
        }

        @NonNull
        @Override
        public FixedSizeRequest withSize(@Px final int width, @Px final int height) {
            builder.displayer(DefaultConfigurationFactory.createBitmapDisplayer());
            return new FixedSizeRequest() {

                @NonNull
                @Override
                public Optional<Bitmap> synchronously() {
                    Bitmap bitmap = uil.loadImageSync(imagePath.toString(), new ImageSize(width, height), builder.build());
                    if (bitmap == null) {
                        return Optional.Companion.absent();
                    } else {
                        return new Optional<>(bitmap);
                    }
                }

                @Override
                public void into(@NonNull final ImageLoadedConsumer consumer) {
                    builder.displayer(DefaultConfigurationFactory.createBitmapDisplayer());
                    uil.loadImage(imagePath.toString(), builder.build(), new SimpleImageLoadingListener() {

                        @Override
                        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                            consumer.onImageLoaded(loadedImage);
                        }

                        @Override
                        public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
                            consumer.onLoadingFailed();
                        }
                    });
                }
            };
        }
    };
}
Also used : Optional(com.alexstyl.specialdates.Optional) ImageSize(com.nostra13.universalimageloader.core.assist.ImageSize) Px(android.support.annotation.Px) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View) SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) NonNull(android.support.annotation.NonNull) ImageView(android.widget.ImageView) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) NonNull(android.support.annotation.NonNull)

Example 4 with Builder

use of com.nostra13.universalimageloader.core.DisplayImageOptions.Builder in project LibreraReader by foobnix.

the class IMG method init.

public static void init(Context context) {
    IMG.context = context;
    bookBGWithMark = context.getResources().getDrawable(R.drawable.bookeffect2);
    bookBGNoMark = context.getResources().getDrawable(R.drawable.bookeffect1);
    final Builder builder = new DisplayImageOptions.Builder();
    builder.cacheInMemory(true);
    builder.cacheOnDisk(true);
    builder.showImageOnLoading(COLOR_DRAWABLE);
    builder.showImageOnFail(COLOR_DRAWABLE);
    builder.showImageForEmptyUri(COLOR_DRAWABLE);
    builder.bitmapConfig(BMP_CFG);
    builder.imageScaleType(ImageScaleType.NONE);
    builder.resetViewBeforeLoading(RESET_VIEW_BEFORE_LOADING);
    builder.considerExifParams(false);
    builder.decodingOptions(new Options());
    final ImageLoaderConfiguration config = // 
    new ImageLoaderConfiguration.Builder(context).threadPoolSize(// 
    1).threadPriority(// 
    Thread.NORM_PRIORITY).defaultDisplayImageOptions(// 
    builder.build()).diskCache(// 
    new UnlimitedDiskCache(new File(context.getExternalCacheDir(), "Images-1"))).imageDownloader(// 
    ImageExtractor.getInstance(context)).build();
    ImageLoader.getInstance().init(config);
}
Also used : DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) Options(android.graphics.BitmapFactory.Options) UnlimitedDiskCache(com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache) Builder(com.nostra13.universalimageloader.core.DisplayImageOptions.Builder) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) File(java.io.File)

Example 5 with Builder

use of com.nostra13.universalimageloader.core.DisplayImageOptions.Builder in project Timber by naman14.

the class AlbumDetailFragment method setAlbumart.

private void setAlbumart() {
    ImageUtils.loadAlbumArtIntoView(album.id, albumArt, new ImageLoadingListener() {

        @Override
        public void onLoadingStarted(String imageUri, View view) {
        }

        @Override
        public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            loadFailed = true;
            MaterialDrawableBuilder builder = MaterialDrawableBuilder.with(context).setIcon(MaterialDrawableBuilder.IconValue.SHUFFLE).setColor(TimberUtils.getBlackWhiteColor(Config.accentColor(context, Helpers.getATEKey(context))));
            ATEUtils.setFabBackgroundTint(fab, Config.accentColor(context, Helpers.getATEKey(context)));
            fab.setImageDrawable(builder.build());
        }

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            try {
                new Palette.Builder(loadedImage).generate(new Palette.PaletteAsyncListener() {

                    @Override
                    public void onGenerated(Palette palette) {
                        Palette.Swatch swatch = palette.getVibrantSwatch();
                        if (swatch != null) {
                            primaryColor = swatch.getRgb();
                            collapsingToolbarLayout.setContentScrimColor(primaryColor);
                            if (getActivity() != null)
                                ATEUtils.setStatusBarColor(getActivity(), Helpers.getATEKey(getActivity()), primaryColor);
                        } else {
                            Palette.Swatch swatchMuted = palette.getMutedSwatch();
                            if (swatchMuted != null) {
                                primaryColor = swatchMuted.getRgb();
                                collapsingToolbarLayout.setContentScrimColor(primaryColor);
                                if (getActivity() != null)
                                    ATEUtils.setStatusBarColor(getActivity(), Helpers.getATEKey(getActivity()), primaryColor);
                            }
                        }
                        if (getActivity() != null) {
                            MaterialDrawableBuilder builder = MaterialDrawableBuilder.with(getActivity()).setIcon(MaterialDrawableBuilder.IconValue.SHUFFLE).setSizeDp(30);
                            if (primaryColor != -1) {
                                builder.setColor(TimberUtils.getBlackWhiteColor(primaryColor));
                                ATEUtils.setFabBackgroundTint(fab, primaryColor);
                                fab.setImageDrawable(builder.build());
                            } else {
                                if (context != null) {
                                    ATEUtils.setFabBackgroundTint(fab, Config.accentColor(context, Helpers.getATEKey(context)));
                                    builder.setColor(TimberUtils.getBlackWhiteColor(Config.accentColor(context, Helpers.getATEKey(context))));
                                    fab.setImageDrawable(builder.build());
                                }
                            }
                        }
                    }
                });
            } catch (Exception ignored) {
            }
        }

        @Override
        public void onLoadingCancelled(String imageUri, View view) {
        }
    });
}
Also used : Palette(androidx.palette.graphics.Palette) Bitmap(android.graphics.Bitmap) ImageLoadingListener(com.nostra13.universalimageloader.core.listener.ImageLoadingListener) MaterialDrawableBuilder(net.steamcrafted.materialiconlib.MaterialDrawableBuilder) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) MaterialDrawableBuilder(net.steamcrafted.materialiconlib.MaterialDrawableBuilder)

Aggregations

ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)4 File (java.io.File)3 Bitmap (android.graphics.Bitmap)2 View (android.view.View)2 ImageView (android.widget.ImageView)2 UnlimitedDiscCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiscCache)2 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)2 FailReason (com.nostra13.universalimageloader.core.assist.FailReason)2 Options (android.graphics.BitmapFactory.Options)1 NonNull (android.support.annotation.NonNull)1 Px (android.support.annotation.Px)1 TextView (android.widget.TextView)1 Palette (androidx.palette.graphics.Palette)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 Optional (com.alexstyl.specialdates.Optional)1 UnlimitedDiskCache (com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache)1 HashCodeFileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator)1 Md5FileNameGenerator (com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator)1 WeakMemoryCache (com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache)1 Builder (com.nostra13.universalimageloader.core.DisplayImageOptions.Builder)1