本文整理汇总了Java中com.bumptech.glide.load.model.ModelLoaderFactory类的典型用法代码示例。如果您正苦于以下问题:Java ModelLoaderFactory类的具体用法?Java ModelLoaderFactory怎么用?Java ModelLoaderFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ModelLoaderFactory类属于com.bumptech.glide.load.model包,在下文中一共展示了ModelLoaderFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerFailFactory
import com.bumptech.glide.load.model.ModelLoaderFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T, Z> void registerFailFactory(Class<T> failModel, Class<Z> failResource)
throws Exception {
DataFetcher<Z> failFetcher = mock(DataFetcher.class);
doAnswer(new Util.CallDataReady<>(null))
.when(failFetcher)
.loadData(isA(Priority.class), isA(DataFetcher.DataCallback.class));
when(failFetcher.getDataClass()).thenReturn(failResource);
ModelLoader<T, Z> failLoader = mock(ModelLoader.class);
when(failLoader.buildLoadData(isA(failModel), anyInt(), anyInt(), isA(Options.class)))
.thenReturn(new ModelLoader.LoadData<>(mock(Key.class), failFetcher));
when(failLoader.handles(isA(failModel))).thenReturn(true);
ModelLoaderFactory<T, Z> failFactory = mock(ModelLoaderFactory.class);
when(failFactory.build(isA(MultiModelLoaderFactory.class))).thenReturn(failLoader);
Glide.get(getContext()).getRegistry().prepend(failModel, failResource, failFactory);
}
示例2: registerMockModelLoader
import com.bumptech.glide.load.model.ModelLoaderFactory; //导入依赖的package包/类
private static <X, Y> void registerMockModelLoader(Class<X> modelClass, Class<Y> dataClass,
Y loadedData, Registry registry) {
DataFetcher<Y> mockStreamFetcher = mock(DataFetcher.class);
when(mockStreamFetcher.getDataClass()).thenReturn(dataClass);
try {
doAnswer(new Util.CallDataReady<>(loadedData))
.when(mockStreamFetcher)
.loadData(isA(Priority.class), isA(DataFetcher.DataCallback.class));
} catch (Exception e) {
throw new RuntimeException(e);
}
ModelLoader<X, Y> mockUrlLoader = mock(ModelLoader.class);
when(mockUrlLoader.buildLoadData(isA(modelClass), anyInt(), anyInt(), isA(Options.class)))
.thenReturn(new ModelLoader.LoadData<>(mock(Key.class), mockStreamFetcher));
when(mockUrlLoader.handles(isA(modelClass))).thenReturn(true);
ModelLoaderFactory<X, Y> mockUrlLoaderFactory = mock(ModelLoaderFactory.class);
when(mockUrlLoaderFactory.build(isA(MultiModelLoaderFactory.class)))
.thenReturn(mockUrlLoader);
registry.replace(modelClass, dataClass, mockUrlLoaderFactory);
}
示例3: registerFailFactory
import com.bumptech.glide.load.model.ModelLoaderFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T, Z> void registerFailFactory(Class<T> failModel, Class<Z> failResource) {
DataFetcher<Z> failFetcher = mock(DataFetcher.class);
doAnswer(new Util.CallDataReady<>(null))
.when(failFetcher)
.loadData(isA(Priority.class), isA(DataFetcher.DataCallback.class));
when(failFetcher.getDataClass()).thenReturn(failResource);
ModelLoader<T, Z> failLoader = mock(ModelLoader.class);
when(failLoader.buildLoadData(isA(failModel), anyInt(), anyInt(), isA(Options.class)))
.thenReturn(new ModelLoader.LoadData<>(mock(Key.class), failFetcher));
when(failLoader.handles(isA(failModel))).thenReturn(true);
ModelLoaderFactory<T, Z> failFactory = mock(ModelLoaderFactory.class);
when(failFactory.build(isA(MultiModelLoaderFactory.class))).thenReturn(failLoader);
Glide.get(context).getRegistry().prepend(failModel, failResource, failFactory);
}
示例4: registerMockStreamModelLoader
import com.bumptech.glide.load.model.ModelLoaderFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> void registerMockStreamModelLoader(final Class<T> modelClass) {
ModelLoader<T, InputStream> modelLoader = mockStreamModelLoader(modelClass);
ModelLoaderFactory<T, InputStream> modelLoaderFactory = mock(ModelLoaderFactory.class);
when(modelLoaderFactory.build(isA(MultiModelLoaderFactory.class))).thenReturn(modelLoader);
Glide.get(RuntimeEnvironment.application).getRegistry()
.prepend(modelClass, InputStream.class, modelLoaderFactory);
}
示例5: waitOn
import com.bumptech.glide.load.model.ModelLoaderFactory; //导入依赖的package包/类
public static synchronized <T> WaitModel<T> waitOn(T model) {
@SuppressWarnings("unchecked") ModelLoaderFactory<WaitModel<T>, InputStream> streamFactory =
new Factory<>((Class<T>) model.getClass(), InputStream.class);
Glide.get(InstrumentationRegistry.getTargetContext())
.getRegistry()
.replace(WaitModel.class, InputStream.class, streamFactory);
return new WaitModel<>(model);
}
示例6: registerMockStreamModelLoader
import com.bumptech.glide.load.model.ModelLoaderFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> void registerMockStreamModelLoader(final Class<T> modelClass) {
ModelLoader<T, InputStream> modelLoader = mockStreamModelLoader(modelClass);
ModelLoaderFactory<T, InputStream> modelLoaderFactory = mock(ModelLoaderFactory.class);
when(modelLoaderFactory.build(isA(MultiModelLoaderFactory.class))).thenReturn(modelLoader);
Glide.get(context).getRegistry()
.prepend(modelClass, InputStream.class, modelLoaderFactory);
}
示例7: onResume
import com.bumptech.glide.load.model.ModelLoaderFactory; //导入依赖的package包/类
@Override
protected void onResume() {
super.onResume();
FileDescriptorUriLoader.Factory originalFactory = new FileDescriptorUriLoader.Factory();
ModelLoaderFactory<Uri, ParcelFileDescriptor> wrapperFactory = new ModelLoaderFactoryWrapper<>(originalFactory, this);
Glide.get(this).register(Uri.class, ParcelFileDescriptor.class, wrapperFactory);
}
示例8: prepend
import com.bumptech.glide.load.model.ModelLoaderFactory; //导入依赖的package包/类
public <Model, Data> Registry prepend(Class<Model> modelClass, Class<Data> dataClass,
ModelLoaderFactory<Model, Data> factory) {
modelLoaderRegistry.prepend(modelClass, dataClass, factory);
return this;
}
示例9: replace
import com.bumptech.glide.load.model.ModelLoaderFactory; //导入依赖的package包/类
public <Model, Data> Registry replace(Class<Model> modelClass, Class<Data> dataClass,
ModelLoaderFactory<Model, Data> factory) {
modelLoaderRegistry.replace(modelClass, dataClass, factory);
return this;
}
示例10: createUrlLoaderFactory
import com.bumptech.glide.load.model.ModelLoaderFactory; //导入依赖的package包/类
@Override
public ModelLoaderFactory<GlideUrl, InputStream> createUrlLoaderFactory() {
return new VolleyUrlLoader.Factory(getRequestQueue());
}
示例11: createUrlLoaderFactory
import com.bumptech.glide.load.model.ModelLoaderFactory; //导入依赖的package包/类
public static ModelLoaderFactory<GlideUrl, InputStream> createUrlLoaderFactory() {
if(sExecutor instanceof GlideLoaderFactory) {
return ((GlideLoaderFactory)sExecutor).createUrlLoaderFactory();
}
return null;
}
示例12: superFactory
import com.bumptech.glide.load.model.ModelLoaderFactory; //导入依赖的package包/类
/**
* {@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;
}
示例13: superFactory
import com.bumptech.glide.load.model.ModelLoaderFactory; //导入依赖的package包/类
/**
* {@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;
}
示例14: ModelLoaderFactoryWrapper
import com.bumptech.glide.load.model.ModelLoaderFactory; //导入依赖的package包/类
public ModelLoaderFactoryWrapper(ModelLoaderFactory<T, Y> wrapped, ExceptionHandler handler) {
this.wrapped = wrapped;
this.handler = handler;
}
示例15: replace
import com.bumptech.glide.load.model.ModelLoaderFactory; //导入依赖的package包/类
/**
* Removes all default and previously registered {@link ModelLoaderFactory}s for the given data
* and model class and replaces all of them with the single {@link ModelLoader} provided.
*
* <p>If you're attempting to add additional functionality or add a backup that should run only
* after the default {@link ModelLoader}s run, use
* {@link #append(Class, Class, ModelLoaderFactory)}. This method should be used only when you
* want to ensure that Glide's default {@link ModelLoader}s do not run.
*
* <p>One good use case for this method is when you want to replace Glide's default networking
* library with your OkHttp, Volley, or your own implementation. Using
* {@link #prepend(Class, Class, ModelLoaderFactory)} or
* {@link #append(Class, Class, ModelLoaderFactory)} may still allow Glide's default networking
* library to run in some cases. Using this method will ensure that only your networking library
* will run and that the request will fail otherwise.
*
* @see #prepend(Class, Class, ModelLoaderFactory)
* @see #append(Class, Class, ModelLoaderFactory)
*
* @param modelClass The model class (e.g. URL, file path).
* @param dataClass the data class (e.g. {@link java.io.InputStream},
* {@link java.io.FileDescriptor}).
*/
public <Model, Data> Registry replace(
Class<Model> modelClass,
Class<Data> dataClass,
ModelLoaderFactory<? extends Model, ? extends Data> factory) {
modelLoaderRegistry.replace(modelClass, dataClass, factory);
return this;
}