Java Code Examples for com.facebook.drawee.view.DraweeView#setController()

The following examples show how to use com.facebook.drawee.view.DraweeView#setController() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FrescoUtils.java    From droidddle with Apache License 2.0 6 votes vote down vote up
public static final void setShotUrl(DraweeView view, String url, String thumbnail/*, BaseControllerListener listener*/) {
        ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
//                .setResizeOptions(
//                        new ResizeOptions(300, 400))
                .setProgressiveRenderingEnabled(true)
                .build();
        ImageRequest lowRequest = null;
        if (!TextUtils.isEmpty(thumbnail)) {
            lowRequest = ImageRequest.fromUri(thumbnail);
        }
        DraweeController draweeController = Fresco.newDraweeControllerBuilder()
                .setImageRequest(imageRequest)
                .setLowResImageRequest(lowRequest)
                .setOldController(view.getController())
                .setAutoPlayAnimations(true)
//                .setControllerListener(listener)
                .build();
        view.setController(draweeController);
    }
 
Example 2
Source File: FrescoUtils.java    From materialup with Apache License 2.0 5 votes vote down vote up
public static final void setShotImage(DraweeView view, Uri uri) {
        ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(uri)
                .setProgressiveRenderingEnabled(true)
//                        .setResizeOptions(new ResizeOptions(1024,1024))
                .build();
        DraweeController draweeController = Fresco.newDraweeControllerBuilder()
                .setImageRequest(imageRequest)
                .setOldController(view.getController())
                .setAutoPlayAnimations(true)
                .build();
        view.setController(draweeController);
    }
 
Example 3
Source File: FrescoUtils.java    From droidddle with Apache License 2.0 5 votes vote down vote up
public static final void setShotImage(DraweeView view, Uri uri) {
        ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(uri)
                .setProgressiveRenderingEnabled(true)
//                        .setResizeOptions(new ResizeOptions(1024,1024))
                .build();
        DraweeController draweeController = Fresco.newDraweeControllerBuilder()
                .setImageRequest(imageRequest)
                .setOldController(view.getController())
                .setAutoPlayAnimations(true)
                .build();
        view.setController(draweeController);
    }
 
Example 4
Source File: FrescoUtils.java    From materialup with Apache License 2.0 4 votes vote down vote up
public static final void setShotUrl(DraweeView view, String url, String thumbnail, BaseDataSubscriber subscriber, boolean full) {
        if (TextUtils.isEmpty(thumbnail) && TextUtils.isEmpty(url)) {
            return;
        }
        ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
//                .setResizeOptions(
//                        new ResizeOptions(300, 400))
                .setProgressiveRenderingEnabled(true)
                .build();
        ImageRequest lowRequest = null;
        if (!TextUtils.isEmpty(thumbnail)) {
            lowRequest = ImageRequest.fromUri(thumbnail);
        }

        if (subscriber != null) {
            if (lowRequest != null && !full) {
                setSubscribe(view.getContext(), lowRequest, subscriber);
            } else if (imageRequest != null) {
                setSubscribe(view.getContext(), imageRequest, subscriber);
            }
        }

        DraweeController draweeController = Fresco.newDraweeControllerBuilder()
                .setImageRequest(imageRequest)
                .setLowResImageRequest(lowRequest)
                .setOldController(view.getController())
                .setAutoPlayAnimations(true)
//                .setControllerListener(listener)
                .build();

//        ImagePipeline imagePipeline = Fresco.getImagePipeline();
//        ImageRequest request = lowRequest == null ? imageRequest : lowRequest;
//        DataSource<CloseableReference<CloseableImage>> dataSource =
//                imagePipeline.fetchDecodedImage(request, view.getContext());
//        dataSource.subscribe(new BaseBitmapDataSubscriber() {
//            @Override
//            protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
//
//            }
//
//            @Override protected void onNewResultImpl(@Nullable Bitmap bitmap) {
//                Palette.from(bitmap).maximumColorCount(3).generate(new Palette.PaletteAsyncListener() {
//                    @Override public void onGenerated(Palette palette) {
//                    }
//                });
//            }
//        }, CallerThreadExecutor.getInstance());

        view.setController(draweeController);
    }