Search in sources :

Example 11 with ImageInfo

use of com.facebook.imagepipeline.image.ImageInfo in project fresco by facebook.

the class ImageFormatProgressiveJpegFragment method setImageUri.

private void setImageUri(Uri uri) {
    mDebugOutput.setText("");
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).setProgressiveRenderingEnabled(mProgressiveRenderingEnabled).build();
    DraweeController controller = Fresco.newDraweeControllerBuilder().setImageRequest(request).setRetainImageOnFailure(true).setPerfDataListener(mImagePerfDataListener).setControllerListener(new BaseControllerListener<ImageInfo>() {

        @Override
        public void onFinalImageSet(String id, @javax.annotation.Nullable ImageInfo imageInfo, @javax.annotation.Nullable Animatable animatable) {
            if (imageInfo != null) {
                QualityInfo qualityInfo = imageInfo.getQualityInfo();
                logScan(qualityInfo, true);
            }
        }

        @Override
        public void onIntermediateImageSet(String id, @javax.annotation.Nullable ImageInfo imageInfo) {
            if (imageInfo != null) {
                QualityInfo qualityInfo = imageInfo.getQualityInfo();
                logScan(qualityInfo, false);
            }
        }

        @Override
        public void onIntermediateImageFailed(String id, Throwable throwable) {
            mDebugOutput.append(String.format(Locale.getDefault(), "onIntermediateImageFailed, %s\n", throwable.getMessage()));
        }
    }).build();
    mSimpleDraweeView.setController(controller);
}
Also used : BaseControllerListener(com.facebook.drawee.controller.BaseControllerListener) DraweeController(com.facebook.drawee.interfaces.DraweeController) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) Animatable(android.graphics.drawable.Animatable) QualityInfo(com.facebook.imagepipeline.image.QualityInfo) ImageInfo(com.facebook.imagepipeline.image.ImageInfo)

Example 12 with ImageInfo

use of com.facebook.imagepipeline.image.ImageInfo in project fresco by facebook.

the class ControllerListenerWrapperTest method testOnFinalImageSetNormalDrawable.

@Test
public void testOnFinalImageSetNormalDrawable() {
    final Drawable drawable = mock(Drawable.class);
    final ImageInfo imageInfo = mock(ImageInfo.class);
    mControllerListenerWrapper.onFinalImageSet(ID, ImageOrigin.DISK, imageInfo, drawable);
    verify(mControllerListener).onFinalImageSet(eq(STRING_ID), eq(imageInfo), isNull(Animatable.class));
    verifyNoMoreInteractions(mControllerListener);
}
Also used : Drawable(android.graphics.drawable.Drawable) Animatable(android.graphics.drawable.Animatable) ImageInfo(com.facebook.imagepipeline.image.ImageInfo) Test(org.junit.Test)

Example 13 with ImageInfo

use of com.facebook.imagepipeline.image.ImageInfo in project fresco by facebook.

the class ControllerListenerWrapperTest method testOnFinalImageSetAnimatedDrawable.

@Test
public void testOnFinalImageSetAnimatedDrawable() {
    final AnimatedDrawable drawable = mock(AnimatedDrawable.class);
    final ImageInfo imageInfo = mock(ImageInfo.class);
    mControllerListenerWrapper.onFinalImageSet(ID, ImageOrigin.DISK, imageInfo, drawable);
    verify(mControllerListener).onFinalImageSet(eq(STRING_ID), eq(imageInfo), eq(drawable));
    verifyNoMoreInteractions(mControllerListener);
}
Also used : ImageInfo(com.facebook.imagepipeline.image.ImageInfo) Test(org.junit.Test)

Aggregations

ImageInfo (com.facebook.imagepipeline.image.ImageInfo)13 Animatable (android.graphics.drawable.Animatable)11 BaseControllerListener (com.facebook.drawee.controller.BaseControllerListener)8 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)7 DraweeController (com.facebook.drawee.interfaces.DraweeController)5 QualityInfo (com.facebook.imagepipeline.image.QualityInfo)4 Uri (android.net.Uri)3 Nullable (android.support.annotation.Nullable)3 View (android.view.View)3 ControllerListener (com.facebook.drawee.controller.ControllerListener)3 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)3 Test (org.junit.Test)3 Point (android.graphics.Point)2 ViewGroup (android.view.ViewGroup)2 TextView (android.widget.TextView)2 PipelineDraweeControllerBuilder (com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder)2 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)2 Drawable (android.graphics.drawable.Drawable)1 AdapterView (android.widget.AdapterView)1 GenericDraweeHierarchy (com.facebook.drawee.generic.GenericDraweeHierarchy)1