Search in sources :

Example 56 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest 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 57 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest 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 58 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest in project remusic by aa112901.

the class LockActivity method updateTrack.

public void updateTrack() {
    lrcRows = getLrcRows();
    String url = MusicPlayer.getAlbumPath();
    if (url == null) {
        mBack.setImageURI(Uri.parse("res:/" + R.drawable.login_bg_night));
    } else {
        try {
            ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url)).build();
            DraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(mBack.getController()).setImageRequest(request).setControllerListener(controllerListener).build();
            mBack.setController(controller);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : DraweeController(com.facebook.drawee.interfaces.DraweeController) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 59 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest in project boxing by Bilibili.

the class BoxingFrescoLoader method displayRaw.

@Override
public void displayRaw(@NonNull ImageView img, @NonNull String absPath, IBoxingCallback callback) {
    absPath = "file://" + absPath;
    ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(absPath));
    ImageRequest request = requestBuilder.build();
    loadImage(request, img, callback);
}
Also used : ImageRequest(com.facebook.imagepipeline.request.ImageRequest) ImageRequestBuilder(com.facebook.imagepipeline.request.ImageRequestBuilder)

Example 60 with ImageRequest

use of com.facebook.imagepipeline.request.ImageRequest 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)

Aggregations

ImageRequest (com.facebook.imagepipeline.request.ImageRequest)100 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)26 DraweeController (com.facebook.drawee.interfaces.DraweeController)25 CloseableReference (com.facebook.common.references.CloseableReference)24 Uri (android.net.Uri)18 ImagePipeline (com.facebook.imagepipeline.core.ImagePipeline)17 Test (org.junit.Test)14 Bitmap (android.graphics.Bitmap)13 CacheKey (com.facebook.cache.common.CacheKey)12 File (java.io.File)11 DataSource (com.facebook.datasource.DataSource)10 BaseBitmapDataSubscriber (com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber)9 CloseableImage (com.facebook.imagepipeline.image.CloseableImage)8 ImageRequestBuilder (com.facebook.imagepipeline.request.ImageRequestBuilder)8 Animatable (android.graphics.drawable.Animatable)7 PipelineDraweeController (com.facebook.drawee.backends.pipeline.PipelineDraweeController)7 BaseControllerListener (com.facebook.drawee.controller.BaseControllerListener)7 ImageOptions (com.facebook.fresco.vito.options.ImageOptions)7 ImageInfo (com.facebook.imagepipeline.image.ImageInfo)7 EncodedImage (com.facebook.imagepipeline.image.EncodedImage)6