com.facebook.drawee.backends.pipeline.PipelineDraweeController Java Examples

The following examples show how to use com.facebook.drawee.backends.pipeline.PipelineDraweeController. 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: SingleImageInterceptor.java    From Flora with MIT License 6 votes vote down vote up
private void load(Uri uri, SimpleDraweeView draweeView, int width, int height) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
            .setResizeOptions(new ResizeOptions(width, height))
            .setProgressiveRenderingEnabled(true)
            .setAutoRotateEnabled(true)
            .build();

    PipelineDraweeController controller =
            (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                    .setImageRequest(request)
                    .setOldController(draweeView.getController())
                    .setAutoPlayAnimations(true)
                    .build();

    draweeView.setController(controller);
}
 
Example #2
Source File: ImageAdapter.java    From TLint with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    Image image = images.get(position);
    holder.image = image;
    if (image == null) {
        return;
    }
    holder.ivCheck.setVisibility(View.VISIBLE);
    holder.ivCheck.setImageResource(selectedImages.contains(image) ? R.drawable.ap_gallery_checked
            : R.drawable.ap_gallery_normal);
    int width = 100, height = 100;
    ImageRequest request =
            ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(new File(image.path)))
                    .setResizeOptions(new ResizeOptions(width, height))
                    .build();
    PipelineDraweeController controller =
            (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                    .setOldController(holder.ivPhoto.getController())
                    .setImageRequest(request)
                    .build();
    holder.ivPhoto.setController(controller);
}
 
Example #3
Source File: AvatarView.java    From actor-platform with GNU Affero General Public License v3.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: CallBackgroundAvatarView.java    From actor-platform with GNU Affero General Public License v3.0 6 votes vote down vote up
public void bindRaw(String fileName) {
    if (bindedFile != null) {
        bindedFile.detach();
        bindedFile = null;
    }
    currentId = 0;

    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(new File(fileName)))
            .setAutoRotateEnabled(true)
            .build();
    PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
            .setOldController(getController())
            .setImageRequest(request)
            .build();
    setController(controller);
}
 
Example #5
Source File: FeedAdapter.java    From Flora with MIT License 5 votes vote down vote up
private void load(Uri uri, SimpleDraweeView draweeView, int width, int height) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
            .setResizeOptions(new ResizeOptions(width, height))
            .setProgressiveRenderingEnabled(true)
            .setAutoRotateEnabled(true)
            .build();

    PipelineDraweeController controller =
            (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                    .setImageRequest(request)
                    .setOldController(draweeView.getController())
                    .setAutoPlayAnimations(true)
                    .build();
    draweeView.setController(controller);
}
 
Example #6
Source File: ImagePerfMonitorTest.java    From fresco with MIT License 5 votes vote down vote up
@Before
public void setUp() {
  mMonotonicClock = mock(MonotonicClock.class);
  mController = mock(PipelineDraweeController.class);
  when(mController.getId()).thenReturn(CONTROLLER_ID);

  mImagePerfMonitor = new ImagePerfMonitor(mMonotonicClock, mController, Suppliers.BOOLEAN_FALSE);
}
 
Example #7
Source File: ImagePerfMonitor.java    From fresco with MIT License 5 votes vote down vote up
public ImagePerfMonitor(
    MonotonicClock monotonicClock,
    PipelineDraweeController pipelineDraweeController,
    Supplier<Boolean> asyncLogging) {
  mMonotonicClock = monotonicClock;
  mPipelineDraweeController = pipelineDraweeController;
  mImagePerfState = new ImagePerfState();
  mAsyncLogging = asyncLogging;
}
 
Example #8
Source File: FastAttachAdapter.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
public void bind(String path) {
    data = path;
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(new File(path)))
            .setResizeOptions(new ResizeOptions(v.getLayoutParams().width,
                    v.getLayoutParams().height))
            .build();
    PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
            .setOldController(v.getController())
            .setImageRequest(request)
            .build();
    v.setController(controller);
    chb.setChecked(selected.contains(data));
}
 
Example #9
Source File: LocationHolder.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void onPostExecute(File result) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(result))
            .setResizeOptions(new ResizeOptions(previewView.getLayoutParams().width,
                    previewView.getLayoutParams().height))
            .build();
    PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
            .setOldController(previewView.getController())
            .setImageRequest(request)
            .build();
    previewView.setController(controller);
}
 
Example #10
Source File: PhotoHolder.java    From actor-platform with GNU Affero General Public License v3.0 5 votes vote down vote up
public void bindImage(Uri uri) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
            .setResizeOptions(new ResizeOptions(previewView.getLayoutParams().width,
                    previewView.getLayoutParams().height))
            .build();
    PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
            .setOldController(previewView.getController())
            .setImageRequest(request)
            .setControllerListener(animationController)
            .build();
    previewView.setController(controller);
}
 
Example #11
Source File: DownsamplingHolder.java    From mirror with GNU General Public License v3.0 5 votes vote down vote up
public void bind(Artboard artboard) {
    mArtboard = artboard;

    String url = MirrorUtils.buildArtboardHttpUrl(mDownsamplingView.getContext(), mArtboard);
    int mResizeWidth = mDownsamplingView.getDownsamplingViewWidth();
    int mResizeHeight = mDownsamplingView.getDownsamplingViewHeight();
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
            .setResizeOptions(new ResizeOptions(mResizeWidth, mResizeHeight))
            .build();
    PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
            .setOldController(mDownsamplingView.getController())
            .setImageRequest(request)
            .build();
    mDownsamplingView.setController(controller);
}
 
Example #12
Source File: MineFragment.java    From fingerpoetry-android with Apache License 2.0 5 votes vote down vote up
private void   updateData() {
    user = AccountLogic.getInstance().getNowUser();
    if(user == null){
        return;
    }
    tvName.setText(user.getName());
    String url = ActivityUtil.genPic(user.getId().hashCode());
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
            .setPostprocessor(postprocessor)
            .build();

    PipelineDraweeController controller =
            (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                    .setImageRequest(request)
                    .setOldController(ivBg.getController())
                    .build();
    ivBg.setController(controller);
    String avartar = "https://second.imdao.cn"+user.getAvatar();
    Timber.i("avatar:"+avartar);
    ivAvatar.setImageURI(Uri.parse(avartar));
    StringBuilder desc = new StringBuilder();
    desc.append(getString(R.string.readed)).append(" ")
            .append(user.getReadCount())
            .append("  ").append(getString(R.string.collected))
            .append(" ").append(user.getCollectCount())
            .append("  ").append(getString(R.string.share))
            .append(" ").append(user.getShareCount());
    tvSig.setText(desc);
    registerAt.setText("加入时间:"+DateUtil.getFriendlyTimeSpanByNow(user.getCreateAt()));
}
 
Example #13
Source File: JokeViewHolder.java    From fingerpoetry-android with Apache License 2.0 5 votes vote down vote up
public static void setSupportGif(SimpleDraweeView draweeView, String url) {
    LogUtils.i("JokeViewHolder", "setSupportGif:" + url);
    PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
            .setUri(url)
            .setOldController(draweeView.getController())
            .setAutoPlayAnimations(true) //自动播放gif动画
            .build();
    draweeView.setController(controller);
}
 
Example #14
Source File: MySimpleDraweeView.java    From Elephant with Apache License 2.0 5 votes vote down vote up
@Override
    public void setImageURI(Uri uri) {

        ImageRequest request = ImageRequestBuilder
                .newBuilderWithSource(uri)
                .setLocalThumbnailPreviewsEnabled(true)
                .setProgressiveRenderingEnabled(false)
                .setResizeOptions(new ResizeOptions(50, 50))
                .build();
/*
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setUri(uri)
                .setTapToRetryEnabled(true)
                .setImageRequest(request)
                .setOldController(getController())
                .build();*/

        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setUri(uri)
                .setTapToRetryEnabled(true)
                .setImageRequest(request)
                .setOldController(getController())
                .build();

        setController(controller);

        super.setImageURI(uri);
    }
 
Example #15
Source File: FrescoUtils.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
/**
 * 渐进式加载
 *
 * @param url
 * @param draweeView
 * @return
 */
public static PipelineDraweeController getController(String url, SimpleDraweeView draweeView) {
    ImageRequest request = ImageRequestBuilder
            .newBuilderWithSource(Uri.parse(url))
            .setProgressiveRenderingEnabled(true)
            .build();
    PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
            .setImageRequest(request)
            .setOldController(draweeView.getController())
            .build();
    return controller;
}
 
Example #16
Source File: FrescoUtil.java    From MyImageUtil with Apache License 2.0 5 votes vote down vote up
public static void setSupportGif(SimpleDraweeView draweeView, String url){
    PipelineDraweeController controller =
            (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                    .setUri(url)
                    .setOldController(draweeView.getController())
                    .setAutoPlayAnimations(true) //自动播放gif动画
                    .build();
    draweeView.setController(controller);
}
 
Example #17
Source File: MultiImageInterceptor.java    From Flora with MIT License 5 votes vote down vote up
private void load(Uri uri, SimpleDraweeView draweeView, int width, int height) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri)
            .setResizeOptions(new ResizeOptions(width, height))
            .setProgressiveRenderingEnabled(true)
            .setAutoRotateEnabled(true)
            .build();

    PipelineDraweeController controller =
            (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                    .setImageRequest(request)
                    .setOldController(draweeView.getController())
                    .setAutoPlayAnimations(true)
                    .build();
    draweeView.setController(controller);
}
 
Example #18
Source File: UETFresco.java    From UETool with MIT License 5 votes vote down vote up
private PipelineDraweeControllerBuilder getFrescoControllerBuilder(DraweeView draweeView) {
    try {
        PipelineDraweeController controller = (PipelineDraweeController) draweeView.getController();
        Field mDataSourceSupplierFiled = PipelineDraweeController.class.getDeclaredField("mDataSourceSupplier");
        mDataSourceSupplierFiled.setAccessible(true);
        Supplier supplier = (Supplier) mDataSourceSupplierFiled.get(controller);
        Field mAutoField = Class.forName("com.facebook.drawee.controller.AbstractDraweeControllerBuilder$2").getDeclaredField("this$0");
        mAutoField.setAccessible(true);
        PipelineDraweeControllerBuilder builder = (PipelineDraweeControllerBuilder) mAutoField.get(supplier);
        return builder;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
Example #19
Source File: StickerView.java    From actor-platform with GNU Affero General Public License v3.0 4 votes vote down vote up
public void bind(FileReference fileReference, int size) {

        if (this.fileReference != null && this.fileReference.equals(fileReference)) {
            return;
        }

        if (bindedFile != null) {
            bindedFile.detach();
            bindedFile = null;
        }

        setImageURI(null);

        this.fileReference = fileReference;

        bindedFile = messenger().bindFile(fileReference, true, new FileVMCallback() {

            private boolean isFastThumbLoaded = false;

            private void checkFastThumb() {
                if (!isFastThumbLoaded) {
                    isFastThumbLoaded = true;
//                    if (sticker.getThumb() != null) {
//                        fastThumbLoader.request(sticker.getThumb());
//                    }
                }
            }

            @Override
            public void onNotDownloaded() {
                checkFastThumb();
            }

            @Override
            public void onDownloading(float progress) {
                checkFastThumb();
            }

            @Override
            public void onDownloaded(FileSystemReference reference) {
                imageFile = new File(reference.getDescriptor());
                ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(imageFile))
                        .setAutoRotateEnabled(true)
                        .build();
                PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                        .setOldController(getController())
                        .setImageRequest(request)
                        .build();
                setController(controller);
                loaded = true;


            }
        });
    }
 
Example #20
Source File: CallBackgroundAvatarView.java    From actor-platform with GNU Affero General Public License v3.0 4 votes vote down vote up
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);
                        }
                    });

                }
            }));
        }
    });
}
 
Example #21
Source File: AvatarView.java    From actor-platform with GNU Affero General Public License v3.0 4 votes vote down vote up
public void bind(Avatar avatar, String title, int id) {
    // Same avatar
    if (avatar != null && getImage(avatar) != null
            && getImage(avatar).getFileReference().getFileId() == currentId) {
        return;
    }

    getHierarchy().setPlaceholderImage(new AvatarPlaceholderDrawable(title, id, placeholderTextSize, getContext()));

    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) {


            ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(new File(reference.getDescriptor())))
                    .setResizeOptions(new ResizeOptions(size, size))
                    .build();
            PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                    .setOldController(getController())
                    .setImageRequest(request)
                    .build();
            setController(controller);
        }
    });
}