Search in sources :

Example 11 with ImageRequestBuilder

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

the class BoxingFrescoLoader method displayThumbnail.

@Override
public void displayThumbnail(@NonNull final ImageView img, @NonNull final String absPath, int width, int height) {
    String finalAbsPath = "file://" + absPath;
    ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(finalAbsPath));
    requestBuilder.setResizeOptions(new ResizeOptions(width, height));
    ImageRequest request = requestBuilder.build();
    final DataSource<CloseableReference<CloseableImage>> dataSource = Fresco.getImagePipeline().fetchDecodedImage(request, null);
    dataSource.subscribe(new BaseDataSubscriber<CloseableReference<CloseableImage>>() {

        @Override
        protected void onNewResultImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
            String path = (String) img.getTag(R.string.boxing_app_name);
            if (path == null || absPath.equals(path)) {
                if (dataSource.getResult() == null) {
                    onFailureImpl(dataSource);
                    return;
                }
                Drawable drawable = createDrawableFromFetchedResult(img.getContext(), dataSource.getResult().get());
                img.setImageDrawable(drawable);
            }
        }

        @Override
        protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
            img.setImageResource(R.drawable.ic_boxing_broken_image);
        }
    }, UiThreadImmediateExecutorService.getInstance());
}
Also used : ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) CloseableReference(com.facebook.common.references.CloseableReference) Drawable(android.graphics.drawable.Drawable) AnimatedDrawable(com.facebook.imagepipeline.animated.base.AnimatedDrawable) OrientedDrawable(com.facebook.drawee.drawable.OrientedDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageRequestBuilder(com.facebook.imagepipeline.request.ImageRequestBuilder)

Example 12 with ImageRequestBuilder

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

the class BoxingFrescoLoader method displayRaw.

@Override
public void displayRaw(@NonNull ImageView img, @NonNull String absPath, int width, int height, IBoxingCallback callback) {
    absPath = "file://" + absPath;
    ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(absPath));
    if (width > 0 && height > 0) {
        requestBuilder.setResizeOptions(new ResizeOptions(width, height));
    }
    ImageRequest request = requestBuilder.build();
    loadImage(request, img, callback);
}
Also used : ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequest(com.facebook.imagepipeline.request.ImageRequest) ImageRequestBuilder(com.facebook.imagepipeline.request.ImageRequestBuilder)

Aggregations

ImageRequestBuilder (com.facebook.imagepipeline.request.ImageRequestBuilder)12 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)6 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)5 Uri (android.net.Uri)4 CloseableReference (com.facebook.common.references.CloseableReference)3 PipelineDraweeControllerBuilder (com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder)3 Nullable (javax.annotation.Nullable)3 DataSource (com.facebook.datasource.DataSource)2 ImagePipeline (com.facebook.imagepipeline.core.ImagePipeline)2 Context (android.content.Context)1 Bitmap (android.graphics.Bitmap)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Drawable (android.graphics.drawable.Drawable)1 DiskCacheConfig (com.facebook.cache.disk.DiskCacheConfig)1 PooledByteBuffer (com.facebook.common.memory.PooledByteBuffer)1 PooledByteBufferInputStream (com.facebook.common.memory.PooledByteBufferInputStream)1 OrientedDrawable (com.facebook.drawee.drawable.OrientedDrawable)1 GenericDraweeHierarchy (com.facebook.drawee.generic.GenericDraweeHierarchy)1 DraweeController (com.facebook.drawee.interfaces.DraweeController)1 AnimatedDrawable (com.facebook.imagepipeline.animated.base.AnimatedDrawable)1