Search in sources :

Example 6 with PipelineDraweeControllerBuilder

use of com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder in project actor-platform by actorapp.

the class CoverAvatarView method bind.

public void bind(final Avatar avatar) {
    // Same avatar
    if (avatar != null && avatar.getSmallImage() != null && avatar.getSmallImage().getFileReference().getFileId() == currentId) {
        return;
    }
    if (fileVM != null) {
        fileVM.detach();
        fileVM = null;
    }
    if (fullFileVM != null) {
        fullFileVM.detach();
        fullFileVM = null;
    }
    isLoaded = false;
    smallDescriptor = null;
    if (tryToSetFast(avatar)) {
        return;
    }
    if (avatar != null && avatar.getSmallImage() != null) {
        currentId = avatar.getSmallImage().getFileReference().getFileId();
        fileVM = messenger().bindFile(avatar.getSmallImage().getFileReference(), true, new FileVMCallback() {

            @Override
            public void onNotDownloaded() {
            }

            @Override
            public void onDownloading(float progress) {
            }

            @Override
            public void onDownloaded(FileSystemReference reference) {
                if (!isLoaded) {
                    smallDescriptor = reference.getDescriptor();
                    setImageURI(Uri.fromFile(new File(smallDescriptor)));
                }
            }
        });
        if (avatar.getFullImage() != null) {
            fullFileVM = messenger().bindFile(avatar.getFullImage().getFileReference(), true, new FileVMCallback() {

                @Override
                public void onNotDownloaded() {
                }

                @Override
                public void onDownloading(float progress) {
                }

                @Override
                public void onDownloaded(FileSystemReference reference) {
                    isLoaded = true;
                    PipelineDraweeControllerBuilder dController = Fresco.newDraweeControllerBuilder();
                    if (smallDescriptor != null) {
                        dController.setLowResImageRequest(ImageRequest.fromUri(Uri.fromFile(new File(smallDescriptor))));
                    }
                    dController.setOldController(getController());
                    dController.setImageRequest(ImageRequest.fromUri(Uri.fromFile(new File(reference.getDescriptor()))));
                    setController(dController.build());
                }
            });
        }
    }
}
Also used : FileSystemReference(im.actor.runtime.files.FileSystemReference) File(java.io.File) FileVMCallback(im.actor.core.viewmodel.FileVMCallback) PipelineDraweeControllerBuilder(com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder)

Example 7 with PipelineDraweeControllerBuilder

use of com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder in project fresco by facebook.

the class DraweeViewHolder method bind.

/**
 * @param uri The Uri to show into the DraweeView for this Holder
 */
public void bind(Uri uri) {
    mDraweeView.initInstrumentation(uri.toString(), mPerfListener);
    ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(mDraweeView.getLayoutParams().width, mDraweeView.getLayoutParams().height));
    PipelineUtil.addOptionalFeatures(imageRequestBuilder, mConfig);
    // Create the Builder
    PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder().setImageRequest(imageRequestBuilder.build());
    if (mConfig.reuseOldController) {
        builder.setOldController(mDraweeView.getController());
    }
    mDraweeView.setListener(builder);
    mDraweeView.setController(builder.build());
}
Also used : ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) ImageRequestBuilder(com.facebook.imagepipeline.request.ImageRequestBuilder) PipelineDraweeControllerBuilder(com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder)

Example 8 with PipelineDraweeControllerBuilder

use of com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder in project fresco by facebook.

the class DraweeViewListAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    InstrumentedDraweeView draweeView;
    if (convertView == null) {
        final Context context = parent.getContext();
        GenericDraweeHierarchy gdh = DraweeUtil.createDraweeHierarchy(context, mConfig);
        draweeView = new InstrumentedDraweeView(context, gdh, mConfig);
        SizeUtil.setConfiguredSize(parent, draweeView, mConfig);
        draweeView.setPadding(mPaddingPx, mPaddingPx, mPaddingPx, mPaddingPx);
    } else {
        draweeView = (InstrumentedDraweeView) convertView;
    }
    final Uri uri = getItem(position);
    draweeView.initInstrumentation(uri.toString(), mPerfListener);
    ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(draweeView.getLayoutParams().width, draweeView.getLayoutParams().height));
    PipelineUtil.addOptionalFeatures(imageRequestBuilder, mConfig);
    // Create the Builder
    PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder().setImageRequest(imageRequestBuilder.build());
    if (mConfig.reuseOldController) {
        builder.setOldController(draweeView.getController());
    }
    if (mConfig.instrumentationEnabled) {
        draweeView.setListener(builder);
    }
    draweeView.setController(builder.build());
    return draweeView;
}
Also used : Context(android.content.Context) GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) InstrumentedDraweeView(com.facebook.samples.scrollperf.instrumentation.InstrumentedDraweeView) Uri(android.net.Uri) ImageRequestBuilder(com.facebook.imagepipeline.request.ImageRequestBuilder) PipelineDraweeControllerBuilder(com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder)

Aggregations

PipelineDraweeControllerBuilder (com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder)8 Animatable (android.graphics.drawable.Animatable)2 View (android.view.View)2 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)2 ImageInfo (com.facebook.imagepipeline.image.ImageInfo)2 ImageRequestBuilder (com.facebook.imagepipeline.request.ImageRequestBuilder)2 Context (android.content.Context)1 Uri (android.net.Uri)1 AdapterView (android.widget.AdapterView)1 TextView (android.widget.TextView)1 GenericDraweeHierarchy (com.facebook.drawee.generic.GenericDraweeHierarchy)1 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)1 ImageDecodeOptionsBuilder (com.facebook.imagepipeline.common.ImageDecodeOptionsBuilder)1 InstrumentedDraweeView (com.facebook.samples.scrollperf.instrumentation.InstrumentedDraweeView)1 FileVMCallback (im.actor.core.viewmodel.FileVMCallback)1 FileSystemReference (im.actor.runtime.files.FileSystemReference)1 File (java.io.File)1 OnViewTapListener (me.relex.photodraweeview.OnViewTapListener)1 PhotoDraweeView (me.relex.photodraweeview.PhotoDraweeView)1