Search in sources :

Example 6 with ImageInfo

use of com.facebook.imagepipeline.image.ImageInfo in project ride-read-android by Ride-Read.

the class ImageActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    imageUrl = getIntent().getStringExtra(IMAGE);
    if (imageUrl.startsWith("/")) {
        imageUrl = "file://" + imageUrl;
    }
    final PhotoDraweeView photoDraweeView = (PhotoDraweeView) findViewById(R.id.iv_image_activity);
    photoDraweeView.setOnViewTapListener(new OnViewTapListener() {

        @Override
        public void onViewTap(View view, float x, float y) {
            onBackPressed();
        }
    });
    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setUri(Uri.parse(imageUrl));
    controller.setOldController(photoDraweeView.getController());
    controller.setControllerListener(new BaseControllerListener<ImageInfo>() {

        @Override
        public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            super.onFinalImageSet(id, imageInfo, animatable);
            if (imageInfo == null) {
                return;
            }
            photoDraweeView.update(imageInfo.getWidth(), imageInfo.getHeight());
        }
    });
    photoDraweeView.setController(controller.build());
}
Also used : OnViewTapListener(me.relex.photodraweeview.OnViewTapListener) Animatable(android.graphics.drawable.Animatable) PhotoDraweeView(me.relex.photodraweeview.PhotoDraweeView) ImageInfo(com.facebook.imagepipeline.image.ImageInfo) View(android.view.View) PhotoDraweeView(me.relex.photodraweeview.PhotoDraweeView) PipelineDraweeControllerBuilder(com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder)

Example 7 with ImageInfo

use of com.facebook.imagepipeline.image.ImageInfo in project SherlockAdapter by EvilBT.

the class FrescoUtil method setWrapImage.

public static void setWrapImage(@NonNull final SimpleDraweeView view, @NonNull final String path) {
    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);
            }
        }
    };
    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) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) Animatable(android.graphics.drawable.Animatable) ImageInfo(com.facebook.imagepipeline.image.ImageInfo)

Example 8 with ImageInfo

use of com.facebook.imagepipeline.image.ImageInfo 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 9 with ImageInfo

use of com.facebook.imagepipeline.image.ImageInfo 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 10 with ImageInfo

use of com.facebook.imagepipeline.image.ImageInfo 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)

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