congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
MemorySizeCalculator$Builder
Code IndexAdd Tabnine to your IDE (free)

How to use
MemorySizeCalculator$Builder
in
com.bumptech.glide.load.engine.cache

Best Java code snippets using com.bumptech.glide.load.engine.cache.MemorySizeCalculator$Builder (Showing top 7 results out of 315)

origin: bumptech/glide

MemorySizeCalculator getCalculator() {
 when(screenDimensions.getWidthPixels()).thenReturn(pixelSize);
 when(screenDimensions.getHeightPixels()).thenReturn(pixelSize);
 return new MemorySizeCalculator.Builder(RuntimeEnvironment.application)
   .setMemoryCacheScreens(memoryCacheScreens)
   .setBitmapPoolScreens(bitmapPoolScreens)
   .setMaxSizeMultiplier(sizeMultiplier)
   .setActivityManager(activityManager)
   .setScreenDimensions(screenDimensions)
   .setArrayPoolSize(byteArrayPoolSizeBytes)
   .build();
}
origin: mozilla-tw/Rocket

memorySizeCalculator = new MemorySizeCalculator.Builder(context).build();
origin: JessYanCoding/MVPArt

@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
  final AppComponent appComponent = ArtUtils.obtainAppComponentFromContext(context);
  builder.setDiskCache(new DiskCache.Factory() {
    @Override
    public DiskCache build() {
      // Careful: the external cache directory doesn't enforce permissions
      return DiskLruCacheWrapper.create(DataHelper.makeDirs(new File(appComponent.cacheFile(), "Glide")), IMAGE_DISK_CACHE_MAX_SIZE);
    }
  });
  MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context).build();
  int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
  int defaultBitmapPoolSize = calculator.getBitmapPoolSize();
  int customMemoryCacheSize = (int) (1.2 * defaultMemoryCacheSize);
  int customBitmapPoolSize = (int) (1.2 * defaultBitmapPoolSize);
  builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize));
  builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize));
  //将配置 Glide 的机会转交给 GlideImageLoaderStrategy,如你觉得框架提供的 GlideImageLoaderStrategy
  //并不能满足自己的需求,想自定义 BaseImageLoaderStrategy,那请你最好实现 GlideAppliesOptions
  //因为只有成为 GlideAppliesOptions 的实现类,这里才能调用 applyGlideOptions(),让你具有配置 Glide 的权利
  BaseImageLoaderStrategy loadImgStrategy = appComponent.imageLoader().getLoadImgStrategy();
  if (loadImgStrategy != null && loadImgStrategy instanceof GlideAppliesOptions) {
    ((GlideAppliesOptions) loadImgStrategy).applyGlideOptions(context, builder);
  }
}
origin: mozilla-tw/Rocket

/**
 * Sets the {@link MemorySizeCalculator} to use to calculate maximum sizes for default
 * {@link MemoryCache MemoryCaches} and/or default {@link BitmapPool BitmapPools}.
 *
 * @see #setMemorySizeCalculator(MemorySizeCalculator)
 *
 * @param builder The builder to use (will not be modified).
 * @return This builder.
 */
public GlideBuilder setMemorySizeCalculator(MemorySizeCalculator.Builder builder) {
 return setMemorySizeCalculator(builder.build());
}
origin: bumptech/glide

memorySizeCalculator = new MemorySizeCalculator.Builder(context).build();
origin: JessYanCoding/MVPArms

@Override
public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
  final AppComponent appComponent = ArmsUtils.obtainAppComponentFromContext(context);
  builder.setDiskCache(new DiskCache.Factory() {
    @Override
    public DiskCache build() {
      // Careful: the external cache directory doesn't enforce permissions
      return DiskLruCacheWrapper.create(DataHelper.makeDirs(new File(appComponent.cacheFile(), "Glide")), IMAGE_DISK_CACHE_MAX_SIZE);
    }
  });
  MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context).build();
  int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
  int defaultBitmapPoolSize = calculator.getBitmapPoolSize();
  int customMemoryCacheSize = (int) (1.2 * defaultMemoryCacheSize);
  int customBitmapPoolSize = (int) (1.2 * defaultBitmapPoolSize);
  builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize));
  builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize));
  //将配置 Glide 的机会转交给 GlideImageLoaderStrategy,如你觉得框架提供的 GlideImageLoaderStrategy
  //并不能满足自己的需求,想自定义 BaseImageLoaderStrategy,那请你最好实现 GlideAppliesOptions
  //因为只有成为 GlideAppliesOptions 的实现类,这里才能调用 applyGlideOptions(),让你具有配置 Glide 的权利
  BaseImageLoaderStrategy loadImgStrategy = appComponent.imageLoader().getLoadImgStrategy();
  if (loadImgStrategy != null && loadImgStrategy instanceof GlideAppliesOptions) {
    ((GlideAppliesOptions) loadImgStrategy).applyGlideOptions(context, builder);
  }
}
origin: bumptech/glide

/**
 * Sets the {@link MemorySizeCalculator} to use to calculate maximum sizes for default
 * {@link MemoryCache MemoryCaches} and/or default {@link BitmapPool BitmapPools}.
 *
 * @see #setMemorySizeCalculator(MemorySizeCalculator)
 *
 * @param builder The builder to use (will not be modified).
 * @return This builder.
 */
// Public API.
@SuppressWarnings("unused")
@NonNull
public GlideBuilder setMemorySizeCalculator(@NonNull MemorySizeCalculator.Builder builder) {
 return setMemorySizeCalculator(builder.build());
}
com.bumptech.glide.load.engine.cacheMemorySizeCalculator$Builder

Javadoc

Constructs an MemorySizeCalculator with reasonable defaults that can be optionally overridden.

Most used methods

  • <init>
  • build
  • setActivityManager
  • setArrayPoolSize
    Sets the size in bytes of the com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool to use to stor
  • setBitmapPoolScreens
  • setMaxSizeMultiplier
  • setMemoryCacheScreens
    Sets the number of device screens worth of pixels the com.bumptech.glide.load.engine.cache.MemoryCac
  • setScreenDimensions

Popular in Java

  • Creating JSON documents from java classes using gson
  • getResourceAsStream (ClassLoader)
  • findViewById (Activity)
  • onCreateOptionsMenu (Activity)
  • Kernel (java.awt.image)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now