GenericRequestBuilder(Context context, ModelType model, LoadProvider<ModelType, DataType, ResourceType, TranscodeType> loadProvider, Class<TranscodeType> transcodeClass, Glide glide) { this.transcodeClass = transcodeClass; this.glide = glide; this.loadProvider = loadProvider != null ? new ChildLoadProvider<ModelType, DataType, ResourceType, TranscodeType>(loadProvider) : null; preSkipEncoder = loadProvider != null ? loadProvider.getEncoder() : null; if (context == null) { throw new NullPointerException("Context can't be null"); } if (model != null && loadProvider == null) { throw new NullPointerException("LoadProvider must not be null"); } this.context = context; this.model = model; }
private static <A, T, Z, R> LoadProvider<A, T, Z, R> build(Glide glide, ModelLoader<A, T> modelLoader, Class<T> dataClass, Class<Z> resourceClass, ResourceTranscoder<Z, R> transcoder) { if (transcoder == null) { transcoder = UnitTranscoder.get(); } return new FixedLoadProvider<A, T, Z, R>(modelLoader, transcoder, glide.buildDataProvider(dataClass, resourceClass)); }
private <Z> Request buildRequestForDataType(Target<TranscodeType> target, LoadProvider<ModelType, Z, ResourceType, TranscodeType> loadProvider, float sizeMultiplier, Priority priority, RequestCoordinator requestCoordinator) { return new GenericRequest<ModelType, Z, ResourceType, TranscodeType>(loadProvider, model, context, priority, target, sizeMultiplier, placeholderDrawable, placeholderId, errorPlaceholder, errorId, requestListener, animationId, animation, requestCoordinator, glide.getEngine(), getFinalTransformation(), transcodeClass, isCacheable); }
BitmapRequestBuilder(Context context, ModelType model, LoadProvider<ModelType, ImageVideoWrapper, Bitmap, TranscodeType> streamLoadProvider, Class<TranscodeType> transcodeClass, Glide glide) { super(context, model, streamLoadProvider, transcodeClass, glide); this.bitmapPool = glide.getBitmapPool(); imageDecoder = new StreamBitmapDecoder(bitmapPool); videoDecoder = new FileDescriptorBitmapDecoder(bitmapPool); }
public GenericRequest(LoadProvider<A, T, Z, R> loadProvider, A model, Context context, Priority priority, Target<R> target, float sizeMultiplier, Drawable placeholderDrawable, int placeholderResourceId, Drawable errorDrawable, int errorResourceId, RequestListener<A> requestListener, int animationId, Animation animation, RequestCoordinator requestCoordinator, Engine engine, Transformation<Z> transformation, Class<R> transcodeClass, boolean isMemoryCacheable) { this.loadProvider = loadProvider; this.model = model; this.context = context; this.priority = priority; this.target = target; this.sizeMultiplier = sizeMultiplier; this.placeholderDrawable = placeholderDrawable; this.placeholderResourceId = placeholderResourceId; this.errorDrawable = errorDrawable; this.errorResourceId = errorResourceId; this.requestListener = requestListener; this.animationId = animationId; this.animation = animation; this.requestCoordinator = requestCoordinator; this.engine = engine; this.transformation = transformation; this.transcodeClass = transcodeClass; this.isMemoryCacheable = isMemoryCacheable; // We allow null models by just setting an error drawable. Null models will always have empty providers, we // simply skip our sanity checks in that unusual case. if (model != null) { if (loadProvider.getCacheDecoder() == null) { throw new NullPointerException("CacheDecoder must not be null, try .cacheDecoder(ResouceDecoder)"); } if (loadProvider.getSourceDecoder() == null) { throw new NullPointerException("SourceDecoder must not be null, try .imageDecoder(ResourceDecoder) " + "and/or .videoDecoder()"); } if (loadProvider.getEncoder() == null) { throw new NullPointerException("Encoder must not be null, try .encode(ResourceEncoder)"); } if (loadProvider.getTranscoder() == null) { throw new NullPointerException("Transcoder must not be null, try .as(Class, ResourceTranscoder)"); } if (loadProvider.getModelLoader() == null) { throw new NullPointerException("ModelLoader must not be null, try .using(ModelLoader)"); } } }
DrawableRequestBuilder(Context context, ModelType model, LoadProvider<ModelType, ImageVideoWrapper, GifBitmapWrapper, Drawable> loadProvider, Glide glide) { super(context, model, loadProvider, Drawable.class, glide); this.context = context; this.glide = glide; }