Search in sources :

Example 6 with BaseControllerListener

use of com.facebook.drawee.controller.BaseControllerListener in project remusic by aa112901.

the class QuickControlsFragment method updateNowplayingCard.

public void updateNowplayingCard() {
    mTitle.setText(MusicPlayer.getTrackName());
    mArtist.setText(MusicPlayer.getArtistName());
    ControllerListener controllerListener = new BaseControllerListener<ImageInfo>() {

        @Override
        public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable anim) {
            if (imageInfo == null) {
                return;
            }
            QualityInfo qualityInfo = imageInfo.getQualityInfo();
            FLog.d("Final image received! " + "Size %d x %d", "Quality level %d, good enough: %s, full quality: %s", imageInfo.getWidth(), imageInfo.getHeight(), qualityInfo.getQuality(), qualityInfo.isOfGoodEnoughQuality(), qualityInfo.isOfFullQuality());
        }

        @Override
        public void onIntermediateImageSet(String id, @Nullable ImageInfo imageInfo) {
        // FLog.d("Intermediate image received");
        }

        @Override
        public void onFailure(String id, Throwable throwable) {
            mAlbumArt.setImageURI(Uri.parse("res:/" + R.drawable.placeholder_disk_210));
        }
    };
    Uri uri = null;
    try {
        uri = Uri.parse(MusicPlayer.getAlbumPath());
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (uri != null) {
        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).build();
        DraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(mAlbumArt.getController()).setImageRequest(request).setControllerListener(controllerListener).build();
        mAlbumArt.setController(controller);
    } else {
        mAlbumArt.setImageURI(Uri.parse("content://" + MusicPlayer.getAlbumPath()));
    }
}
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) BaseControllerListener(com.facebook.drawee.controller.BaseControllerListener) ControllerListener(com.facebook.drawee.controller.ControllerListener) QualityInfo(com.facebook.imagepipeline.image.QualityInfo) ImageInfo(com.facebook.imagepipeline.image.ImageInfo) Uri(android.net.Uri) Nullable(android.support.annotation.Nullable)

Example 7 with BaseControllerListener

use of com.facebook.drawee.controller.BaseControllerListener in project SherlockAdapter by EvilBT.

the class FrescoUtil method resizeImage.

public static void resizeImage(@NonNull final SimpleDraweeView view, @NonNull final String path, final int viewWidth) {
    Preconditions.checkNotNull(view);
    Preconditions.checkNotNull(path);
    ControllerListener<ImageInfo> controllerListener = new BaseControllerListener<ImageInfo>() {

        @Override
        public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            if (imageInfo == null) {
                return;
            }
            final float width = imageInfo.getWidth();
            final float height = imageInfo.getHeight();
            if (width * height != 0.0f) {
                final int viewHeight = (int) (height * viewWidth / width);
                setResizeImage(view, path, new ResizeOptions(viewWidth, viewHeight));
            }
        }
    };
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(path)).build();
    view.setController(Fresco.newDraweeControllerBuilder().setImageRequest(request).setOldController(view.getController()).setControllerListener(controllerListener).build());
}
Also used : BaseControllerListener(com.facebook.drawee.controller.BaseControllerListener) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) Animatable(android.graphics.drawable.Animatable) ImageInfo(com.facebook.imagepipeline.image.ImageInfo) Point(android.graphics.Point)

Example 8 with BaseControllerListener

use of com.facebook.drawee.controller.BaseControllerListener in project SherlockAdapter by EvilBT.

the class FrescoUtil method setWrapAndResizeImage.

public static void setWrapAndResizeImage(@NonNull final SimpleDraweeView view, @NonNull final String path, final int viewWidth, @Nullable final Point size) {
    Preconditions.checkNotNull(view);
    Preconditions.checkNotNull(path);
    ControllerListener<ImageInfo> controllerListener = new BaseControllerListener<ImageInfo>() {

        @Override
        public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            if (imageInfo == null) {
                return;
            }
            final float width = imageInfo.getWidth();
            final float height = imageInfo.getHeight();
            if (width * height != 0.0f) {
                view.setAspectRatio(width / height);
                final int viewHeight = (int) (height * viewWidth / width);
                if (size != null) {
                    size.set(viewWidth, viewHeight);
                }
                setResizeImage(view, path, new ResizeOptions(viewWidth, viewHeight));
            }
        }
    };
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(path)).build();
    view.setController(Fresco.newDraweeControllerBuilder().setImageRequest(request).setOldController(view.getController()).setControllerListener(controllerListener).build());
}
Also used : BaseControllerListener(com.facebook.drawee.controller.BaseControllerListener) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) Animatable(android.graphics.drawable.Animatable) ImageInfo(com.facebook.imagepipeline.image.ImageInfo) Point(android.graphics.Point)

Example 9 with BaseControllerListener

use of com.facebook.drawee.controller.BaseControllerListener 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)

Aggregations

Animatable (android.graphics.drawable.Animatable)9 BaseControllerListener (com.facebook.drawee.controller.BaseControllerListener)9 ImageInfo (com.facebook.imagepipeline.image.ImageInfo)8 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)7 DraweeController (com.facebook.drawee.interfaces.DraweeController)6 Uri (android.net.Uri)4 ControllerListener (com.facebook.drawee.controller.ControllerListener)4 QualityInfo (com.facebook.imagepipeline.image.QualityInfo)4 Nullable (android.support.annotation.Nullable)3 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)3 Point (android.graphics.Point)2 View (android.view.View)2 ViewGroup (android.view.ViewGroup)2 GenericDraweeHierarchy (com.facebook.drawee.generic.GenericDraweeHierarchy)2 RoundingParams (com.facebook.drawee.generic.RoundingParams)2 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)2 ApplicationInfo (android.content.pm.ApplicationInfo)1 PackageManager (android.content.pm.PackageManager)1 Handler (android.os.Handler)1 TextView (android.widget.TextView)1