Search in sources :

Example 1 with ResizeOptions

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);
}
Also used : PipelineDraweeController(com.facebook.drawee.backends.pipeline.PipelineDraweeController) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest)

Example 2 with ResizeOptions

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);
        }
    });
}
Also used : FileSystemReference(im.actor.runtime.files.FileSystemReference) PipelineDraweeController(com.facebook.drawee.backends.pipeline.PipelineDraweeController) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) File(java.io.File) FileVMCallback(im.actor.core.viewmodel.FileVMCallback)

Example 3 with ResizeOptions

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);
        }
    }
}
Also used : PipelineDraweeController(com.facebook.drawee.backends.pipeline.PipelineDraweeController) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) Uri(android.net.Uri) File(java.io.File)

Example 4 with ResizeOptions

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);
}
Also used : ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) MediaVariations(com.facebook.imagepipeline.request.MediaVariations) Test(org.junit.Test)

Example 5 with ResizeOptions

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));
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) Uri(android.net.Uri) EncodedImage(com.facebook.imagepipeline.image.EncodedImage) CacheKey(com.facebook.cache.common.CacheKey) SimpleCacheKey(com.facebook.cache.common.SimpleCacheKey) Before(org.junit.Before)

Aggregations

ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)59 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)27 Uri (android.net.Uri)12 Test (org.junit.Test)11 DraweeController (com.facebook.drawee.interfaces.DraweeController)10 ImageRequestBuilder (com.facebook.imagepipeline.request.ImageRequestBuilder)7 PipelineDraweeController (com.facebook.drawee.backends.pipeline.PipelineDraweeController)5 File (java.io.File)5 PipelineDraweeControllerBuilder (com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder)4 Drawable (android.graphics.drawable.Drawable)3 CloseableReference (com.facebook.common.references.CloseableReference)3 GenericDraweeHierarchy (com.facebook.drawee.generic.GenericDraweeHierarchy)3 EncodedImage (com.facebook.imagepipeline.image.EncodedImage)3 FileSystemReference (im.actor.runtime.files.FileSystemReference)3 Context (android.content.Context)2 Canvas (android.graphics.Canvas)2 Point (android.graphics.Point)2 Animatable (android.graphics.drawable.Animatable)2 View (android.view.View)2 Spinner (android.widget.Spinner)2