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

The following examples show how to use com.bumptech.glide.load.model.ModelLoaderFactory. 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: GlideVolleyRequestExecutor.java    From RecyclerAdapterBase with Apache License 2.0 4 votes vote down vote up
@Override
public ModelLoaderFactory<GlideUrl, InputStream> createUrlLoaderFactory() {
	return new VolleyUrlLoader.Factory(getRequestQueue());
}
 
Example #2
Source File: ExampleApiBase.java    From RecyclerAdapterBase with Apache License 2.0 4 votes vote down vote up
public static ModelLoaderFactory<GlideUrl, InputStream> createUrlLoaderFactory() {
	if(sExecutor instanceof GlideLoaderFactory) {
		return ((GlideLoaderFactory)sExecutor).createUrlLoaderFactory();
	}
	return null;
}
 
Example #3
Source File: GlideModule.java    From glide-support with The Unlicense 4 votes vote down vote up
/**
 * {@link Glide#register(Class, Class, ModelLoaderFactory) Register}'s params should be
 * {@code (Class<T>, Class<Y>, ModelLoaderFactory<? super T, Y>)}. This method works around that.
 */
@SuppressWarnings({"unchecked", "unused"})
private static <T> ModelLoaderFactory<T, InputStream> superFactory(
		ModelLoaderFactory<? super T, InputStream> factory, Class<T> modelType) {
	return (ModelLoaderFactory<T, InputStream>)factory;
}
 
Example #4
Source File: Glide.java    From giffun with Apache License 2.0 3 votes vote down vote up
/**
 * Use the given factory to build a {@link ModelLoader} for models of the given class. Generally the best use of
 * this method is to replace one of the default factories or add an implementation for other similar low level
 * models. Typically the {@link RequestManager#using(com.bumptech.glide.load.model.stream.StreamModelLoader)} or
 * {@link RequestManager#using(com.bumptech.glide.load.model.file_descriptor.FileDescriptorModelLoader)} syntax is
 * preferred because it directly links the model with the ModelLoader being used to load it. Any factory replaced
 * by the given factory will have its {@link ModelLoaderFactory#teardown()}} method called.
 *
 * <p>
 *     Note - If a factory already exists for the given class, it will be replaced. If that factory is not being
 *     used for any other model class, {@link ModelLoaderFactory#teardown()}
 *     will be called.
 * </p>
 *
 * <p>
 *     Note - The factory must not be an anonymous inner class of an Activity or another object that cannot be
 *     retained statically.
 * </p>
 *
 * @see RequestManager#using(com.bumptech.glide.load.model.file_descriptor.FileDescriptorModelLoader)
 * @see RequestManager#using(com.bumptech.glide.load.model.stream.StreamModelLoader)
 *
 * @param modelClass The model class.
 * @param resourceClass The resource class the model loader will translate the model type into.
 * @param factory The factory to use.
 * @param <T> The type of the model.
 * @param <Y> the type of the resource.
 */
public <T, Y> void register(Class<T> modelClass, Class<Y> resourceClass, ModelLoaderFactory<T, Y> factory) {
    ModelLoaderFactory<T, Y> removed = loaderFactory.register(modelClass, resourceClass, factory);
    if (removed != null) {
        removed.teardown();
    }
}
 
Example #5
Source File: Glide.java    From giffun with Apache License 2.0 3 votes vote down vote up
/**
 * Removes any {@link ModelLoaderFactory} registered for the given model and resource classes if one exists. If a
 * {@link ModelLoaderFactory} is removed, its {@link ModelLoaderFactory#teardown()}} method will be called.
 *
 * @deprecated Use {@link #register(Class, Class, ModelLoaderFactory)} to replace
 * a registered loader rather than simply removing it.
 * @param modelClass The model class.
 * @param resourceClass The resource class.
 * @param <T> The type of the model.
 * @param <Y> The type of the resource.
 */
@Deprecated
public <T, Y> void unregister(Class<T> modelClass, Class<Y> resourceClass) {
    ModelLoaderFactory<T, Y> removed = loaderFactory.unregister(modelClass, resourceClass);
    if (removed != null) {
        removed.teardown();
    }
}