Java 类com.bumptech.glide.load.data.DataFetcher 实例源码

项目:ImitateZHRB    文件:ImgLoadUtil.java   
@Override
public DataFetcher<InputStream> getResourceFetcher(final String model, int i, int i1) {
    return new DataFetcher<InputStream>() {
        @Override
        public InputStream loadData(Priority priority) throws Exception {
            throw new IOException();
        }

        @Override
        public void cleanup() {

        }

        @Override
        public String getId() {
            return model;
        }

        @Override
        public void cancel() {

        }
    };
}
项目:GitHub    文件:DecodeJob.java   
private <Data> Resource<R> decodeFromData(DataFetcher<?> fetcher, Data data,
    DataSource dataSource) throws GlideException {
  try {
    if (data == null) {
      return null;
    }
    long startTime = LogTime.getLogTime();
    Resource<R> result = decodeFromFetcher(data, dataSource);
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
      logWithTimeAndKey("Decoded result " + result, startTime);
    }
    return result;
  } finally {
    fetcher.cleanup();
  }
}
项目:GitHub    文件:MultiModelLoader.java   
@Override
public LoadData<Data> buildLoadData(Model model, int width, int height,
    Options options) {
  Key sourceKey = null;
  int size = modelLoaders.size();
  List<DataFetcher<Data>> fetchers = new ArrayList<>(size);
  for (int i = 0; i < size; i++) {
    ModelLoader<Model, Data> modelLoader = modelLoaders.get(i);
    if (modelLoader.handles(model)) {
      LoadData<Data> loadData = modelLoader.buildLoadData(model, width, height, options);
      if (loadData != null) {
        sourceKey = loadData.sourceKey;
        fetchers.add(loadData.fetcher);
      }
    }
  }
  return !fetchers.isEmpty()
      ? new LoadData<>(sourceKey, new MultiFetcher<>(fetchers, exceptionListPool)) : null;
}
项目: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   
@SuppressWarnings("unchecked")
private <T> ModelLoader<T, InputStream> mockStreamModelLoader(final Class<T> modelClass) {
  ModelLoader<T, InputStream> modelLoader = mock(ModelLoader.class);
  DataFetcher<InputStream> fetcher = mock(DataFetcher.class);
  try {
    doAnswer(new Util.CallDataReady<>(new ByteArrayInputStream(new byte[0]))).when(fetcher)
        .loadData(isA(Priority.class), isA(DataFetcher.DataCallback.class));
  } catch (Exception e) {
    // Do nothing.
  }
  when(fetcher.getDataClass()).thenReturn(InputStream.class);
  when(modelLoader.buildLoadData(isA(modelClass), anyInt(), anyInt(), isA(Options.class)))
      .thenReturn(new ModelLoader.LoadData<>(mock(Key.class), fetcher));
  when(modelLoader.handles(isA(modelClass))).thenReturn(true);

  return modelLoader;
}
项目: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    文件:DecodeJob.java   
@Override
public void onDataFetcherReady(Key sourceKey, Object data, DataFetcher<?> fetcher,
    DataSource dataSource, Key attemptedKey) {
  this.currentSourceKey = sourceKey;
  this.currentData = data;
  this.currentFetcher = fetcher;
  this.currentDataSource = dataSource;
  this.currentAttemptingKey = attemptedKey;
  if (Thread.currentThread() != currentThread) {
    runReason = RunReason.DECODE_DATA;
    callback.reschedule(this);
  } else {
    TraceCompat.beginSection("DecodeJob.decodeFromRetrievedData");
    try {
      decodeFromRetrievedData();
    } finally {
      TraceCompat.endSection();
    }
  }
}
项目:GitHub    文件:DecodeJob.java   
private <Data> Resource<R> decodeFromData(DataFetcher<?> fetcher, Data data,
    DataSource dataSource) throws GlideException {
  try {
    if (data == null) {
      return null;
    }
    long startTime = LogTime.getLogTime();
    Resource<R> result = decodeFromFetcher(data, dataSource);
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
      logWithTimeAndKey("Decoded result " + result, startTime);
    }
    return result;
  } finally {
    fetcher.cleanup();
  }
}
项目:GitHub    文件:MultiModelLoader.java   
@Override
public LoadData<Data> buildLoadData(Model model, int width, int height,
    Options options) {
  Key sourceKey = null;
  int size = modelLoaders.size();
  List<DataFetcher<Data>> fetchers = new ArrayList<>(size);
  for (int i = 0; i < size; i++) {
    ModelLoader<Model, Data> modelLoader = modelLoaders.get(i);
    if (modelLoader.handles(model)) {
      LoadData<Data> loadData = modelLoader.buildLoadData(model, width, height, options);
      if (loadData != null) {
        sourceKey = loadData.sourceKey;
        fetchers.add(loadData.fetcher);
      }
    }
  }
  return !fetchers.isEmpty()
      ? new LoadData<>(sourceKey, new MultiFetcher<>(fetchers, exceptionListPool)) : null;
}
项目: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   
@SuppressWarnings("unchecked")
private <T> ModelLoader<T, InputStream> mockStreamModelLoader(final Class<T> modelClass) {
  ModelLoader<T, InputStream> modelLoader = mock(ModelLoader.class);
  DataFetcher<InputStream> fetcher = mock(DataFetcher.class);
  try {
    doAnswer(new Util.CallDataReady<>(new ByteArrayInputStream(new byte[0]))).when(fetcher)
        .loadData(isA(Priority.class), isA(DataFetcher.DataCallback.class));
  } catch (Exception e) {
    // Do nothing.
  }
  when(fetcher.getDataClass()).thenReturn(InputStream.class);
  when(modelLoader.buildLoadData(isA(modelClass), anyInt(), anyInt(), isA(Options.class)))
      .thenReturn(new ModelLoader.LoadData<>(mock(Key.class), fetcher));
  when(modelLoader.handles(isA(modelClass))).thenReturn(true);

  return modelLoader;
}
项目: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);
}
项目:decoy    文件:NetworkDisablingLoader.java   
@Override
public DataFetcher<InputStream> getResourceFetcher(final String model, int width, int height) {
    return new DataFetcher<InputStream>() {
        @Override
        public InputStream loadData(Priority priority) throws Exception {
            throw new IOException("Forced Glide network failure");
        }

        @Override
        public void cleanup() {
        }

        @Override
        public String getId() {
            return model;
        }

        @Override
        public void cancel() {
        }
    };
}
项目:velociraptor    文件:AppInfoIconLoader.java   
@Override
public DataFetcher<InputStream> getResourceFetcher(final AppInfo model, int width, int height) {
    return new DataFetcher<InputStream>() {
        @Override
        public InputStream loadData(Priority priority) throws Exception {
            mCancelled = false;
            PackageManager pm = mContext.getPackageManager();
            if (mCancelled) return null;
            return drawableToStream(pm.getApplicationInfo(model.packageName, 0).loadIcon(pm));
        }

        @Override
        public void cleanup() {
        }

        @Override
        public String getId() {
            return String.valueOf(model.packageName.hashCode());
        }

        @Override
        public void cancel() {
            mCancelled = true;
        }
    };
}
项目:nuclei-android    文件:GlideImageView.java   
@Override
public DataFetcher<InputStream> getResourceFetcher(final Uri model, int width, int height) {
    return new DataFetcher<InputStream>() {
        @Override
        public InputStream loadData(Priority priority) throws Exception {
            throw new IOException();
        }

        @Override
        public void cleanup() {
        }

        @Override
        public String getId() {
            return model.toString();
        }

        @Override
        public void cancel() {
        }
    };
}
项目:aptoide-client    文件:GlideUtils.java   
@Override
public DataFetcher<InputStream> getResourceFetcher(final String model, int i, int i1) {
    return new DataFetcher<InputStream>() {
        @Override
        public InputStream loadData(Priority priority) {
            return null;
        }

        @Override
        public void cleanup() {

        }

        @Override
        public String getId() {
            return model;
        }

        @Override
        public void cancel() {

        }
    };
}
项目:itplayer    文件:StreamNfsLoader.java   
@Override
public DataFetcher<InputStream> getResourceFetcher(final String model, int width, int height) {
    return new DataFetcher<InputStream>() {
        @Override
        public InputStream loadData(Priority priority) throws Exception {
            return new NfsFileInputStream(ctx, model);
        }

        @Override
        public void cleanup() { }

        @Override
        public String getId() {
            return model;
        }

        @Override
        public void cancel() { }
    };
}
项目:saarang-iosched    文件:GenericRequest.java   
@Override
public void onSizeReady(int width, int height) {
    if (isCancelled) {
        return;
    }

    width = Math.round(sizeMultiplier * width);
    height = Math.round(sizeMultiplier * height);
    ResourceDecoder<InputStream, Z> cacheDecoder = loadProvider.getCacheDecoder();
    ResourceDecoder<T, Z> decoder = loadProvider.getSourceDecoder();
    ResourceEncoder <Z> encoder = loadProvider.getEncoder();
    ResourceTranscoder<Z, R> transcoder = loadProvider.getTranscoder();
    ModelLoader<A, T> modelLoader = loadProvider.getModelLoader();

    final String id = modelLoader.getId(model);
    final DataFetcher<T> dataFetcher = modelLoader.getResourceFetcher(model, width, height);

    loadedFromMemoryCache = true;
    loadStatus = engine.load(id, width, height, cacheDecoder, dataFetcher, decoder, transformation,
            encoder, transcoder, priority, isMemoryCacheable, this);
    loadedFromMemoryCache = resource != null;
}
项目:saarang-iosched    文件:BaseGlideUrlLoader.java   
@Override
public DataFetcher<InputStream> getResourceFetcher(T model, int width, int height) {
    final String id = getId(model);
    GlideUrl result = null;
    if (modelCache != null) {
        result = modelCache.get(id, width, height);
    }

    if (result == null) {
        String stringURL = getUrl(model, width, height);
        result = new GlideUrl(stringURL);

        if (modelCache != null) {
            modelCache.put(id, width, height, result);
        }
    }

    return concreteLoader.getResourceFetcher(result, width, height);
}
项目:AppDevFestSudeste2015    文件:GenericRequest.java   
@Override
public void onSizeReady(int width, int height) {
    if (isCancelled) {
        return;
    }

    width = Math.round(sizeMultiplier * width);
    height = Math.round(sizeMultiplier * height);
    ResourceDecoder<InputStream, Z> cacheDecoder = loadProvider.getCacheDecoder();
    ResourceDecoder<T, Z> decoder = loadProvider.getSourceDecoder();
    ResourceEncoder <Z> encoder = loadProvider.getEncoder();
    ResourceTranscoder<Z, R> transcoder = loadProvider.getTranscoder();
    ModelLoader<A, T> modelLoader = loadProvider.getModelLoader();

    final String id = modelLoader.getId(model);
    final DataFetcher<T> dataFetcher = modelLoader.getResourceFetcher(model, width, height);

    loadedFromMemoryCache = true;
    loadStatus = engine.load(id, width, height, cacheDecoder, dataFetcher, decoder, transformation,
            encoder, transcoder, priority, isMemoryCacheable, this);
    loadedFromMemoryCache = resource != null;
}
项目:AppDevFestSudeste2015    文件:BaseGlideUrlLoader.java   
@Override
public DataFetcher<InputStream> getResourceFetcher(T model, int width, int height) {
    final String id = getId(model);
    GlideUrl result = null;
    if (modelCache != null) {
        result = modelCache.get(id, width, height);
    }

    if (result == null) {
        String stringURL = getUrl(model, width, height);
        result = new GlideUrl(stringURL);

        if (modelCache != null) {
            modelCache.put(id, width, height, result);
        }
    }

    return concreteLoader.getResourceFetcher(result, width, height);
}
项目:anticipate    文件:AppIconLoader.java   
@Override
public DataFetcher<InputStream> getResourceFetcher(final AppInfo model, int width, int height) {
    return new DataFetcher<InputStream>() {
        @Override
        public InputStream loadData(Priority priority) throws Exception {
            mCancelled = false;
            PackageManager pm = mContext.getPackageManager();
            if (mCancelled) return null;
            return drawableToStream(pm.getApplicationInfo(model.packageName, 0).loadIcon(pm));
        }

        @Override
        public void cleanup() {
        }

        @Override
        public String getId() {
            return String.valueOf(model.packageName.hashCode());
        }

        @Override
        public void cancel() {
            mCancelled = true;
        }
    };
}
项目:hipda    文件:GlideImageJob.java   
@Override
public DataFetcher<InputStream> getResourceFetcher(final String model, int i, int i1) {
    return new DataFetcher<InputStream>() {
        @Override
        public InputStream loadData(Priority priority) throws Exception {
            throw new IOException();
        }

        @Override
        public void cleanup() {

        }

        @Override
        public String getId() {
            return model;
        }

        @Override
        public void cancel() {

        }
    };
}
项目:android-tutorials-glide    文件:NetworkDisablingLoader.java   
@Override
public DataFetcher<InputStream> getResourceFetcher(final String model, int width, int height) {
    return new DataFetcher<InputStream>() {
        @Override
        public InputStream loadData(Priority priority) throws Exception {
            throw new IOException("Forced Glide network failure");
        }

        @Override
        public void cleanup() {
        }

        @Override
        public String getId() {
            return model;
        }

        @Override
        public void cancel() {
        }
    };
}
项目:devfestnorte-app    文件:GenericRequest.java   
@Override
public void onSizeReady(int width, int height) {
    if (isCancelled) {
        return;
    }

    width = Math.round(sizeMultiplier * width);
    height = Math.round(sizeMultiplier * height);
    ResourceDecoder<InputStream, Z> cacheDecoder = loadProvider.getCacheDecoder();
    ResourceDecoder<T, Z> decoder = loadProvider.getSourceDecoder();
    ResourceEncoder <Z> encoder = loadProvider.getEncoder();
    ResourceTranscoder<Z, R> transcoder = loadProvider.getTranscoder();
    ModelLoader<A, T> modelLoader = loadProvider.getModelLoader();

    final String id = modelLoader.getId(model);
    final DataFetcher<T> dataFetcher = modelLoader.getResourceFetcher(model, width, height);

    loadedFromMemoryCache = true;
    loadStatus = engine.load(id, width, height, cacheDecoder, dataFetcher, decoder, transformation,
            encoder, transcoder, priority, isMemoryCacheable, this);
    loadedFromMemoryCache = resource != null;
}
项目:devfestnorte-app    文件:BaseGlideUrlLoader.java   
@Override
public DataFetcher<InputStream> getResourceFetcher(T model, int width, int height) {
    final String id = getId(model);
    GlideUrl result = null;
    if (modelCache != null) {
        result = modelCache.get(id, width, height);
    }

    if (result == null) {
        String stringURL = getUrl(model, width, height);
        result = new GlideUrl(stringURL);

        if (modelCache != null) {
            modelCache.put(id, width, height, result);
        }
    }

    return concreteLoader.getResourceFetcher(result, width, height);
}
项目:saarang-iosched    文件:GenericRequest.java   
@Override
public void onSizeReady(int width, int height) {
    if (isCancelled) {
        return;
    }

    width = Math.round(sizeMultiplier * width);
    height = Math.round(sizeMultiplier * height);
    ResourceDecoder<InputStream, Z> cacheDecoder = loadProvider.getCacheDecoder();
    ResourceDecoder<T, Z> decoder = loadProvider.getSourceDecoder();
    ResourceEncoder <Z> encoder = loadProvider.getEncoder();
    ResourceTranscoder<Z, R> transcoder = loadProvider.getTranscoder();
    ModelLoader<A, T> modelLoader = loadProvider.getModelLoader();

    final String id = modelLoader.getId(model);
    final DataFetcher<T> dataFetcher = modelLoader.getResourceFetcher(model, width, height);

    loadedFromMemoryCache = true;
    loadStatus = engine.load(id, width, height, cacheDecoder, dataFetcher, decoder, transformation,
            encoder, transcoder, priority, isMemoryCacheable, this);
    loadedFromMemoryCache = resource != null;
}
项目:saarang-iosched    文件:BaseGlideUrlLoader.java   
@Override
public DataFetcher<InputStream> getResourceFetcher(T model, int width, int height) {
    final String id = getId(model);
    GlideUrl result = null;
    if (modelCache != null) {
        result = modelCache.get(id, width, height);
    }

    if (result == null) {
        String stringURL = getUrl(model, width, height);
        result = new GlideUrl(stringURL);

        if (modelCache != null) {
            modelCache.put(id, width, height, result);
        }
    }

    return concreteLoader.getResourceFetcher(result, width, height);
}
项目:q-mail    文件:ContactPictureLoader.java   
@Override
public DataFetcher<FallbackGlideParams> getResourceFetcher(final FallbackGlideParams model, int width,
        int height) {

    return new DataFetcher<FallbackGlideParams>() {

        @Override
        public FallbackGlideParams loadData(Priority priority) throws Exception {
            return model;
        }

        @Override
        public void cleanup() {

        }

        @Override
        public String getId() {
            return model.getId();
        }

        @Override
        public void cancel() {

        }
    };
}
项目:GitHub    文件:VolleyStreamFetcherServerTest.java   
@Test
public void testReturnsInputStreamOnStatusOk() throws Exception {
  String expected = "fakedata";
  mockWebServer.enqueue(new MockResponse().setBody(expected).setResponseCode(200));
  DataFetcher<InputStream> fetcher = getFetcher();
  fetcher.loadData(Priority.HIGH, callback);
  waitForResponseLatch.await();
  verify(callback).onDataReady(streamCaptor.capture());
  assertStreamOf(expected, streamCaptor.getValue());
}
项目:GitHub    文件:DecodeJob.java   
@Override
public void onDataFetcherReady(Key sourceKey, Object data, DataFetcher<?> fetcher,
    DataSource dataSource, Key attemptedKey) {
  this.currentSourceKey = sourceKey;
  this.currentData = data;
  this.currentFetcher = fetcher;
  this.currentDataSource = dataSource;
  this.currentAttemptingKey = attemptedKey;
  if (Thread.currentThread() != currentThread) {
    runReason = RunReason.DECODE_DATA;
    callback.reschedule(this);
  } else {
    decodeFromRetrievedData();
  }
}
项目:GitHub    文件:DecodeJob.java   
@Override
public void onDataFetcherFailed(Key attemptedKey, Exception e, DataFetcher<?> fetcher,
    DataSource dataSource) {
  fetcher.cleanup();
  GlideException exception = new GlideException("Fetching data failed", e);
  exception.setLoggingDetails(attemptedKey, dataSource, fetcher.getDataClass());
  exceptions.add(exception);
  if (Thread.currentThread() != currentThread) {
    runReason = RunReason.SWITCH_TO_SOURCE_SERVICE;
    callback.reschedule(this);
  } else {
    runGenerators();
  }
}
项目:GitHub    文件:SourceGenerator.java   
@Override
public void onDataFetcherReady(Key sourceKey, Object data, DataFetcher<?> fetcher,
    DataSource dataSource, Key attemptedKey) {
  // This data fetcher will be loading from a File and provide the wrong data source, so override
  // with the data source of the original fetcher
  cb.onDataFetcherReady(sourceKey, data, fetcher, loadData.fetcher.getDataSource(), sourceKey);
}
项目:GitHub    文件:MultiModelLoader.java   
@Override
public void cleanup() {
  exceptionListPool.release(exceptions);
  exceptions = null;
  for (DataFetcher<Data> fetcher : fetchers) {
    fetcher.cleanup();
  }
}
项目:GitHub    文件:Util.java   
@SuppressWarnings("unchecked")
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
  DataFetcher.DataCallback<T> callback =
      (DataFetcher.DataCallback<T>) invocationOnMock.getArguments()[1];
  callback.onDataReady(data);
  return null;
}
项目:GitHub    文件:VolleyStreamFetcherServerTest.java   
@Test
public void testReturnsInputStreamOnStatusOk() throws Exception {
  String expected = "fakedata";
  mockWebServer.enqueue(new MockResponse().setBody(expected).setResponseCode(200));
  DataFetcher<InputStream> fetcher = getFetcher();
  fetcher.loadData(Priority.HIGH, callback);
  waitForResponseLatch.await();
  verify(callback).onDataReady(streamCaptor.capture());
  assertStreamOf(expected, streamCaptor.getValue());
}
项目:GitHub    文件:DecodeJob.java   
@Override
public void onDataFetcherFailed(Key attemptedKey, Exception e, DataFetcher<?> fetcher,
    DataSource dataSource) {
  fetcher.cleanup();
  GlideException exception = new GlideException("Fetching data failed", e);
  exception.setLoggingDetails(attemptedKey, dataSource, fetcher.getDataClass());
  throwables.add(exception);
  if (Thread.currentThread() != currentThread) {
    runReason = RunReason.SWITCH_TO_SOURCE_SERVICE;
    callback.reschedule(this);
  } else {
    runGenerators();
  }
}
项目:GitHub    文件:SourceGenerator.java   
@Override
public void onDataFetcherReady(Key sourceKey, Object data, DataFetcher<?> fetcher,
    DataSource dataSource, Key attemptedKey) {
  // This data fetcher will be loading from a File and provide the wrong data source, so override
  // with the data source of the original fetcher
  cb.onDataFetcherReady(sourceKey, data, fetcher, loadData.fetcher.getDataSource(), sourceKey);
}
项目:GitHub    文件:MultiModelLoader.java   
@Override
public void cleanup() {
  if (exceptions != null) {
    throwableListPool.release(exceptions);
  }
  exceptions = null;
  for (DataFetcher<Data> fetcher : fetchers) {
    fetcher.cleanup();
  }
}
项目:GitHub    文件:ByteArrayLoaderTest.java   
@Test
public void testCanHandleByteArray() {
  byte[] data = new byte[10];
  DataFetcher<Object> fetcher =
      Preconditions.checkNotNull(loader.buildLoadData(data, -1, -1, options)).fetcher;
  assertNotNull(fetcher);
}