当前位置: 首页>>代码示例>>Java>>正文


Java DataFetcher类代码示例

本文整理汇总了Java中com.bumptech.glide.load.data.DataFetcher的典型用法代码示例。如果您正苦于以下问题:Java DataFetcher类的具体用法?Java DataFetcher怎么用?Java DataFetcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DataFetcher类属于com.bumptech.glide.load.data包,在下文中一共展示了DataFetcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResourceFetcher

import com.bumptech.glide.load.data.DataFetcher; //导入依赖的package包/类
@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() {

        }
    };
}
 
开发者ID:Mrqinlei,项目名称:ImitateZHRB,代码行数:25,代码来源:ImgLoadUtil.java

示例2: decodeFromData

import com.bumptech.glide.load.data.DataFetcher; //导入依赖的package包/类
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();
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:DecodeJob.java

示例3: buildLoadData

import com.bumptech.glide.load.data.DataFetcher; //导入依赖的package包/类
@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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:MultiModelLoader.java

示例4: registerFailFactory

import com.bumptech.glide.load.data.DataFetcher; //导入依赖的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

示例5: mockStreamModelLoader

import com.bumptech.glide.load.data.DataFetcher; //导入依赖的package包/类
@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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:GlideTest.java

示例6: registerMockModelLoader

import com.bumptech.glide.load.data.DataFetcher; //导入依赖的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

示例7: onDataFetcherReady

import com.bumptech.glide.load.data.DataFetcher; //导入依赖的package包/类
@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();
    }
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:DecodeJob.java

示例8: registerFailFactory

import com.bumptech.glide.load.data.DataFetcher; //导入依赖的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

示例9: getResourceFetcher

import com.bumptech.glide.load.data.DataFetcher; //导入依赖的package包/类
@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() {
        }
    };
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:23,代码来源:NetworkDisablingLoader.java

示例10: getResourceFetcher

import com.bumptech.glide.load.data.DataFetcher; //导入依赖的package包/类
@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;
        }
    };
}
 
开发者ID:plusCubed,项目名称:velociraptor,代码行数:27,代码来源:AppInfoIconLoader.java

示例11: getResourceFetcher

import com.bumptech.glide.load.data.DataFetcher; //导入依赖的package包/类
@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() {
        }
    };
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:23,代码来源:GlideImageView.java

示例12: getResourceFetcher

import com.bumptech.glide.load.data.DataFetcher; //导入依赖的package包/类
@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() {

        }
    };
}
 
开发者ID:Aptoide,项目名称:aptoide-client,代码行数:25,代码来源:GlideUtils.java

示例13: getResourceFetcher

import com.bumptech.glide.load.data.DataFetcher; //导入依赖的package包/类
@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() { }
    };
}
 
开发者ID:irtimmer,项目名称:itplayer,代码行数:21,代码来源:StreamNfsLoader.java

示例14: onSizeReady

import com.bumptech.glide.load.data.DataFetcher; //导入依赖的package包/类
@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;
}
 
开发者ID:The-WebOps-Club,项目名称:saarang-iosched,代码行数:23,代码来源:GenericRequest.java

示例15: getResourceFetcher

import com.bumptech.glide.load.data.DataFetcher; //导入依赖的package包/类
@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);
}
 
开发者ID:The-WebOps-Club,项目名称:saarang-iosched,代码行数:20,代码来源:BaseGlideUrlLoader.java


注:本文中的com.bumptech.glide.load.data.DataFetcher类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。