Search in sources :

Example 36 with DraweeController

use of com.facebook.drawee.interfaces.DraweeController in project fresco by facebook.

the class ImageFormatKeyframesFragment method initAnimation.

private void initAnimation(View view) {
    mSimpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
    mSimpleDraweeView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    DraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(mSimpleDraweeView.getController()).setUri(sampleUris().createKeyframesUri()).setAutoPlayAnimations(true).build();
    mSimpleDraweeView.setController(controller);
    final SwitchCompat switchBackground = (SwitchCompat) view.findViewById(R.id.switch_background);
    switchBackground.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mSimpleDraweeView.getHierarchy().setBackgroundImage(isChecked ? new CheckerBoardDrawable(getResources()) : null);
        }
    });
}
Also used : CheckerBoardDrawable(com.facebook.fresco.samples.showcase.misc.CheckerBoardDrawable) DraweeController(com.facebook.drawee.interfaces.DraweeController) CompoundButton(android.widget.CompoundButton) SwitchCompat(androidx.appcompat.widget.SwitchCompat)

Example 37 with DraweeController

use of com.facebook.drawee.interfaces.DraweeController in project fresco by facebook.

the class ImagePipelinePostProcessorFragment method setPostprocessor.

private void setPostprocessor(Postprocessor postprocessor) {
    final ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri).setPostprocessor(postprocessor).build();
    final DraweeController draweeController = Fresco.newDraweeControllerBuilder().setOldController(mDraweeMain.getController()).setImageRequest(imageRequest).build();
    mDraweeMain.setController(draweeController);
}
Also used : DraweeController(com.facebook.drawee.interfaces.DraweeController) ImageRequest(com.facebook.imagepipeline.request.ImageRequest)

Example 38 with DraweeController

use of com.facebook.drawee.interfaces.DraweeController in project fresco by facebook.

the class ImagePipelineResizingFragment method reloadImage.

private void reloadImage(Uri imageUri, @Nullable ResizeOptions resizeOptions) {
    final ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(imageUri).setResizeOptions(resizeOptions).setImageDecodeOptions(new ImageDecodeOptionsBuilder().build()).build();
    final DraweeController draweeController = Fresco.newDraweeControllerBuilder().setOldController(mDraweeMain.getController()).setImageRequest(imageRequest).build();
    mDraweeMain.setController(draweeController);
}
Also used : DraweeController(com.facebook.drawee.interfaces.DraweeController) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) ImageDecodeOptionsBuilder(com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder)

Example 39 with DraweeController

use of com.facebook.drawee.interfaces.DraweeController 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 40 with DraweeController

use of com.facebook.drawee.interfaces.DraweeController in project fresco by facebook.

the class ToggleAnimationClickListener method onClick.

@Override
public void onClick(View v) {
    DraweeController controller = mDraweeView.getController();
    if (controller == null) {
        return;
    }
    Animatable animatable = controller.getAnimatable();
    if (animatable == null) {
        return;
    }
    if (animatable.isRunning()) {
        animatable.stop();
    } else {
        animatable.start();
    }
}
Also used : DraweeController(com.facebook.drawee.interfaces.DraweeController) Animatable(android.graphics.drawable.Animatable)

Aggregations

DraweeController (com.facebook.drawee.interfaces.DraweeController)53 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)25 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)10 Uri (android.net.Uri)8 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)8 Animatable (android.graphics.drawable.Animatable)7 BaseControllerListener (com.facebook.drawee.controller.BaseControllerListener)6 GenericDraweeHierarchy (com.facebook.drawee.generic.GenericDraweeHierarchy)5 ImageInfo (com.facebook.imagepipeline.image.ImageInfo)5 ControllerListener (com.facebook.drawee.controller.ControllerListener)4 QualityInfo (com.facebook.imagepipeline.image.QualityInfo)4 Drawable (android.graphics.drawable.Drawable)3 Nullable (android.support.annotation.Nullable)3 Canvas (android.graphics.Canvas)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2 View (android.view.View)2 ViewGroup (android.view.ViewGroup)2 AbstractDraweeController (com.facebook.drawee.controller.AbstractDraweeController)2 ProgressBarDrawable (com.facebook.drawee.drawable.ProgressBarDrawable)2 GenericDraweeHierarchyBuilder (com.facebook.drawee.generic.GenericDraweeHierarchyBuilder)2