Search in sources :

Example 46 with DraweeController

use of com.facebook.drawee.interfaces.DraweeController in project fresco by facebook.

the class PipelineDraweeControllerBuilder method obtainController.

@Override
protected PipelineDraweeController obtainController() {
    if (FrescoSystrace.isTracing()) {
        FrescoSystrace.beginSection("PipelineDraweeControllerBuilder#obtainController");
    }
    try {
        DraweeController oldController = getOldController();
        PipelineDraweeController controller;
        final String controllerId = generateUniqueControllerId();
        if (oldController instanceof PipelineDraweeController) {
            controller = (PipelineDraweeController) oldController;
        } else {
            controller = mPipelineDraweeControllerFactory.newController();
        }
        controller.initialize(obtainDataSourceSupplier(controller, controllerId), controllerId, getCacheKey(), getCallerContext(), mCustomDrawableFactories, mImageOriginListener);
        controller.initializePerformanceMonitoring(mImagePerfDataListener, this, Suppliers.BOOLEAN_FALSE);
        return controller;
    } finally {
        if (FrescoSystrace.isTracing()) {
            FrescoSystrace.endSection();
        }
    }
}
Also used : DraweeController(com.facebook.drawee.interfaces.DraweeController)

Example 47 with DraweeController

use of com.facebook.drawee.interfaces.DraweeController in project fresco by facebook.

the class DraweeSpanStringBuilder method setImageSpan.

public void setImageSpan(DraweeHolder draweeHolder, int startIndex, int endIndex, final int drawableWidthPx, final int drawableHeightPx, boolean enableResizing, @BetterImageSpan.BetterImageSpanAlignment int verticalAlignment) {
    if (endIndex >= length()) {
        // Example: Text = "ABC", insert image at position 18.
        return;
    }
    Drawable topLevelDrawable = draweeHolder.getTopLevelDrawable();
    if (topLevelDrawable != null) {
        if (topLevelDrawable.getBounds().isEmpty()) {
            topLevelDrawable.setBounds(0, 0, drawableWidthPx, drawableHeightPx);
        }
        topLevelDrawable.setCallback(mDrawableCallback);
    }
    DraweeSpan draweeSpan = new DraweeSpan(draweeHolder, verticalAlignment);
    final DraweeController controller = draweeHolder.getController();
    if (controller instanceof AbstractDraweeController) {
        ((AbstractDraweeController) controller).addControllerListener(new DrawableChangedListener(draweeSpan, enableResizing, drawableHeightPx));
    }
    mDraweeSpans.add(draweeSpan);
    setSpan(draweeSpan, startIndex, endIndex + 1, SPAN_EXCLUSIVE_EXCLUSIVE);
}
Also used : DraweeController(com.facebook.drawee.interfaces.DraweeController) AbstractDraweeController(com.facebook.drawee.controller.AbstractDraweeController) Drawable(android.graphics.drawable.Drawable) AbstractDraweeController(com.facebook.drawee.controller.AbstractDraweeController)

Example 48 with DraweeController

use of com.facebook.drawee.interfaces.DraweeController in project fresco by facebook.

the class MyPagerAdapter method instantiateItem.

@Override
public Object instantiateItem(ViewGroup container, int position) {
    FrameLayout page = (FrameLayout) container.getChildAt(position);
    if (page == null) {
        return null;
    }
    ZoomableDraweeView zoomableDraweeView = (ZoomableDraweeView) page.findViewById(R.id.zoomableView);
    zoomableDraweeView.setAllowTouchInterceptionWhileZoomed(mAllowSwipingWhileZoomed);
    // needed for double tap to zoom
    zoomableDraweeView.setIsLongpressEnabled(false);
    zoomableDraweeView.setTapListener(new DoubleTapGestureListener(zoomableDraweeView));
    DraweeController controller = Fresco.newDraweeControllerBuilder().setUri(SAMPLE_URIS[position % SAMPLE_URIS.length]).setCallerContext("ZoomableApp-MyPagerAdapter").build();
    zoomableDraweeView.setController(controller);
    page.requestLayout();
    return page;
}
Also used : DoubleTapGestureListener(com.facebook.samples.zoomable.DoubleTapGestureListener) DraweeController(com.facebook.drawee.interfaces.DraweeController) FrameLayout(android.widget.FrameLayout) ZoomableDraweeView(com.facebook.samples.zoomable.ZoomableDraweeView)

Example 49 with DraweeController

use of com.facebook.drawee.interfaces.DraweeController in project teaTime by ancfdy.

the class FrescoUtils method moreImgRequst.

/**
 * 多图请求需 自定义ImageRequest(图片预览)
 * @param draweeView
 * @param lowResUri
 * @param highResUri
 */
public static void moreImgRequst(SimpleDraweeView draweeView, String lowResUri, String highResUri) {
    DraweeController controller = Fresco.newDraweeControllerBuilder().setLowResImageRequest(// 低分辨率的缩略图
    ImageRequest.fromUri(Uri.parse(lowResUri))).setImageRequest(// 高分辨率的图
    ImageRequest.fromUri(Uri.parse(highResUri))).setOldController(draweeView.getController()).build();
    draweeView.setController(controller);
}
Also used : DraweeController(com.facebook.drawee.interfaces.DraweeController)

Example 50 with DraweeController

use of com.facebook.drawee.interfaces.DraweeController in project teaTime by ancfdy.

the class FrescoUtils method loadGif.

/**
 * 加载gif图
 * @param draweeView
 * @param uriString
 */
public static void loadGif(SimpleDraweeView draweeView, String uriString) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uriString)).build();
    DraweeController controller = Fresco.newDraweeControllerBuilder().setImageRequest(request).setAutoPlayAnimations(true).build();
    draweeView.setController(controller);
}
Also used : DraweeController(com.facebook.drawee.interfaces.DraweeController) ImageRequest(com.facebook.imagepipeline.request.ImageRequest)

Aggregations

DraweeController (com.facebook.drawee.interfaces.DraweeController)56 ImageRequest (com.facebook.imagepipeline.request.ImageRequest)25 ResizeOptions (com.facebook.imagepipeline.common.ResizeOptions)10 Uri (android.net.Uri)8 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)8 Animatable (android.graphics.drawable.Animatable)7 BaseControllerListener (com.facebook.drawee.controller.BaseControllerListener)6 GenericDraweeHierarchy (com.facebook.drawee.generic.GenericDraweeHierarchy)6 ImageInfo (com.facebook.imagepipeline.image.ImageInfo)5 ControllerListener (com.facebook.drawee.controller.ControllerListener)4 QualityInfo (com.facebook.imagepipeline.image.QualityInfo)4 Drawable (android.graphics.drawable.Drawable)3 Nullable (android.support.annotation.Nullable)3 ProgressBarDrawable (com.facebook.drawee.drawable.ProgressBarDrawable)3 Canvas (android.graphics.Canvas)2 ColorDrawable (android.graphics.drawable.ColorDrawable)2 View (android.view.View)2 ViewGroup (android.view.ViewGroup)2 AbstractDraweeController (com.facebook.drawee.controller.AbstractDraweeController)2 GenericDraweeHierarchyBuilder (com.facebook.drawee.generic.GenericDraweeHierarchyBuilder)2