本文整理汇总了Java中com.facebook.imagepipeline.request.ImageRequest.getMediaVariations方法的典型用法代码示例。如果您正苦于以下问题:Java ImageRequest.getMediaVariations方法的具体用法?Java ImageRequest.getMediaVariations怎么用?Java ImageRequest.getMediaVariations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.imagepipeline.request.ImageRequest
的用法示例。
在下文中一共展示了ImageRequest.getMediaVariations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: submitFetchRequest
import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
private <T> DataSource<CloseableReference<T>> submitFetchRequest(
Producer<CloseableReference<T>> producerSequence,
ImageRequest imageRequest,
ImageRequest.RequestLevel lowestPermittedRequestLevelOnSubmit,
Object callerContext) {
final RequestListener requestListener = getRequestListenerForRequest(imageRequest);
try {
ImageRequest.RequestLevel lowestPermittedRequestLevel =
ImageRequest.RequestLevel.getMax(
imageRequest.getLowestPermittedRequestLevel(),
lowestPermittedRequestLevelOnSubmit);
SettableProducerContext settableProducerContext = new SettableProducerContext(
imageRequest,
generateUniqueFutureId(),
requestListener,
callerContext,
lowestPermittedRequestLevel,
/* isPrefetch */ false,
imageRequest.getProgressiveRenderingEnabled() ||
imageRequest.getMediaVariations() != null ||
!UriUtil.isNetworkUri(imageRequest.getSourceUri()),
imageRequest.getPriority());
return CloseableProducerToDataSourceAdapter.create(
producerSequence,
settableProducerContext,
requestListener);
} catch (Exception exception) {
return DataSources.immediateFailedDataSource(exception);
}
}
示例2: produceResults
import com.facebook.imagepipeline.request.ImageRequest; //导入方法依赖的package包/类
public void produceResults(
final Consumer<EncodedImage> consumer,
final ProducerContext producerContext) {
final ImageRequest imageRequest = producerContext.getImageRequest();
final ResizeOptions resizeOptions = imageRequest.getResizeOptions();
final MediaVariations mediaVariations = imageRequest.getMediaVariations();
if (!imageRequest.isDiskCacheEnabled() ||
resizeOptions == null ||
resizeOptions.height <= 0 ||
resizeOptions.width <= 0 ||
imageRequest.getBytesRange() != null) {
startInputProducerWithExistingConsumer(consumer, producerContext);
return;
}
if (mediaVariations == null) {
startInputProducerWithExistingConsumer(consumer, producerContext);
return;
}
producerContext.getListener().onProducerStart(producerContext.getId(), PRODUCER_NAME);
final AtomicBoolean isCancelled = new AtomicBoolean(false);
if (mediaVariations.getVariantsCount() > 0) {
chooseFromVariants(
consumer,
producerContext,
imageRequest,
mediaVariations,
resizeOptions,
isCancelled);
} else {
MediaVariations.Builder mediaVariationsBuilder =
MediaVariations.newBuilderForMediaId(mediaVariations.getMediaId())
.setForceRequestForSpecifiedUri(mediaVariations.shouldForceRequestForSpecifiedUri())
.setSource(MediaVariations.SOURCE_INDEX_DB);
Task<MediaVariations> indexedMediaVariationsTask =
mMediaVariationsIndex.getCachedVariants(
mediaVariations.getMediaId(), mediaVariationsBuilder);
indexedMediaVariationsTask.continueWith(
new Continuation<MediaVariations, Object>() {
@Override
public Object then(Task<MediaVariations> task) throws Exception {
if (task.isCancelled() || task.isFaulted()) {
return task;
} else {
try {
if (task.getResult() == null) {
startInputProducerWithWrappedConsumer(
consumer, producerContext, mediaVariations.getMediaId());
return null;
} else {
return chooseFromVariants(
consumer,
producerContext,
imageRequest,
task.getResult(),
resizeOptions,
isCancelled);
}
} catch (Exception e) {
return null;
}
}
}
});
}
subscribeTaskForRequestCancellation(isCancelled, producerContext);
}