本文整理汇总了Java中com.bumptech.glide.load.DataSource类的典型用法代码示例。如果您正苦于以下问题:Java DataSource类的具体用法?Java DataSource怎么用?Java DataSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataSource类属于com.bumptech.glide.load包,在下文中一共展示了DataSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notifyEncodeAndRelease
import com.bumptech.glide.load.DataSource; //导入依赖的package包/类
private void notifyEncodeAndRelease(Resource<R> resource, DataSource dataSource) {
if (resource instanceof Initializable) {
((Initializable) resource).initialize();
}
Resource<R> result = resource;
LockedResource<R> lockedResource = null;
if (deferredEncodeManager.hasResourceToEncode()) {
lockedResource = LockedResource.obtain(resource);
result = lockedResource;
}
notifyComplete(result, dataSource);
stage = Stage.ENCODE;
try {
if (deferredEncodeManager.hasResourceToEncode()) {
deferredEncodeManager.encode(diskCacheProvider, options);
}
} finally {
if (lockedResource != null) {
lockedResource.unlock();
}
onEncodeComplete();
}
}
示例2: decodeFromData
import com.bumptech.glide.load.DataSource; //导入依赖的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();
}
}
示例3: onDataFetcherReady
import com.bumptech.glide.load.DataSource; //导入依赖的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();
}
}
}
示例4: testFactoryReturnsNoAnimationIfFromMemoryCache
import com.bumptech.glide.load.DataSource; //导入依赖的package包/类
@Test
public void testFactoryReturnsNoAnimationIfFromMemoryCache() {
Transition<Object> animation =
factory.build(DataSource.MEMORY_CACHE, true /*isFirstResource*/);
assertEquals(NoTransition.get(), animation);
verify(viewTransitionAnimationFactory, never()).build(RuntimeEnvironment.application);
}
示例5: load_afterResourceIsLoadedInActiveResources_returnsFromMemoryCache
import com.bumptech.glide.load.DataSource; //导入依赖的package包/类
@Test
public void load_afterResourceIsLoadedInActiveResources_returnsFromMemoryCache() {
when(harness.resource.isCacheable()).thenReturn(true);
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
harness.getEngine().onEngineJobComplete(harness.cacheKey, harness.resource);
return null;
}
}).when(harness.job).start(any(DecodeJob.class));
harness.doLoad();
harness.doLoad();
verify(harness.cb).onResourceReady(any(Resource.class), eq(DataSource.MEMORY_CACHE));
}
示例6: build
import com.bumptech.glide.load.DataSource; //导入依赖的package包/类
@Override
public Transition<Drawable> build(DataSource dataSource, boolean isFirstResource) {
if (dataSource == DataSource.MEMORY_CACHE) {
return NoTransition.get();
} else if (isFirstResource) {
return getFirstResourceTransition(dataSource);
} else {
return getSecondResourceTransition(dataSource);
}
}
示例7: testRequestListenerIsCalledWithLoadedFromMemoryIfLoadCompletesSynchronously
import com.bumptech.glide.load.DataSource; //导入依赖的package包/类
@Test
public void testRequestListenerIsCalledWithLoadedFromMemoryIfLoadCompletesSynchronously() {
final SingleRequest<List> request = builder.build();
when(builder.engine
.load(
eq(builder.glideContext),
eq(builder.model),
eq(builder.signature),
anyInt(),
anyInt(),
eq(Object.class),
eq(List.class),
any(Priority.class),
any(DiskCacheStrategy.class),
eq(builder.transformations),
anyBoolean(),
anyBoolean(),
any(Options.class),
anyBoolean(),
anyBoolean(),
/*useAnimationPool=*/ anyBoolean(),
anyBoolean(),
any(ResourceCallback.class)))
.thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
request.onResourceReady(builder.resource, DataSource.MEMORY_CACHE);
return null;
}
});
request.begin();
request.onSizeReady(100, 100);
verify(builder.requestListener)
.onResourceReady(eq(builder.result), any(Number.class), isAListTarget(),
eq(DataSource.MEMORY_CACHE), anyBoolean());
}
示例8: testCanHandleEmptyResources
import com.bumptech.glide.load.DataSource; //导入依赖的package包/类
@Test
public void testCanHandleEmptyResources() {
SingleRequest<List> request = builder.build();
when(builder.resource.get()).thenReturn(null);
request.onResourceReady(builder.resource, DataSource.REMOTE);
assertTrue(request.isFailed());
verify(builder.engine).release(eq(builder.resource));
verify(builder.requestListener).onLoadFailed(isAGlideException(), any(Number.class),
eq(builder.target), anyBoolean());
}
示例9: testRequestListenerIsCalledWithNotIsFirstRequestIfRequestCoordinatorReturnsResourceSet
import com.bumptech.glide.load.DataSource; //导入依赖的package包/类
@Test
public void
testRequestListenerIsCalledWithNotIsFirstRequestIfRequestCoordinatorReturnsResourceSet() {
SingleRequest<List> request = builder.build();
when(builder.requestCoordinator.isAnyResourceSet()).thenReturn(true);
request.onResourceReady(builder.resource, DataSource.DATA_DISK_CACHE);
verify(builder.requestListener)
.onResourceReady(eq(builder.result), any(Number.class), isAListTarget(),
isADataSource(), eq(false));
}
示例10: testRequestListenerIsCalledWithTarget
import com.bumptech.glide.load.DataSource; //导入依赖的package包/类
@Test
public void testRequestListenerIsCalledWithTarget() {
SingleRequest<List> request = builder.build();
request.onResourceReady(builder.resource, DataSource.DATA_DISK_CACHE);
verify(builder.requestListener)
.onResourceReady(any(List.class), any(Number.class), eq(builder.target), isADataSource(),
anyBoolean());
}
示例11: testRequestListenerIsCalledWithResourceResult
import com.bumptech.glide.load.DataSource; //导入依赖的package包/类
@Test
public void testRequestListenerIsCalledWithResourceResult() {
SingleRequest<List> request = builder.build();
request.onResourceReady(builder.resource, DataSource.DATA_DISK_CACHE);
verify(builder.requestListener)
.onResourceReady(eq(builder.result), any(Number.class), isAListTarget(), isADataSource(),
anyBoolean());
}
示例12: testCanHandleNullResources
import com.bumptech.glide.load.DataSource; //导入依赖的package包/类
@Test
public void testCanHandleNullResources() {
SingleRequest<List> request = builder.build();
request.onResourceReady(null, DataSource.LOCAL);
assertTrue(request.isFailed());
verify(builder.requestListener).onLoadFailed(isAGlideException(), isA(Number.class),
eq(builder.target), anyBoolean());
}
示例13: testReturnsResourceOnGetIfAlreadyDone
import com.bumptech.glide.load.DataSource; //导入依赖的package包/类
@Test
public void testReturnsResourceOnGetIfAlreadyDone()
throws ExecutionException, InterruptedException {
Object expected = new Object();
future.onResourceReady(
/*resource=*/ expected,
/*model=*/ null,
/*target=*/future,
DataSource.DATA_DISK_CACHE,
true /*isFirstResource*/);
assertEquals(expected, future.get());
}
示例14: testResourceIsReturnedFromActiveResourcesIfPresent
import com.bumptech.glide.load.DataSource; //导入依赖的package包/类
@Test
public void testResourceIsReturnedFromActiveResourcesIfPresent() {
harness.activeResources.activate(harness.cacheKey, harness.resource);
harness.doLoad();
verify(harness.cb).onResourceReady(eq(harness.resource), eq(DataSource.MEMORY_CACHE));
}
示例15: testRequestListenerIsCalledWithModel
import com.bumptech.glide.load.DataSource; //导入依赖的package包/类
@Test
public void testRequestListenerIsCalledWithModel() {
SingleRequest<List> request = builder.build();
request.onResourceReady(builder.resource, DataSource.DATA_DISK_CACHE);
verify(builder.requestListener)
.onResourceReady(any(List.class), eq(builder.model), isAListTarget(), isADataSource(),
anyBoolean());
}