我已经使用@AppGlideModule
配置了AppGlideModule,并且想要更改此配置的日志记录级别。
例如我的应用程序的调试版本具有滑动日志记录启用/禁用选项,因此,根据用户操作,我想更改其日志记录级别
如何实现呢?
@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);
}
}
}