Java 类com.bumptech.glide.load.model.MultiModelLoaderFactory 实例源码

项目:GitHub    文件:GlideTest.java   
@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);
}
项目:GitHub    文件:GlideTest.java   
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);
}
项目:GitHub    文件:GlideTest.java   
@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);
}
项目:GitHub    文件:GlideTest.java   
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);
}
项目:GitHub    文件:GlideTest.java   
@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);
}
项目:GitHub    文件:GlideTest.java   
@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);
}
项目:GitHub    文件:OkHttpUrlLoader.java   
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new OkHttpUrlLoader(client);
}
项目:GitHub    文件:OkHttpUrlLoader.java   
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new OkHttpUrlLoader(client);
}
项目:GitHub    文件:VolleyUrlLoader.java   
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory factory) {
  return new VolleyUrlLoader(requestQueue, requestFactory);
}
项目:GitHub    文件:GiphyModelLoader.java   
@Override
public ModelLoader<Api.GifResult, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new GiphyModelLoader(multiFactory.build(GlideUrl.class, InputStream.class));
}
项目:GitHub    文件:FlickrModelLoader.java   
@Override
public ModelLoader<Photo, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new FlickrModelLoader(multiFactory.build(GlideUrl.class, InputStream.class),
      modelCache);
}
项目:GitHub    文件:HttpUriLoader.java   
@Override
public ModelLoader<Uri, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new HttpUriLoader(multiFactory.build(GlideUrl.class, InputStream.class));
}
项目:GitHub    文件:UrlLoader.java   
@Override
public ModelLoader<URL, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new UrlLoader(multiFactory.build(GlideUrl.class, InputStream.class));
}
项目:GitHub    文件:MediaStoreVideoThumbLoader.java   
@Override
public ModelLoader<Uri, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new MediaStoreVideoThumbLoader(context);
}
项目:GitHub    文件:HttpGlideUrlLoader.java   
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new HttpGlideUrlLoader(modelCache);
}
项目:GitHub    文件:MediaStoreImageThumbLoader.java   
@Override
public ModelLoader<Uri, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new MediaStoreImageThumbLoader(context);
}
项目:GitHub    文件:OkHttpUrlLoader.java   
@SuppressWarnings("deprecation")
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new OkHttpUrlLoader(client);
}
项目:GitHub    文件:OkHttpUrlLoader.java   
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new OkHttpUrlLoader(client);
}
项目:GitHub    文件:VolleyUrlLoader.java   
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory factory) {
  return new VolleyUrlLoader(requestQueue, requestFactory);
}
项目:GitHub    文件:WaitModelLoader.java   
@Override
public ModelLoader<WaitModel<Model>, Data> build(
    MultiModelLoaderFactory multiFactory) {
  return new WaitModelLoader<>(multiFactory.build(modelClass, dataClass));
}
项目:GitHub    文件:GiphyModelLoader.java   
@Override
public ModelLoader<Api.GifResult, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new GiphyModelLoader(multiFactory.build(GlideUrl.class, InputStream.class));
}
项目:GitHub    文件:FlickrModelLoader.java   
@Override
public ModelLoader<Photo, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new FlickrModelLoader(
      multiFactory.build(GlideUrl.class, InputStream.class), modelCache);
}
项目:GitHub    文件:HttpUriLoader.java   
@Override
public ModelLoader<Uri, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new HttpUriLoader(multiFactory.build(GlideUrl.class, InputStream.class));
}
项目:GitHub    文件:UrlLoader.java   
@Override
public ModelLoader<URL, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new UrlLoader(multiFactory.build(GlideUrl.class, InputStream.class));
}
项目:GitHub    文件:MediaStoreVideoThumbLoader.java   
@Override
public ModelLoader<Uri, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new MediaStoreVideoThumbLoader(context);
}
项目:GitHub    文件:HttpGlideUrlLoader.java   
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new HttpGlideUrlLoader(modelCache);
}
项目:GitHub    文件:MediaStoreImageThumbLoader.java   
@Override
public ModelLoader<Uri, InputStream> build(MultiModelLoaderFactory multiFactory) {
  return new MediaStoreImageThumbLoader(context);
}
项目:KomaMusic    文件:ArtworkModeLoader.java   
@Override
public ModelLoader<String, InputStream> build(MultiModelLoaderFactory multiFactory) {
    return new ArtworkModeLoader();
}
项目:MoligyMvpArms    文件:OkHttpUrlLoader.java   
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory multiFactory) {
    return new OkHttpUrlLoader(client);
}
项目:garras    文件:PixelsModelLoader.java   
@Override
public ModelLoader<String, InputStream> build(MultiModelLoaderFactory multiFactory) {
    return new PixelsModelLoader(multiFactory.build(GlideUrl.class, InputStream.class), urlCache);
}
项目:FireBaseTest    文件:FirebaseImageLoader.java   
@Override
public ModelLoader<StorageReference, InputStream> build(MultiModelLoaderFactory factory) {
    return new FirebaseImageLoader();
}
项目:FastAndroid    文件:OkHttpUrlLoader.java   
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory multiFactory) {
    return new OkHttpUrlLoader(client);
}
项目:Aurora    文件:OkHttpUrlLoader.java   
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory multiFactory) {
    return new OkHttpUrlLoader(client);
}
项目:NeiHanDuanZiTV    文件:OkHttpUrlLoader.java   
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory multiFactory) {
    return new OkHttpUrlLoader(client);
}
项目:GmArchMvvm    文件:OkHttpUrlLoader.java   
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory multiFactory) {
    return new OkHttpUrlLoader(client);
}
项目:GmArchMvvm    文件:OkHttpUrlLoader.java   
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory multiFactory) {
    return new OkHttpUrlLoader(client);
}
项目:MVVMArms    文件:OkHttpUrlLoader.java   
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory multiFactory) {
    return new OkHttpUrlLoader(client);
}
项目:arctic-icon-request    文件:AppIconLoaderFactory.java   
@NonNull
@Override
public ModelLoader<AppModel, InputStream> build(@NonNull MultiModelLoaderFactory multiFactory) {
  return new AppIconLoader(context);
}
项目:MVPFrames    文件:OkHttpUrlLoader.java   
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory multiFactory) {
    return new OkHttpUrlLoader(client);
}
项目:S1-Next    文件:AppHttpUrlLoader.java   
@Override
public ModelLoader<GlideUrl, InputStream> build(MultiModelLoaderFactory multiFactory) {
    return new AppHttpUrlLoader(mOkHttpClient);
}