Search in sources :

Example 1 with InstrumentedDraweeView

use of com.facebook.samples.scrollperf.instrumentation.InstrumentedDraweeView in project fresco by facebook.

the class DraweeViewAdapter method onCreateViewHolder.

@Override
public DraweeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    GenericDraweeHierarchy gdh = DraweeUtil.createDraweeHierarchy(mContext, mConfig);
    final InstrumentedDraweeView simpleDraweeView = new InstrumentedDraweeView(mContext, gdh, mConfig);
    simpleDraweeView.setPadding(mPaddingPx, mPaddingPx, mPaddingPx, mPaddingPx);
    return new DraweeViewHolder(parent, simpleDraweeView, mConfig, mPerfListener);
}
Also used : GenericDraweeHierarchy(com.facebook.drawee.generic.GenericDraweeHierarchy) InstrumentedDraweeView(com.facebook.samples.scrollperf.instrumentation.InstrumentedDraweeView)

Example 2 with InstrumentedDraweeView

use of com.facebook.samples.scrollperf.instrumentation.InstrumentedDraweeView 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

GenericDraweeHierarchy (com.facebook.drawee.generic.GenericDraweeHierarchy)2 InstrumentedDraweeView (com.facebook.samples.scrollperf.instrumentation.InstrumentedDraweeView)2 Context (android.content.Context)1 Uri (android.net.Uri)1 PipelineDraweeControllerBuilder (com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder)1 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)1 ImageRequestBuilder (com.facebook.imagepipeline.request.ImageRequestBuilder)1