當前位置: 首頁>>代碼示例>>Java>>正文


Java ModelLoaderFactory類代碼示例

本文整理匯總了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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:GlideTest.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:GlideTest.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:GlideTest.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:GlideTest.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:WaitModelLoader.java

示例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);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:10,代碼來源:GlideTest.java

示例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);
}
 
開發者ID:TWiStErRob,項目名稱:TWiStErRob,代碼行數:9,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:6,代碼來源:Registry.java

示例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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:6,代碼來源:Registry.java

示例10: createUrlLoaderFactory

import com.bumptech.glide.load.model.ModelLoaderFactory; //導入依賴的package包/類
@Override
public ModelLoaderFactory<GlideUrl, InputStream> createUrlLoaderFactory() {
	return new VolleyUrlLoader.Factory(getRequestQueue());
}
 
開發者ID:showang,項目名稱:RecyclerAdapterBase,代碼行數:5,代碼來源:GlideVolleyRequestExecutor.java

示例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;
}
 
開發者ID:showang,項目名稱:RecyclerAdapterBase,代碼行數:7,代碼來源:ExampleApiBase.java

示例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;
}
 
開發者ID:TWiStErRob,項目名稱:glide-support,代碼行數:10,代碼來源:GlideModule.java

示例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;
}
 
開發者ID:toshiapp,項目名稱:toshi-android-client,代碼行數:10,代碼來源:GlideOkHttpStack.java

示例14: ModelLoaderFactoryWrapper

import com.bumptech.glide.load.model.ModelLoaderFactory; //導入依賴的package包/類
public ModelLoaderFactoryWrapper(ModelLoaderFactory<T, Y> wrapped, ExceptionHandler handler) {
    this.wrapped = wrapped;
    this.handler = handler;
}
 
開發者ID:TWiStErRob,項目名稱:TWiStErRob,代碼行數:5,代碼來源:ModelLoaderFactoryWrapper.java

示例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;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:31,代碼來源:Registry.java


注:本文中的com.bumptech.glide.load.model.ModelLoaderFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。