use of com.facebook.imagepipeline.common.ResizeOptions in project actor-platform by actorapp.
the class PhotoHolder method bindImage.
public void bindImage(Uri uri) {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(previewView.getLayoutParams().width, previewView.getLayoutParams().height)).build();
PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(previewView.getController()).setImageRequest(request).setControllerListener(animationController).build();
previewView.setController(controller);
}
use of com.facebook.imagepipeline.common.ResizeOptions in project actor-platform by actorapp.
the class AvatarView method bind.
public void bind(Avatar avatar, String title, int id) {
// Same avatar
if (avatar != null && getImage(avatar) != null && getImage(avatar).getFileReference().getFileId() == currentId) {
return;
}
getHierarchy().setPlaceholderImage(new AvatarPlaceholderDrawable(title, id, placeholderTextSize, getContext()));
if (bindedFile != null) {
bindedFile.detach();
bindedFile = null;
}
setImageURI(null);
if (avatar == null || getImage(avatar) == null) {
currentId = 0;
return;
}
currentId = getImage(avatar).getFileReference().getFileId();
bindedFile = messenger().bindFile(getImage(avatar).getFileReference(), true, new FileVMCallback() {
@Override
public void onNotDownloaded() {
}
@Override
public void onDownloading(float progress) {
}
@Override
public void onDownloaded(FileSystemReference reference) {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(new File(reference.getDescriptor()))).setResizeOptions(new ResizeOptions(size, size)).build();
PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(getController()).setImageRequest(request).build();
setController(controller);
}
});
}
use of com.facebook.imagepipeline.common.ResizeOptions in project actor-platform by actorapp.
the class BackgroundPreviewView method bind.
public void bind(int i) {
if (i != BACKGROUNDS.length) {
int bkgrnd = getBackground(i);
Uri uri = new Uri.Builder().scheme(UriUtil.LOCAL_RESOURCE_SCHEME).path(String.valueOf(bkgrnd)).build();
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(width, height)).build();
PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(getController()).setImageRequest(request).build();
setController(controller);
} else {
if (BaseActorSettingsFragment.getWallpaperFile() != null) {
File customWallpaper = new File(BaseActorSettingsFragment.getWallpaperFile());
if (!customWallpaper.exists()) {
return;
}
Uri uri = Uri.fromFile(customWallpaper);
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(width, height)).build();
PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(getController()).setImageRequest(request).build();
setController(controller);
}
}
}
use of com.facebook.imagepipeline.common.ResizeOptions in project fresco by facebook.
the class MediaVariationsFallbackProducerTest method testSendsNonFinalImageToConsumerAndStartsInputProducerIfRequestForcesRequestForSpecifiedUri.
@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, false);
verify(mConsumer, never()).onProgressUpdate(anyFloat());
verify(mProducerListener).onProducerStart(mRequestId, PRODUCER_NAME);
verifySuccessSentToListener(FOUND, NOT_USED_AS_LAST, MediaVariations.SOURCE_INDEX_DB, 1);
verifyInputProducerProduceResultsWithNewConsumer();
verifyZeroInteractions(mSmallImageBufferedDiskCache);
}
use of com.facebook.imagepipeline.common.ResizeOptions in project fresco by facebook.
the class MediaVariationsFallbackProducerTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
mMediaVariationsFallbackProducer = new MediaVariationsFallbackProducer(mDefaultBufferedDiskCache, mSmallImageBufferedDiskCache, mCacheKeyFactory, mMediaVariationsIndex, mMediaIdExtractor, mDiskCachePolicy, mInputProducer);
mProducerContext = new SettableProducerContext(mImageRequest, mRequestId, mProducerListener, mCallerContext, ImageRequest.RequestLevel.FULL_FETCH, false, true, Priority.MEDIUM);
mMediaVariationsWithVariants = MediaVariations.newBuilderForMediaId(MEDIA_ID).addVariant(URI_S, SIZE_S, SIZE_S).addVariant(URI_M, SIZE_M, SIZE_M).addVariant(URI_L, SIZE_L, SIZE_L).build();
mEmptyMediaVariations = MediaVariations.newBuilderForMediaId(MEDIA_ID).build();
when(mImageRequest.getSourceUri()).thenReturn(URI_ORIGINAL);
when(mImageRequest.getCacheChoice()).thenReturn(CacheChoice.DEFAULT);
when(mImageRequest.getResizeOptions()).thenReturn(new ResizeOptions(SIZE_M, SIZE_M));
when(mImageRequest.isDiskCacheEnabled()).thenReturn(true);
when(mProducerListener.requiresExtraMap(mRequestId)).thenReturn(true);
when(mCacheKeyFactory.getEncodedCacheKey(mImageRequest, mCallerContext)).thenReturn(CACHE_KEY_ORIGINAL);
when(mCacheKeyFactory.getEncodedCacheKey(mImageRequest, URI_S, mCallerContext)).thenReturn(CACHE_KEY_S);
when(mCacheKeyFactory.getEncodedCacheKey(mImageRequest, URI_M, mCallerContext)).thenReturn(CACHE_KEY_M);
when(mCacheKeyFactory.getEncodedCacheKey(mImageRequest, URI_L, mCallerContext)).thenReturn(CACHE_KEY_L);
whenIndexDbContainsNoMatchingVariants();
when(mMediaIdExtractor.getMediaIdFrom(any(Uri.class))).thenReturn(null);
when(mDiskCachePolicy.getCacheChoiceForResult(any(ImageRequest.class), any(EncodedImage.class))).thenReturn(CacheChoice.DEFAULT);
when(mDefaultBufferedDiskCache.get(any(CacheKey.class), any(AtomicBoolean.class))).thenReturn(Task.<EncodedImage>forResult(null));
when(mSmallImageBufferedDiskCache.get(any(CacheKey.class), any(AtomicBoolean.class))).thenReturn(Task.<EncodedImage>forResult(null));
}
Aggregations