コード例 #1
0
    public RequestHarness() {
      modelLoader = mock(ModelLoader.class);
      when(modelLoader.getResourceFetcher(any(Number.class), anyInt(), anyInt()))
          .thenReturn(mock(DataFetcher.class));
      when(loadProvider.getModelLoader()).thenReturn(modelLoader);
      when(loadProvider.getCacheDecoder()).thenReturn(cacheDecoder);
      when(loadProvider.getSourceDecoder()).thenReturn(sourceDecoder);
      when(loadProvider.getSourceEncoder()).thenReturn(sourceEncoder);
      when(loadProvider.getEncoder()).thenReturn(encoder);
      when(loadProvider.getTranscoder()).thenReturn(transcoder);
      when(requestCoordinator.canSetImage(any(Request.class))).thenReturn(true);
      when(requestCoordinator.canNotifyStatusChanged(any(Request.class))).thenReturn(true);

      when(resource.get()).thenReturn(result);
    }
コード例 #2
0
  @Override
  public DataFetcher<InputStream> getResourceFetcher(T model, int width, int height) {
    GlideUrl result = null;
    if (modelCache != null) {
      result = modelCache.get(model, width, height);
    }

    if (result == null) {
      String stringURL = getUrl(model, width, height);
      if (TextUtils.isEmpty(stringURL)) {
        return null;
      }

      result = new GlideUrl(stringURL);

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

    return concreteLoader.getResourceFetcher(result, width, height);
  }