1

I have configured AppGlideModule using @AppGlideModule and I want to change the logging level of this configuration.
Ex. My debug version of the application has glide logging enable/disable options so, on the basis of user action I want to change its logging level How to achieve this?

@GlideModule
public final class MyGlideAppModule extends AppGlideModule {

    private static final long GLIDE_DISK_CACHE_SIZE = 50 * 1024 * 1024; // 50MB
    private static final String TAG = TivoGlideAppModule.class.getSimpleName();

    @Override
    public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {

        // Configure Memory Cache
        MemorySizeCalculator calc1 = new MemorySizeCalculator.Builder(context)
                .build();
        builder.setMemoryCache(new LruResourceCache(calc1.getMemoryCacheSize()));
        TivoLogger.d(TAG, "Glide Memory Cache:  " + calc1.getMemoryCacheSize() / (1024 * 1024) + " MB");


        // Configure Bitmap Pool
        MemorySizeCalculator calc2 = new MemorySizeCalculator.Builder(context)
                .build();
        builder.setBitmapPool(new LruBitmapPool(calc2.getBitmapPoolSize()));
        TivoLogger.d(TAG, "Glide Bitmap Pool Size:  " + calc2.getBitmapPoolSize() / (1024 * 1024) + " MB");


        // Configure Disk Cache
        builder.setDiskCache(new ExternalPreferredCacheDiskCacheFactory(context, GLIDE_DISK_CACHE_SIZE));
        TivoLogger.d(TAG, "Glide Disk Cache Size  " + GLIDE_DISK_CACHE_SIZE / (1024 * 1024) + " MB");


        // Default Request Options
        builder.setDefaultRequestOptions(
                new RequestOptions()
                        .format(DecodeFormat.PREFER_RGB_565)
                        .downsample(DownsampleStrategy.AT_MOST)
                        .skipMemoryCache(true));

        // Configure Logging level
        if (PreferenceUtils.isImageLibraryLoggingAllowed(context)) {
            builder.setLogLevel(Log.DEBUG);
        }
    }
}
Zoe
  • 27,060
  • 21
  • 118
  • 148
Gaurav
  • 99
  • 2
  • 8

0 Answers0