All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bumptech.glide.util.FixedPreloadSizeProvider Maven / Gradle / Ivy

Go to download

A fast and efficient image loading library for Android focused on smooth scrolling.

There is a newer version: 5.0.0-rc01
Show newest version
package com.bumptech.glide.util;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bumptech.glide.ListPreloader;

/**
 * A {@link com.bumptech.glide.ListPreloader.PreloadSizeProvider} with a fixed width and height.
 *
 * @param  The type of the model the size should be provided for.
 */
public class FixedPreloadSizeProvider implements ListPreloader.PreloadSizeProvider {

  private final int[] size;

  /**
   * Constructor for a PreloadSizeProvider with a fixed size.
   *
   * @param width The width of the preload size in pixels.
   * @param height The height of the preload size in pixels.
   */
  public FixedPreloadSizeProvider(int width, int height) {
    this.size = new int[] {width, height};
  }

  @Nullable
  @Override
  // It's better to take on the risk that callers may mutate the array when there isn't any reason
  // for them to do so than it the performance overhead of copying the array with every call.
  @SuppressWarnings("PMD.MethodReturnsInternalArray")
  public int[] getPreloadSize(@NonNull T item, int adapterPosition, int itemPosition) {
    return size;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy