Search in sources :

Example 36 with ResizeOptions

use of com.facebook.imagepipeline.common.ResizeOptions in project actor-platform by actorapp.

the class AvatarView method bindRaw.

public void bindRaw(String fileName) {
    if (bindedFile != null) {
        bindedFile.detach();
        bindedFile = null;
    }
    currentId = 0;
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(new File(fileName))).setResizeOptions(new ResizeOptions(size, size)).setAutoRotateEnabled(true).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) File(java.io.File)

Example 37 with ResizeOptions

use of com.facebook.imagepipeline.common.ResizeOptions in project actor-platform by actorapp.

the class CallBackgroundAvatarView method bind.

public void bind(Avatar avatar) {
    // Same avatar
    if (avatar != null && getImage(avatar) != null && getImage(avatar).getFileReference().getFileId() == currentId) {
        return;
    }
    fastThumbLoader = new FastThumbLoader(this);
    fastThumbLoader.setBlur(10);
    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) {
            blurActor.send(new BlurActor.RequestBlur(reference.getDescriptor(), 10, new BlurActor.BluredListener() {

                @Override
                public void onBlured(final File f) {
                    ((BaseActivity) getContext()).runOnUiThread(new Runnable() {

                        @Override
                        public void run() {
                            ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(f)).setResizeOptions(new ResizeOptions(Screen.getWidth(), Screen.getHeight())).build();
                            PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(getController()).setImageRequest(request).build();
                            setController(controller);
                        }
                    });
                }
            }));
        }
    });
}
Also used : FileSystemReference(im.actor.runtime.files.FileSystemReference) FastThumbLoader(im.actor.sdk.controllers.conversation.view.FastThumbLoader) PipelineDraweeController(com.facebook.drawee.backends.pipeline.PipelineDraweeController) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) BaseActivity(im.actor.sdk.controllers.activity.BaseActivity) File(java.io.File) FileVMCallback(im.actor.core.viewmodel.FileVMCallback)

Example 38 with ResizeOptions

use of com.facebook.imagepipeline.common.ResizeOptions in project lzc_app_lib by httplzc.

the class BigImgDataRequestHelper method getHolderData.

// 获取holder 的catch
private void getHolderData(final WrapperUri wrapperUri) {
    final Uri holderUri = wrapperUri.getLowUri();
    if (holderUri == null)
        return;
    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(holderUri).setResizeOptions(new ResizeOptions(ScreenData.widthPX / 3, ScreenData.heightPX / 3)).build();
    DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(request, "");
    dataSource.subscribe(new BaseDataSubscriber<CloseableReference<CloseableImage>>() {

        @Override
        protected void onNewResultImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
            if (!dataSource.isFinished()) {
                return;
            }
            CloseableReference<CloseableImage> ref = dataSource.getResult();
            if (ref != null && ref.isValid()) {
                try {
                    if (data.get(wrapperUri.getUri()) == null) {
                        holderData.put(holderUri, ref.clone());
                        if (imgDataLoadCompleteListener != null)
                            imgDataLoadCompleteListener.onHolderDataLoadComplete(wrapperUri);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    CloseableReference.closeSafely(ref);
                }
            }
        }

        @Override
        protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
        }
    }, UiThreadImmediateExecutorService.getInstance());
}
Also used : ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) CloseableReference(com.facebook.common.references.CloseableReference) ImagePipeline(com.facebook.imagepipeline.core.ImagePipeline) Uri(android.net.Uri) WrapperUri(com.yioks.lzclib.Data.WrapperUri)

Example 39 with ResizeOptions

use of com.facebook.imagepipeline.common.ResizeOptions in project lzc_app_lib by httplzc.

the class FunUntil method loadImg.

/**
 * 加载图片
 * @param targetWidth
 * @param targetHeight
 * @param simpleDraweeView
 * @param path
 */
public static void loadImg(int targetWidth, int targetHeight, SimpleDraweeView simpleDraweeView, String path) {
    if (StringManagerUtil.CheckNull(path))
        return;
    Uri uri = null;
    try {
        uri = Uri.parse(path);
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(targetWidth, targetHeight)).setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH).build();
    AbstractDraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(simpleDraweeView.getController()).setImageRequest(request).build();
    simpleDraweeView.setController(controller);
}
Also used : ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) AbstractDraweeController(com.facebook.drawee.controller.AbstractDraweeController) Uri(android.net.Uri)

Example 40 with ResizeOptions

use of com.facebook.imagepipeline.common.ResizeOptions in project ride-read-android by Ride-Read.

the class FrescoImgLoader method displayImage.

@Override
public void displayImage(Activity activity, Context context, String path, final GalleryImageView imageView, int width, int height) {
    GenericDraweeHierarchy hierarchy = // 占位图
    new GenericDraweeHierarchyBuilder(context.getResources()).setFadeDuration(300).setPlaceholderImage(R.mipmap.gallery_pick_photo).setFailureImage(// 加载失败图
    R.mipmap.gallery_pick_photo).setProgressBarImage(// loading
    new ProgressBarDrawable()).build();
    final DraweeHolder<GenericDraweeHierarchy> draweeHolder = DraweeHolder.create(hierarchy, context);
    imageView.setOnImageViewListener(new GalleryImageView.OnImageViewListener() {

        @Override
        public void onDraw(Canvas canvas) {
            Drawable drawable = draweeHolder.getHierarchy().getTopLevelDrawable();
            if (drawable == null) {
                imageView.setImageResource(R.mipmap.gallery_pick_photo);
            } else {
                imageView.setImageDrawable(drawable);
            }
        }

        @Override
        public boolean verifyDrawable(Drawable dr) {
            return dr == draweeHolder.getHierarchy().getTopLevelDrawable();
        }

        @Override
        public void onDetach() {
            draweeHolder.onDetach();
        }

        @Override
        public void onAttach() {
            draweeHolder.onAttach();
        }
    });
    Uri uri = new Uri.Builder().scheme(UriUtil.LOCAL_FILE_SCHEME).path(path).build();
    ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(width, height)).build();
    DraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(draweeHolder.getController()).setImageRequest(imageRequest).build();
    draweeHolder.setController(controller);
}
Also used : GalleryImageView(com.yancy.gallerypick.widget.GalleryImageView) ProgressBarDrawable(com.facebook.drawee.drawable.ProgressBarDrawable) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) GenericDraweeHierarchyBuilder(com.facebook.drawee.generic.GenericDraweeHierarchyBuilder) DraweeController(com.facebook.drawee.interfaces.DraweeController) Canvas(android.graphics.Canvas) Drawable(android.graphics.drawable.Drawable) ProgressBarDrawable(com.facebook.drawee.drawable.ProgressBarDrawable) Uri(android.net.Uri) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest)

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