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

项目:GitHub    文件:StreamLocalUriFetcherTest.java   
@Test
public void testLoadResource_returnsInputStream() throws Exception {
  Context context = RuntimeEnvironment.application;
  Uri uri = Uri.parse("file://nothing");

  ContentResolver contentResolver = context.getContentResolver();
  ContentResolverShadow shadow = (ContentResolverShadow) Shadow.extract(contentResolver);
  shadow.registerInputStream(uri, new ByteArrayInputStream(new byte[0]));

  StreamLocalUriFetcher fetcher = new StreamLocalUriFetcher(context.getContentResolver(), uri);
  fetcher.loadData(Priority.NORMAL, callback);
  verify(callback).onDataReady(isNotNull(InputStream.class));
}
项目:GitHub    文件:StreamLocalUriFetcherTest.java   
@Test
public void testLoadResource_withNullInputStream_callsLoadFailed() {
  Context context = RuntimeEnvironment.application;
  Uri uri = Uri.parse("file://nothing");

  ContentResolver contentResolver = context.getContentResolver();
  ContentResolverShadow shadow = (ContentResolverShadow) Shadow.extract(contentResolver);

  shadow.registerInputStream(uri, null /*inputStream*/);

  StreamLocalUriFetcher fetcher = new StreamLocalUriFetcher(context.getContentResolver(), uri);
  fetcher.loadData(Priority.LOW, callback);

  verify(callback).onLoadFailed(isA(FileNotFoundException.class));
}
项目:GitHub    文件:StreamLocalUriFetcherTest.java   
@Test
public void testLoadResource_returnsInputStream() throws Exception {
  Context context = RuntimeEnvironment.application;
  Uri uri = Uri.parse("file://nothing");

  ContentResolver contentResolver = context.getContentResolver();
  ContentResolverShadow shadow = Shadow.extract(contentResolver);
  shadow.registerInputStream(uri, new ByteArrayInputStream(new byte[0]));

  StreamLocalUriFetcher fetcher = new StreamLocalUriFetcher(context.getContentResolver(), uri);
  fetcher.loadData(Priority.NORMAL, callback);
  verify(callback).onDataReady(isNotNull(InputStream.class));
}
项目:GitHub    文件:StreamLocalUriFetcherTest.java   
@Test
public void testLoadResource_withNullInputStream_callsLoadFailed() {
  Context context = RuntimeEnvironment.application;
  Uri uri = Uri.parse("file://nothing");

  ContentResolver contentResolver = context.getContentResolver();
  ContentResolverShadow shadow = Shadow.extract(contentResolver);

  shadow.registerInputStream(uri, null /*inputStream*/);

  StreamLocalUriFetcher fetcher = new StreamLocalUriFetcher(context.getContentResolver(), uri);
  fetcher.loadData(Priority.LOW, callback);

  verify(callback).onLoadFailed(isA(FileNotFoundException.class));
}
项目:GitHub    文件:UriLoader.java   
@Override
public DataFetcher<InputStream> build(Uri uri) {
  return new StreamLocalUriFetcher(contentResolver, uri);
}
项目:GitHub    文件:UriLoader.java   
@Override
public DataFetcher<InputStream> build(Uri uri) {
  return new StreamLocalUriFetcher(contentResolver, uri);
}
项目:saarang-iosched    文件:StreamUriLoader.java   
@Override
protected DataFetcher<InputStream> getLocalUriFetcher(Context context, Uri uri) {
    return new StreamLocalUriFetcher(context, uri);
}
项目:AppDevFestSudeste2015    文件:StreamUriLoader.java   
@Override
protected DataFetcher<InputStream> getLocalUriFetcher(Context context, Uri uri) {
    return new StreamLocalUriFetcher(context, uri);
}
项目:devfestnorte-app    文件:StreamUriLoader.java   
@Override
protected DataFetcher<InputStream> getLocalUriFetcher(Context context, Uri uri) {
    return new StreamLocalUriFetcher(context, uri);
}
项目:saarang-iosched    文件:StreamUriLoader.java   
@Override
protected DataFetcher<InputStream> getLocalUriFetcher(Context context, Uri uri) {
    return new StreamLocalUriFetcher(context, uri);
}