Java Code Examples for com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder#setControllerListener()

The following examples show how to use com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder#setControllerListener() . 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: FrescoImageLoader.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public static void display(SimpleDraweeView view, String uri, int width, int height, ControllerListener listener) {
    if (uri != null) {
        PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
        controller.setOldController(view.getController());
        controller.setAutoPlayAnimations(true);
        ImageRequestBuilder imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri)).setCacheChoice(CacheChoice.SMALL).setLocalThumbnailPreviewsEnabled(true);
        imageRequest.setProgressiveRenderingEnabled(true);
        Log.d("Good", uri);
        if (width > 0 && height > 0) {
            imageRequest.setResizeOptions(new ResizeOptions(width, height));
        }
        controller.setImageRequest(imageRequest.build());
        controller.setControllerListener(listener);
        view.setController(controller.build());
    }
}
 
Example 2
Source File: ImageViewerAdapter.java    From photo-viewer with Apache License 2.0 6 votes vote down vote up
private void setController(String url, ReadableMap headers) {
			PipelineDraweeControllerBuilder controllerBuilder = Fresco.newDraweeControllerBuilder();
//			controllerBuilder.setUri(url);
			controllerBuilder.setOldController(drawee.getController());
			controllerBuilder.setControllerListener(getDraweeControllerListener(drawee));
			controllerBuilder.setAutoPlayAnimations(true);
			if (imageRequestBuilder != null) {
				imageRequestBuilder.setSource(Uri.parse(url));
				controllerBuilder.setImageRequest(imageRequestBuilder.build());
			}
//			support load local image just like React Native do

			ImageSource imageSource = new ImageSource(getContext(), url);
			ImageRequestBuilder imageRequestBuilder1 = ImageRequestBuilder.newBuilderWithSource(imageSource.getUri());
//			support headers
			ImageRequest imageRequest = ReactNetworkImageRequest.fromBuilderWithHeaders(imageRequestBuilder1, headers);

			controllerBuilder.setImageRequest(imageRequest);


			drawee.setController(controllerBuilder.build());
		}
 
Example 3
Source File: PhotoShowActivity.java    From Elephant with Apache License 2.0 6 votes vote down vote up
@Override
public void initLoad() {
    super.initLoad();

    if (!TextUtils.isEmpty(mImageUrl)) {
        PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
        controller.setUri(mImageUrl);
        controller.setOldController(mPhotoIv.getController());
        controller.setControllerListener(new BaseControllerListener<ImageInfo>() {
            @Override
            public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
                super.onFinalImageSet(id, imageInfo, animatable);
                if (imageInfo == null || mPhotoIv == null) {
                    return;
                }
                mPhotoIv.update(imageInfo.getWidth(), imageInfo.getHeight());
            }
        });
        mPhotoIv.setController(controller.build());
    }
}
 
Example 4
Source File: GalleryActivity.java    From phphub-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String imageUrl = getIntent().getStringExtra(IMAGE_URL);
    if (!TextUtils.isEmpty(imageUrl)) {
        PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder();
        builder.setUri(Uri.parse(imageUrl));
        builder.setOldController(photoView.getController());
        builder.setControllerListener(new BaseControllerListener<ImageInfo>() {
            @Override
            public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
                super.onFinalImageSet(id, imageInfo, animatable);
                if (imageInfo == null || photoView == null) {
                    return;
                }
                photoView.update(imageInfo.getWidth(), imageInfo.getHeight());
            }
        });
        photoView.setController(builder.build());
    }
}
 
Example 5
Source File: ViewPagerActivity.java    From PhotoDraweeView with Apache License 2.0 6 votes vote down vote up
@Override public Object instantiateItem(ViewGroup viewGroup, int position) {
    final PhotoDraweeView photoDraweeView = new PhotoDraweeView(viewGroup.getContext());
    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setUri(Uri.parse("res:///" + mDrawables[position]));
    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());

    try {
        viewGroup.addView(photoDraweeView, ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
    } catch (Exception e) {
        e.printStackTrace();
    }

    return photoDraweeView;
}
 
Example 6
Source File: FrescoUtils.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public static void displayPhoto(SimpleDraweeView mSimpleDraweeView, String path, int width, int height, ControllerListener mControllerListener) {
    if (!TextUtils.isEmpty(path)) {
        PipelineDraweeControllerBuilder mPipelineDraweeControllerBuilder = Fresco.newDraweeControllerBuilder();
        ImageRequestBuilder mImageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(path));
        mImageRequestBuilder.setResizeOptions(new ResizeOptions(width, height));
        mPipelineDraweeControllerBuilder.setOldController(mSimpleDraweeView.getController());
        mPipelineDraweeControllerBuilder.setImageRequest(mImageRequestBuilder.build());
        mPipelineDraweeControllerBuilder.setControllerListener(mControllerListener);
        mSimpleDraweeView.setController(mPipelineDraweeControllerBuilder.build());
    }
}
 
Example 7
Source File: FrescoImageLoader.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public static void display(SimpleDraweeView view, String lowUri, String uri, ControllerListener listener) {
    if (uri != null) {
        ImageRequestBuilder imageRequest;
        int w = view.getLayoutParams().width;
        int h = view.getLayoutParams().height;
        PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
        if (!lowUri.startsWith("file:///")) {
            lowUri = "file://" + lowUri;
        }
        if (lowUri != null && lowUri.length() > 0) {
            controller.setLowResImageRequest(ImageRequest.fromUri(lowUri));
        }
        controller.setOldController(view.getController());
        controller.setAutoPlayAnimations(true);
        if (uri.endsWith(".MP4")) {
            imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(lowUri));
        } else {
            imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri));
        }
        if (w > 0 && h > 0) {
            imageRequest.setResizeOptions(new ResizeOptions(w, h));
        }
        controller.setImageRequest(imageRequest.build());
        controller.setControllerListener(listener);
        view.setController(controller.build());
    }
}
 
Example 8
Source File: ImagePreFragment.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
private void initImage() {
    PipelineDraweeControllerBuilder controller = FrescoUtils.getPreController(url, pdvImage);
    controller.setControllerListener(listener);
    final GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources())
            .setProgressBarImage(new ImageLoadProgressBar(new ImageLoadProgressBar.OnLevelChangeListener() {
                @Override
                public void onChange(int level) {
                    if (level >= 100) {
                        hideLoadingDialog();
                    }
                }
            }, Color.parseColor("#90CCCCCC"))).build();
    hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
    pdvImage.setHierarchy(hierarchy);
    pdvImage.setController(controller.build());
    pdvImage.setOnPhotoTapListener(new OnPhotoTapListener() {
        @Override
        public void onPhotoTap(View view, float x, float y) {
            if (mActivity != null)
                mActivity.finish();
        }
    });
    pdvImage.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {

            return true;
        }
    });
}
 
Example 9
Source File: ImageFragment.java    From TLint with Apache License 2.0 5 votes vote down vote up
@Override
public void initData() {
    showContent(true);
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
            .setProgressiveRenderingEnabled(true)
            .build();

    GenericDraweeHierarchy hierarchy =
            new GenericDraweeHierarchyBuilder(getResources()).setProgressBarImage(
                    new ImageLoadProgressBar(new ImageLoadProgressBar.OnLevelChangeListener() {
                        @Override
                        public void onChange(int level) {
                            if (level > 100 && progress.getVisibility() == View.VISIBLE) {
                                progress.setVisibility(View.GONE);
                            }
                        }
                    }, ResourceUtil.getThemeColor(getActivity()))).build();
    hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);

    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setControllerListener(listener);
    controller.setImageRequest(request);
    controller.setOldController(image.getController());
    controller.setAutoPlayAnimations(true);
    image.setHierarchy(hierarchy);
    image.setController(controller.build());
}