com.bumptech.glide.load.model.ModelLoader Java Examples

The following examples show how to use com.bumptech.glide.load.model.ModelLoader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DrawableTypeRequest.java    From giffun with Apache License 2.0 6 votes vote down vote up
private static <A, Z, R> FixedLoadProvider<A, ImageVideoWrapper, Z, R> buildProvider(Glide glide,
        ModelLoader<A, InputStream> streamModelLoader,
        ModelLoader<A, ParcelFileDescriptor> fileDescriptorModelLoader, Class<Z> resourceClass,
        Class<R> transcodedClass,
        ResourceTranscoder<Z, R> transcoder) {
    if (streamModelLoader == null && fileDescriptorModelLoader == null) {
        return null;
    }

    if (transcoder == null) {
        transcoder = glide.buildTranscoder(resourceClass, transcodedClass);
    }
    DataLoadProvider<ImageVideoWrapper, Z> dataLoadProvider = glide.buildDataProvider(ImageVideoWrapper.class,
            resourceClass);
    ImageVideoModelLoader<A> modelLoader = new ImageVideoModelLoader<A>(streamModelLoader,
            fileDescriptorModelLoader);
    return new FixedLoadProvider<A, ImageVideoWrapper, Z, R>(modelLoader, transcoder, dataLoadProvider);
}
 
Example #2
Source File: BitmapTypeRequest.java    From giffun with Apache License 2.0 6 votes vote down vote up
private static <A, R> FixedLoadProvider<A, ImageVideoWrapper, Bitmap, R> buildProvider(Glide glide,
        ModelLoader<A, InputStream> streamModelLoader,
        ModelLoader<A, ParcelFileDescriptor> fileDescriptorModelLoader,
        Class<R> transcodedClass, ResourceTranscoder<Bitmap, R> transcoder) {
    if (streamModelLoader == null && fileDescriptorModelLoader == null) {
        return null;
    }

    if (transcoder == null) {
        transcoder = glide.buildTranscoder(Bitmap.class, transcodedClass);
    }
    DataLoadProvider<ImageVideoWrapper, Bitmap> loadProvider = glide.buildDataProvider(ImageVideoWrapper.class,
            Bitmap.class);
    ImageVideoModelLoader<A> modelLoader = new ImageVideoModelLoader<A>(streamModelLoader,
            fileDescriptorModelLoader);

    return new FixedLoadProvider<A, ImageVideoWrapper, Bitmap, R>(modelLoader, transcoder, loadProvider);
}
 
Example #3
Source File: FixedLoadProvider.java    From giffun with Apache License 2.0 6 votes vote down vote up
public FixedLoadProvider(ModelLoader<A, T> modelLoader, ResourceTranscoder<Z, R> transcoder,
        DataLoadProvider<T, Z> dataLoadProvider) {
    if (modelLoader == null) {
        throw new NullPointerException("ModelLoader must not be null");
    }
    this.modelLoader = modelLoader;

    if (transcoder == null) {
        throw new NullPointerException("Transcoder must not be null");
    }
    this.transcoder = transcoder;

    if (dataLoadProvider == null) {
        throw new NullPointerException("DataLoadProvider must not be null");
    }
    this.dataLoadProvider = dataLoadProvider;
}
 
Example #4
Source File: GifTypeRequest.java    From giffun with Apache License 2.0 5 votes vote down vote up
GifTypeRequest(GenericRequestBuilder<ModelType, ?, ?, ?> other,
        ModelLoader<ModelType, InputStream> streamModelLoader, RequestManager.OptionsApplier optionsApplier) {
    super(buildProvider(other.glide, streamModelLoader, GifDrawable.class, null), GifDrawable.class, other);
    this.streamModelLoader = streamModelLoader;
    this.optionsApplier = optionsApplier;

    // Default to animating.
    crossFade();
}
 
Example #5
Source File: GifTypeRequest.java    From giffun with Apache License 2.0 5 votes vote down vote up
private static <A, R> FixedLoadProvider<A, InputStream, GifDrawable, R> buildProvider(Glide glide,
        ModelLoader<A, InputStream> streamModelLoader, Class<R> transcodeClass,
        ResourceTranscoder<GifDrawable, R> transcoder) {
    if (streamModelLoader == null) {
        return null;
    }

    if (transcoder == null) {
        transcoder = glide.buildTranscoder(GifDrawable.class, transcodeClass);
    }
    DataLoadProvider<InputStream, GifDrawable> dataLoadProvider = glide.buildDataProvider(InputStream.class,
            GifDrawable.class);
    return new FixedLoadProvider<A, InputStream, GifDrawable, R>(streamModelLoader, transcoder, dataLoadProvider);
}
 
Example #6
Source File: ArtistImageFetcher.java    From Orin with GNU General Public License v3.0 5 votes vote down vote up
public ArtistImageFetcher(Context context, LastFMRestClient lastFMRestClient, ArtistImage model, ModelLoader<GlideUrl, InputStream> urlLoader, int width, int height) {
    this.context = context;
    this.lastFMRestClient = lastFMRestClient;
    this.model = model;
    this.urlLoader = urlLoader;
    this.width = width;
    this.height = height;
}
 
Example #7
Source File: GenericRequest.java    From giffun with Apache License 2.0 5 votes vote down vote up
/**
 * A callback method that should never be invoked directly.
 */
@Override
public void onSizeReady(int width, int height) {
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        logV("Got onSizeReady in " + LogTime.getElapsedMillis(startTime));
    }
    if (status != Status.WAITING_FOR_SIZE) {
        return;
    }
    status = Status.RUNNING;

    width = Math.round(sizeMultiplier * width);
    height = Math.round(sizeMultiplier * height);

    ModelLoader<A, T> modelLoader = loadProvider.getModelLoader();
    final DataFetcher<T> dataFetcher = modelLoader.getResourceFetcher(model, width, height);

    if (dataFetcher == null) {
        onException(new Exception("Failed to load model: \'" + model + "\'"));
        return;
    }
    ResourceTranscoder<Z, R> transcoder = loadProvider.getTranscoder();
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        logV("finished setup for calling load in " + LogTime.getElapsedMillis(startTime));
    }
    loadedFromMemoryCache = true;
    loadStatus = engine.load(signature, width, height, dataFetcher, loadProvider, transformation, transcoder,
            priority, isMemoryCacheable, diskCacheStrategy, this);
    loadedFromMemoryCache = resource != null;
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        logV("finished onSizeReady in " + LogTime.getElapsedMillis(startTime));
    }
}
 
Example #8
Source File: BitmapTypeRequest.java    From giffun with Apache License 2.0 5 votes vote down vote up
BitmapTypeRequest(GenericRequestBuilder<ModelType, ?, ?, ?> other,
        ModelLoader<ModelType, InputStream> streamModelLoader,
        ModelLoader<ModelType, ParcelFileDescriptor> fileDescriptorModelLoader,
        RequestManager.OptionsApplier optionsApplier) {
    super(buildProvider(other.glide, streamModelLoader, fileDescriptorModelLoader, Bitmap.class, null),
            Bitmap.class, other);
    this.streamModelLoader = streamModelLoader;
    this.fileDescriptorModelLoader = fileDescriptorModelLoader;
    this.glide = other.glide;
    this.optionsApplier = optionsApplier;
}
 
Example #9
Source File: RequestManager.java    From giffun with Apache License 2.0 5 votes vote down vote up
private <T> DrawableTypeRequest<T> loadGeneric(Class<T> modelClass) {
    ModelLoader<T, InputStream> streamModelLoader = Glide.buildStreamModelLoader(modelClass, context);
    ModelLoader<T, ParcelFileDescriptor> fileDescriptorModelLoader =
            Glide.buildFileDescriptorModelLoader(modelClass, context);
    if (modelClass != null && streamModelLoader == null && fileDescriptorModelLoader == null) {
        throw new IllegalArgumentException("Unknown type " + modelClass + ". You must provide a Model of a type for"
                + " which there is a registered ModelLoader, if you are using a custom model, you must first call"
                + " Glide#register with a ModelLoaderFactory for your custom model class");
    }

    return optionsApplier.apply(
            new DrawableTypeRequest<T>(modelClass, streamModelLoader, fileDescriptorModelLoader, context,
                    glide, requestTracker, lifecycle, optionsApplier));
}
 
Example #10
Source File: ArtistImageFetcher.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
public ArtistImageFetcher(Context context, LastFMRestClient lastFMRestClient, ArtistImage model, ModelLoader<GlideUrl, InputStream> urlLoader, int width, int height) {
    this.context = context;
    this.lastFMRestClient = lastFMRestClient;
    this.model = model;
    this.urlLoader = urlLoader;
    this.width = width;
    this.height = height;
}
 
Example #11
Source File: ArtistImageFetcher.java    From MusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
public ArtistImageFetcher(LastFMRestClient lastFMRestClient, ArtistImage model, ModelLoader<GlideUrl, InputStream> urlLoader, int width, int height, Options options) {
    this.lastFMRestClient = lastFMRestClient;
    this.model = model;
    this.urlLoader = urlLoader;
    this.width = width;
    this.height = height;
    mOption = options;
    mLoadOriginal = model.mLoadOriginal;
    mImageNumber = model.mImageNumber;
}
 
Example #12
Source File: DrawableTypeRequest.java    From giffun with Apache License 2.0 5 votes vote down vote up
DrawableTypeRequest(Class<ModelType> modelClass, ModelLoader<ModelType, InputStream> streamModelLoader,
        ModelLoader<ModelType, ParcelFileDescriptor> fileDescriptorModelLoader, Context context, Glide glide,
        RequestTracker requestTracker, Lifecycle lifecycle, RequestManager.OptionsApplier optionsApplier) {
    super(context, modelClass,
            buildProvider(glide, streamModelLoader, fileDescriptorModelLoader, GifBitmapWrapper.class,
                    GlideDrawable.class, null),
            glide, requestTracker, lifecycle);
    this.streamModelLoader = streamModelLoader;
    this.fileDescriptorModelLoader = fileDescriptorModelLoader;
    this.optionsApplier = optionsApplier;
}
 
Example #13
Source File: GenericTranscodeRequest.java    From giffun with Apache License 2.0 5 votes vote down vote up
GenericTranscodeRequest(
        Class<ResourceType> transcodeClass, GenericRequestBuilder<ModelType, ?, ?, ?> other,
        ModelLoader<ModelType, DataType> modelLoader, Class<DataType> dataClass, Class<ResourceType> resourceClass,
        RequestManager.OptionsApplier optionsApplier) {
    super(build(other.glide, modelLoader, dataClass, resourceClass, UnitTranscoder.<ResourceType>get()),
            transcodeClass, other);
    this.modelLoader = modelLoader;
    this.dataClass = dataClass;
    this.resourceClass = resourceClass;
    this.optionsApplier = optionsApplier;
}
 
Example #14
Source File: ContactPhotoLoader.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ModelLoader<ContactPhoto, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new ContactPhotoLoader(context);
}
 
Example #15
Source File: ArtistImageLoader.java    From MusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
public ArtistImageLoader(LastFMRestClient lastFMRestClient, ModelLoader<GlideUrl, InputStream> urlLoader) {
    this.lastFMClient = lastFMRestClient;
    this.urlLoader = urlLoader;
}
 
Example #16
Source File: DecryptableStreamUriLoader.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ModelLoader<DecryptableUri, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new DecryptableStreamUriLoader(context);
}
 
Example #17
Source File: AudioFileCoverLoader.java    From VinylMusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
@Override
@NonNull
public ModelLoader<AudioFileCover, InputStream> build(@NonNull MultiModelLoaderFactory multiFactory) {
    return new AudioFileCoverLoader();
}
 
Example #18
Source File: AudioFileCoverLoader.java    From Orin with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ModelLoader<AudioFileCover, InputStream> build(Context context, GenericLoaderFactory factories) {
    return new AudioFileCoverLoader();
}
 
Example #19
Source File: OkHttpUrlLoader.java    From TestChat with Apache License 2.0 4 votes vote down vote up
@Override
public ModelLoader<GlideUrl, InputStream> build(Context context, GenericLoaderFactory factories) {
    return new OkHttpUrlLoader(client);
}
 
Example #20
Source File: ArtistImageLoader.java    From Orin with GNU General Public License v3.0 4 votes vote down vote up
public ArtistImageLoader(Context context, LastFMRestClient lastFMRestClient, ModelLoader<GlideUrl, InputStream> urlLoader) {
    this.context = context;
    this.lastFMClient = lastFMRestClient;
    this.urlLoader = urlLoader;
}
 
Example #21
Source File: OkHttpUrlLoader.java    From imsdk-android with MIT License 4 votes vote down vote up
@Override
public ModelLoader<GlideUrl, InputStream> build(Context context, GenericLoaderFactory factories) {
    return new OkHttpUrlLoader(client);
}
 
Example #22
Source File: OkHttpUrlLoader.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new OkHttpUrlLoader(client);
}
 
Example #23
Source File: AppIconGlideModule.java    From SoloPi with Apache License 2.0 4 votes vote down vote up
@NonNull
@Override
public ModelLoader<String, ByteBuffer> build(@NonNull MultiModelLoaderFactory multiFactory) {
    return new ApkIconModelLoader(context);
}
 
Example #24
Source File: FixedLoadProvider.java    From giffun with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ModelLoader<A, T> getModelLoader() {
    return modelLoader;
}
 
Example #25
Source File: ChildLoadProvider.java    From giffun with Apache License 2.0 4 votes vote down vote up
@Override
public ModelLoader<A, T> getModelLoader() {
    return parent.getModelLoader();
}
 
Example #26
Source File: FileDescriptorResourceLoader.java    From giffun with Apache License 2.0 4 votes vote down vote up
public FileDescriptorResourceLoader(Context context, ModelLoader<Uri, ParcelFileDescriptor> uriLoader) {
    super(context, uriLoader);
}
 
Example #27
Source File: FileDescriptorResourceLoader.java    From giffun with Apache License 2.0 4 votes vote down vote up
@Override
public ModelLoader<Integer, ParcelFileDescriptor> build(Context context, GenericLoaderFactory factories) {
    return new FileDescriptorResourceLoader(context, factories.buildModelLoader(Uri.class,
            ParcelFileDescriptor.class));
}
 
Example #28
Source File: FileDescriptorUriLoader.java    From giffun with Apache License 2.0 4 votes vote down vote up
public FileDescriptorUriLoader(Context context, ModelLoader<GlideUrl, ParcelFileDescriptor> urlLoader) {
    super(context, urlLoader);
}
 
Example #29
Source File: FileDescriptorUriLoader.java    From giffun with Apache License 2.0 4 votes vote down vote up
@Override
public ModelLoader<Uri, ParcelFileDescriptor> build(Context context, GenericLoaderFactory factories) {
    return new FileDescriptorUriLoader(context, factories.buildModelLoader(GlideUrl.class,
            ParcelFileDescriptor.class));
}
 
Example #30
Source File: FileDescriptorStringLoader.java    From giffun with Apache License 2.0 4 votes vote down vote up
public FileDescriptorStringLoader(ModelLoader<Uri, ParcelFileDescriptor> uriLoader) {
    super(uriLoader);
}