本文整理汇总了Java中com.facebook.imagepipeline.common.ResizeOptions类的典型用法代码示例。如果您正苦于以下问题:Java ResizeOptions类的具体用法?Java ResizeOptions怎么用?Java ResizeOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResizeOptions类属于com.facebook.imagepipeline.common包,在下文中一共展示了ResizeOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BitmapMemoryCacheKey
import com.facebook.imagepipeline.common.ResizeOptions; //导入依赖的package包/类
public BitmapMemoryCacheKey(
String sourceString,
@Nullable ResizeOptions resizeOptions,
RotationOptions rotationOptions,
ImageDecodeOptions imageDecodeOptions,
@Nullable CacheKey postprocessorCacheKey,
@Nullable String postprocessorName,
Object callerContext) {
mSourceString = Preconditions.checkNotNull(sourceString);
mResizeOptions = resizeOptions;
mRotationOptions = rotationOptions;
mImageDecodeOptions = imageDecodeOptions;
mPostprocessorCacheKey = postprocessorCacheKey;
mPostprocessorName = postprocessorName;
mHash = HashCodeUtil.hashCode(
sourceString.hashCode(),
(resizeOptions != null) ? resizeOptions.hashCode() : 0,
rotationOptions.hashCode(),
mImageDecodeOptions,
mPostprocessorCacheKey,
postprocessorName);
mCallerContext = callerContext;
mCacheTime = RealtimeSinceBootClock.get().now();
}
示例2: determineResizeRatio
import com.facebook.imagepipeline.common.ResizeOptions; //导入依赖的package包/类
@VisibleForTesting static float determineResizeRatio(
ResizeOptions resizeOptions,
int width,
int height) {
if (resizeOptions == null) {
return 1.0f;
}
final float widthRatio = ((float) resizeOptions.width) / width;
final float heightRatio = ((float) resizeOptions.height) / height;
float ratio = Math.max(widthRatio, heightRatio);
if (width * ratio > resizeOptions.maxBitmapSize) {
ratio = resizeOptions.maxBitmapSize / width;
}
if (height * ratio > resizeOptions.maxBitmapSize) {
ratio = resizeOptions.maxBitmapSize / height;
}
return ratio;
}
示例3: testCreatingRequestFromExistingRequest
import com.facebook.imagepipeline.common.ResizeOptions; //导入依赖的package包/类
@Test
public void testCreatingRequestFromExistingRequest() {
ImageRequest original = ImageRequestBuilder
.newBuilderWithSource(Uri.parse("http://frescolib.org/image.jpg"))
.setCacheChoice(ImageRequest.CacheChoice.SMALL)
.setImageDecodeOptions(new ImageDecodeOptionsBuilder().build())
.setLocalThumbnailPreviewsEnabled(true)
.setLowestPermittedRequestLevel(ImageRequest.RequestLevel.DISK_CACHE)
.setMediaVariations(MediaVariations.forMediaId("A113"))
.setPostprocessor(new BasePostprocessor() {
@Override
public String getName() {
return super.getName();
}
})
.setProgressiveRenderingEnabled(true)
.setRequestListener(new RequestLoggingListener())
.setResizeOptions(new ResizeOptions(20, 20))
.setRotationOptions(RotationOptions.forceRotation(RotationOptions.ROTATE_90))
.setRequestPriority(Priority.HIGH)
.build();
ImageRequest copy = ImageRequestBuilder.fromRequest(original).build();
assertThat(copy).isEqualTo(original);
}
示例4: testWithImageNotBigEnoughForResizeOptions
import com.facebook.imagepipeline.common.ResizeOptions; //导入依赖的package包/类
private static void testWithImageNotBigEnoughForResizeOptions(
int[] imageWidths,
int[] imageHeights,
int startRotation,
int additionalRequestWidth,
int additionalRequestHeight) {
for (int rotation = startRotation; rotation < 360; rotation += 180) {
for (int i = 0; i < TEST_COUNT; i++) {
ResizeOptions resizeOptions = new ResizeOptions(
REQUEST_WIDTHS[i] + additionalRequestWidth,
REQUEST_HEIGHTS[i] + additionalRequestHeight);
EncodedImage encodedImage = mockImage(imageWidths[i], imageHeights[i], rotation);
assertFalse(ThumbnailSizeChecker.isImageBigEnough(encodedImage, resizeOptions));
}
}
}
示例5: testDecode_WhenSmartResizingEnabledAndLocalUri_ThenPerformDownsampling
import com.facebook.imagepipeline.common.ResizeOptions; //导入依赖的package包/类
@Test
public void testDecode_WhenSmartResizingEnabledAndLocalUri_ThenPerformDownsampling()
throws Exception {
int resizedWidth = 10;
int resizedHeight = 10;
when(mExperimentalResizingEnabledSupplier.get()).thenReturn(true);
setupLocalUri(ResizeOptions.forDimensions(resizedWidth, resizedHeight));
produceResults();
JobScheduler.JobRunnable jobRunnable = getJobRunnable();
jobRunnable.run(mEncodedImage, Consumer.IS_LAST);
// The sample size was modified, which means Downsampling has been performed
assertNotEquals(mEncodedImage.getSampleSize(), EncodedImage.DEFAULT_SAMPLE_SIZE);
}
示例6: testDecode_WhenSmartResizingEnabledAndNetworkUri_ThenPerformNoDownsampling
import com.facebook.imagepipeline.common.ResizeOptions; //导入依赖的package包/类
@Test
public void testDecode_WhenSmartResizingEnabledAndNetworkUri_ThenPerformNoDownsampling()
throws Exception {
int resizedWidth = 10;
int resizedHeight = 10;
when(mExperimentalResizingEnabledSupplier.get()).thenReturn(true);
setupNetworkUri(ResizeOptions.forDimensions(resizedWidth, resizedHeight));
produceResults();
JobScheduler.JobRunnable jobRunnable = getJobRunnable();
jobRunnable.run(mEncodedImage, Consumer.IS_LAST);
// The sample size was not modified, which means Downsampling has not been performed
assertEquals(mEncodedImage.getSampleSize(), EncodedImage.DEFAULT_SAMPLE_SIZE);
}
示例7: testSendsSmallestLargerFinalImageToConsumerWhenLargerVariantsFromIndexFound
import com.facebook.imagepipeline.common.ResizeOptions; //导入依赖的package包/类
@Test
public void testSendsSmallestLargerFinalImageToConsumerWhenLargerVariantsFromIndexFound() {
when(mImageRequest.getMediaVariations()).thenReturn(mMediaVariationsWithVariants);
whenCacheContains(mDefaultBufferedDiskCache, CACHE_KEY_S, CACHE_KEY_M, CACHE_KEY_L);
whenIndexDbContains(URI_M, SIZE_M, CacheChoice.DEFAULT);
when(mImageRequest.getResizeOptions()).thenReturn(new ResizeOptions(SIZE_M - 10, SIZE_M - 10));
mMediaVariationsFallbackProducer.produceResults(mConsumer, mProducerContext);
verify(mConsumer).onNewResult(mImageM, Consumer.IS_LAST | Consumer.DO_NOT_CACHE_ENCODED);
verify(mConsumer).onProgressUpdate(1L);
verify(mProducerListener).onProducerStart(mRequestId, PRODUCER_NAME);
verifySuccessSentToListener(
FOUND,
USED_AS_LAST,
MediaVariations.SOURCE_IMAGE_REQUEST,
VARIANTS_COUNT);
verifyZeroInteractions(mInputProducer, mSmallImageBufferedDiskCache);
}
示例8: when
import com.facebook.imagepipeline.common.ResizeOptions; //导入依赖的package包/类
@Test
public void testSendsLargestCachedNonFinalImageToConsumerAndStartsInputProducerIfNoCachedVariantFromRequestBigEnough() {
when(mImageRequest.getMediaVariations()).thenReturn(mMediaVariationsWithVariants);
whenCacheContains(mDefaultBufferedDiskCache, CACHE_KEY_S, CACHE_KEY_M, CACHE_KEY_L);
when(mImageRequest.getResizeOptions()).thenReturn(new ResizeOptions(SIZE_L + 80, SIZE_L + 80));
mMediaVariationsFallbackProducer.produceResults(mConsumer, mProducerContext);
verify(mConsumer).onNewResult(mImageL, Consumer.DO_NOT_CACHE_ENCODED | Consumer.IS_PLACEHOLDER);
verify(mConsumer, never()).onProgressUpdate(anyFloat());
verifyInputProducerProduceResultsWithNewConsumer(false);
verify(mProducerListener).onProducerStart(mRequestId, PRODUCER_NAME);
verifySuccessSentToListener(
FOUND,
NOT_USED_AS_LAST,
MediaVariations.SOURCE_IMAGE_REQUEST,
VARIANTS_COUNT);
verifyZeroInteractions(mSmallImageBufferedDiskCache);
}
示例9: testSendsSmallestLargerFinalImageToConsumerWhenLargerVariantsFromRequestFound
import com.facebook.imagepipeline.common.ResizeOptions; //导入依赖的package包/类
@Test
public void testSendsSmallestLargerFinalImageToConsumerWhenLargerVariantsFromRequestFound() {
when(mImageRequest.getMediaVariations()).thenReturn(mMediaVariationsWithVariants);
whenCacheContains(mDefaultBufferedDiskCache, CACHE_KEY_S, CACHE_KEY_M, CACHE_KEY_L);
when(mImageRequest.getResizeOptions()).thenReturn(new ResizeOptions(SIZE_M - 10, SIZE_M - 10));
mMediaVariationsFallbackProducer.produceResults(mConsumer, mProducerContext);
verify(mConsumer).onNewResult(mImageM, Consumer.IS_LAST | Consumer.DO_NOT_CACHE_ENCODED);
verify(mConsumer).onProgressUpdate(1L);
verify(mProducerListener).onProducerStart(mRequestId, PRODUCER_NAME);
verifySuccessSentToListener(
FOUND,
USED_AS_LAST,
MediaVariations.SOURCE_IMAGE_REQUEST,
VARIANTS_COUNT);
verifyZeroInteractions(mInputProducer, mSmallImageBufferedDiskCache);
}
示例10: testSendsNonFinalImageToConsumerAndStartsInputProducerIfRequestForcesRequestForSpecifiedUri
import com.facebook.imagepipeline.common.ResizeOptions; //导入依赖的package包/类
@Test
public void testSendsNonFinalImageToConsumerAndStartsInputProducerIfRequestForcesRequestForSpecifiedUri() {
MediaVariations mediaVariations = MediaVariations.newBuilderForMediaId(MEDIA_ID)
.setForceRequestForSpecifiedUri(true)
.build();
when(mImageRequest.getMediaVariations()).thenReturn(mediaVariations);
whenCacheContains(mDefaultBufferedDiskCache, CACHE_KEY_S, CACHE_KEY_M, CACHE_KEY_L);
whenIndexDbContains(URI_M, SIZE_M, CacheChoice.DEFAULT);
when(mImageRequest.getResizeOptions()).thenReturn(new ResizeOptions(SIZE_M - 10, SIZE_M - 10));
mMediaVariationsFallbackProducer.produceResults(mConsumer, mProducerContext);
verify(mConsumer).onNewResult(mImageM, Consumer.DO_NOT_CACHE_ENCODED | Consumer.IS_PLACEHOLDER);
verify(mConsumer, never()).onProgressUpdate(anyFloat());
verify(mProducerListener).onProducerStart(mRequestId, PRODUCER_NAME);
verifySuccessSentToListener(FOUND, NOT_USED_AS_LAST, MediaVariations.SOURCE_INDEX_DB, 1);
verifyInputProducerProduceResultsWithNewConsumer(false);
verifyZeroInteractions(mSmallImageBufferedDiskCache);
}
示例11: testUsesSmallCacheIfRequestedByImageRequest
import com.facebook.imagepipeline.common.ResizeOptions; //导入依赖的package包/类
@Test
public void testUsesSmallCacheIfRequestedByImageRequest() {
when(mImageRequest.getMediaVariations()).thenReturn(mMediaVariationsWithVariants);
whenCacheContains(mSmallImageBufferedDiskCache, CACHE_KEY_S, CACHE_KEY_M, CACHE_KEY_L);
when(mImageRequest.getResizeOptions()).thenReturn(new ResizeOptions(SIZE_S, SIZE_S));
when(mImageRequest.getCacheChoice()).thenReturn(CacheChoice.SMALL);
mMediaVariationsFallbackProducer.produceResults(mConsumer, mProducerContext);
verify(mConsumer).onNewResult(mImageS, Consumer.IS_LAST | Consumer.DO_NOT_CACHE_ENCODED);
verify(mConsumer).onProgressUpdate(1L);
verify(mProducerListener).onProducerStart(mRequestId, PRODUCER_NAME);
verifySuccessSentToListener(
FOUND,
USED_AS_LAST,
MediaVariations.SOURCE_IMAGE_REQUEST,
VARIANTS_COUNT);
verifyZeroInteractions(mInputProducer, mDefaultBufferedDiskCache);
}
示例12: testResizeRatio
import com.facebook.imagepipeline.common.ResizeOptions; //导入依赖的package包/类
@Test
public void testResizeRatio() {
ResizeOptions resizeOptions = new ResizeOptions(512, 512);
assertEquals(
0.5f,
ResizeAndRotateProducer.determineResizeRatio(resizeOptions, 1024, 1024),
0.01);
assertEquals(
0.25f,
ResizeAndRotateProducer.determineResizeRatio(resizeOptions, 2048, 4096),
0.01);
assertEquals(
0.5f,
ResizeAndRotateProducer.determineResizeRatio(resizeOptions, 4096, 512),
0.01);
}
示例13: onBind
import com.facebook.imagepipeline.common.ResizeOptions; //导入依赖的package包/类
@Override
protected void onBind(String uriString) {
Uri uri = Uri.parse(uriString);
ImageRequestBuilder imageRequestBuilder =
ImageRequestBuilder.newBuilderWithSource(uri);
if (UriUtil.isNetworkUri(uri)) {
imageRequestBuilder.setProgressiveRenderingEnabled(true);
} else {
imageRequestBuilder.setResizeOptions(new ResizeOptions(
mImageView.getLayoutParams().width,
mImageView.getLayoutParams().height));
}
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
.setImageRequest(imageRequestBuilder.build())
.setOldController(mImageView.getController())
.setControllerListener(mImageView.getListener())
.setAutoPlayAnimations(true)
.build();
mImageView.setController(draweeController);
}
示例14: loadThumb
import com.facebook.imagepipeline.common.ResizeOptions; //导入依赖的package包/类
private void loadThumb(
SimpleDraweeView draweeView,
Size size,
ImageRequest.RequestLevel requestLevel) {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(size.uri)
.setMediaVariations(MediaVariations.newBuilderForMediaId(MEDIA_ID)
.setForceRequestForSpecifiedUri(true)
.build())
.setLowestPermittedRequestLevel(requestLevel)
.setResizeOptions(new ResizeOptions(draweeView.getWidth(), draweeView.getHeight()))
.setCacheChoice(size.cacheChoice)
.build();
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setImageRequest(request)
.setOldController(draweeView.getController())
.build();
draweeView.setController(controller);
}
示例15: loadMainImage
import com.facebook.imagepipeline.common.ResizeOptions; //导入依赖的package包/类
private void loadMainImage() {
// Request a non-existent image to force fallback to the variations
Uri uri = Uri.parse(String.format(URI_TEMPLATE, "full", "jpg"));
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
.setMediaVariations(getMediaVariationsForMode(mMode))
.setResizeOptions(new ResizeOptions(
mMainImageDraweeView.getWidth(),
mMainImageDraweeView.getHeight()))
.build();
Log.i(
TAG,
request.getMediaVariations() == null ? "null" : request.getMediaVariations().toString());
setDraweeControllerForRequest(request);
}