com.facebook.drawee.view.DraweeView Java Examples

The following examples show how to use com.facebook.drawee.view.DraweeView. 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: Attacher.java    From CanPhotos with Apache License 2.0 6 votes vote down vote up
public Attacher(DraweeView<GenericDraweeHierarchy> draweeView) {
    mDraweeView = new WeakReference<>(draweeView);
    draweeView.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
    draweeView.setOnTouchListener(this);
    mScaleDragDetector = new ScaleDragDetector(draweeView.getContext(), this);
    mGestureDetector = new GestureDetectorCompat(draweeView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {
                @Override public void onLongPress(MotionEvent e) {
                    super.onLongPress(e);
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getDraweeView());
                    }
                }
            });
    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
}
 
Example #2
Source File: UETFresco.java    From UETool with MIT License 6 votes vote down vote up
@Override
public List<Item> getAttrs(Element element) {
    List<Item> items = new ArrayList<>();

    View view = element.getView();

    if (view instanceof DraweeView) {
        items.add(new TitleItem("DraweeView"));
        items.add(new TextItem("CornerRadius", getCornerRadius((DraweeView) view)));
        items.add(new TextItem("ImageURI", getImageURI((DraweeView) view), true));
        items.add(new TextItem("ActualScaleType", getScaleType((DraweeView) view), true));
        items.add(new TextItem("IsSupportAnimation", isSupportAnimation((DraweeView) view)));
        items.add(new BitmapItem("PlaceHolderImage", getPlaceHolderBitmap((DraweeView) view)));
        items.add(new TextItem("FadeDuration", getFadeDuration((DraweeView) view)));
    }
    return items;
}
 
Example #3
Source File: Attacher.java    From PicKing with Apache License 2.0 6 votes vote down vote up
public Attacher(DraweeView<GenericDraweeHierarchy> draweeView) {
    mDraweeView = new WeakReference<>(draweeView);
    draweeView.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
    draweeView.setOnTouchListener(this);
    mScaleDragDetector = new ScaleDragDetector(draweeView.getContext(), this);
    mGestureDetector = new GestureDetectorCompat(draweeView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {
                @Override public void onLongPress(MotionEvent e) {
                    super.onLongPress(e);
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getDraweeView());
                    }
                }
            });
    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
}
 
Example #4
Source File: NonInterceptableAttacher.java    From photo-viewer with Apache License 2.0 6 votes vote down vote up
@Override
public void onDrag(float dx, float dy) {
    DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();
    if (draweeView != null) {
        getDrawMatrix().postTranslate(dx, dy);
        checkMatrixAndInvalidate();

        ViewParent parent = draweeView.getParent();
        if (parent == null) {
            return;
        }

        if (getScale() == 1.0f) {
            parent.requestDisallowInterceptTouchEvent(false);
        } else {
            parent.requestDisallowInterceptTouchEvent(true);
        }
    }
}
 
Example #5
Source File: Attacher.java    From TLint with Apache License 2.0 6 votes vote down vote up
public Attacher(DraweeView<GenericDraweeHierarchy> draweeView) {
    mDraweeView = new WeakReference<>(draweeView);
    draweeView.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
    draweeView.setOnTouchListener(this);
    mScaleDragDetector = new ScaleDragDetector(draweeView.getContext(), this);
    mGestureDetector = new GestureDetectorCompat(draweeView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {
                @Override
                public void onLongPress(MotionEvent e) {
                    super.onLongPress(e);
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getDraweeView());
                    }
                }
            });
    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
}
 
Example #6
Source File: UETFresco.java    From UETool with MIT License 6 votes vote down vote up
private Bitmap getPlaceHolderBitmap(DraweeView draweeView) {
    GenericDraweeHierarchy hierarchy = getGenericDraweeHierarchy(draweeView);
    if (hierarchy != null && hierarchy.hasPlaceholderImage()) {
        try {
            Field mFadeDrawableField = hierarchy.getClass().getDeclaredField("mFadeDrawable");
            mFadeDrawableField.setAccessible(true);
            FadeDrawable fadeDrawable = (FadeDrawable) mFadeDrawableField.get(hierarchy);
            Field mLayersField = fadeDrawable.getClass().getDeclaredField("mLayers");
            mLayersField.setAccessible(true);
            Drawable[] layers = (Drawable[]) mLayersField.get(fadeDrawable);
            // PLACEHOLDER_IMAGE_INDEX == 1
            Drawable drawable = layers[1];
            return getFrescoDrawableBitmap(drawable);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return null;
}
 
Example #7
Source File: UETFresco.java    From UETool with MIT License 6 votes vote down vote up
private String getCornerRadius(DraweeView draweeView) {
    GenericDraweeHierarchy hierarchy = getGenericDraweeHierarchy(draweeView);
    if (hierarchy != null) {
        RoundingParams params = hierarchy.getRoundingParams();
        if (params != null) {
            float[] cornersRadii = params.getCornersRadii();
            if (cornersRadii != null) {
                float firstRadii = cornersRadii[0];
                for (int i = 1; i < 8; i++) {
                    if (firstRadii != cornersRadii[i]) {
                        return null;
                    }
                }
                return px2dip(firstRadii, true);
            }
        }
    }
    return null;
}
 
Example #8
Source File: Attacher.java    From PicKing with Apache License 2.0 6 votes vote down vote up
@Override public void run() {

            DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();
            if (draweeView == null) {
                return;
            }

            float t = interpolate();
            float scale = mZoomStart + t * (mZoomEnd - mZoomStart);
            float deltaScale = scale / getScale();

            onScale(deltaScale, mFocalX, mFocalY);

            if (t < 1f) {
                postOnAnimation(draweeView, this);
            }
        }
 
Example #9
Source File: Attacher.java    From PicKing with Apache License 2.0 6 votes vote down vote up
@Override public void run() {
    if (mScroller.isFinished()) {
        return;
    }

    DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();

    if (draweeView != null && mScroller.computeScrollOffset()) {
        final int newX = mScroller.getCurrX();
        final int newY = mScroller.getCurrY();
        mMatrix.postTranslate(mCurrentX - newX, mCurrentY - newY);
        draweeView.invalidate();
        mCurrentX = newX;
        mCurrentY = newY;
        postOnAnimation(draweeView, this);
    }
}
 
Example #10
Source File: Attacher.java    From CanPhotos with Apache License 2.0 6 votes vote down vote up
@Override public void onDrag(float dx, float dy) {

        DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();

        if (draweeView != null && !mScaleDragDetector.isScaling()) {
            mMatrix.postTranslate(dx, dy);
            checkMatrixAndInvalidate();

            ViewParent parent = draweeView.getParent();
            if (parent == null) {
                return;
            }

            if (mAllowParentInterceptOnEdge
                    && !mScaleDragDetector.isScaling()
                    && !mBlockParentIntercept) {
                if (mScrollEdge == EDGE_BOTH || (mScrollEdge == EDGE_LEFT && dx >= 1f) || (
                        mScrollEdge == EDGE_RIGHT
                                && dx <= -1f)) {
                    parent.requestDisallowInterceptTouchEvent(false);
                }
            } else {
                parent.requestDisallowInterceptTouchEvent(true);
            }
        }
    }
 
Example #11
Source File: Attacher.java    From CanPhotos with Apache License 2.0 6 votes vote down vote up
@Override public void run() {

            DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();
            if (draweeView == null) {
                return;
            }

            float t = interpolate();
            float scale = mZoomStart + t * (mZoomEnd - mZoomStart);
            float deltaScale = scale / getScale();

            onScale(deltaScale, mFocalX, mFocalY);

            if (t < 1f) {
                postOnAnimation(draweeView, this);
            }
        }
 
Example #12
Source File: Attacher.java    From CanPhotos with Apache License 2.0 6 votes vote down vote up
@Override public void run() {
    if (mScroller.isFinished()) {
        return;
    }

    DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();

    if (draweeView != null && mScroller.computeScrollOffset()) {
        final int newX = mScroller.getCurrX();
        final int newY = mScroller.getCurrY();
        mMatrix.postTranslate(mCurrentX - newX, mCurrentY - newY);
        draweeView.invalidate();
        mCurrentX = newX;
        mCurrentY = newY;
        postOnAnimation(draweeView, this);
    }
}
 
Example #13
Source File: Attacher.java    From TLint with Apache License 2.0 6 votes vote down vote up
@Override
public void onDrag(float dx, float dy) {

    DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();

    if (draweeView != null && !mScaleDragDetector.isScaling()) {
        mMatrix.postTranslate(dx, dy);
        checkMatrixAndInvalidate();

        ViewParent parent = draweeView.getParent();
        if (parent == null) {
            return;
        }

        if (mAllowParentInterceptOnEdge
                && !mScaleDragDetector.isScaling()
                && !mBlockParentIntercept) {
            if (mScrollEdge == EDGE_BOTH || (mScrollEdge == EDGE_LEFT && dx >= 1f) || (mScrollEdge
                    == EDGE_RIGHT && dx <= -1f)) {
                parent.requestDisallowInterceptTouchEvent(false);
            }
        } else {
            parent.requestDisallowInterceptTouchEvent(true);
        }
    }
}
 
Example #14
Source File: Attacher.java    From SprintNBA with Apache License 2.0 6 votes vote down vote up
public Attacher(DraweeView<GenericDraweeHierarchy> draweeView) {
    mDraweeView = new WeakReference<>(draweeView);
    draweeView.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
    draweeView.setOnTouchListener(this);
    mScaleDragDetector = new ScaleDragDetector(draweeView.getContext(), this);
    mGestureDetector = new GestureDetectorCompat(draweeView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {
                @Override public void onLongPress(MotionEvent e) {
                    super.onLongPress(e);
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getDraweeView());
                    }
                }
            });
    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
}
 
Example #15
Source File: Attacher.java    From PhotoDraweeView with Apache License 2.0 6 votes vote down vote up
@Override public void run() {
    if (mScroller.isFinished()) {
        return;
    }

    DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();

    if (draweeView != null && mScroller.computeScrollOffset()) {
        final int newX = mScroller.getCurrX();
        final int newY = mScroller.getCurrY();
        mMatrix.postTranslate(mCurrentX - newX, mCurrentY - newY);
        draweeView.invalidate();
        mCurrentX = newX;
        mCurrentY = newY;
        postOnAnimation(draweeView, this);
    }
}
 
Example #16
Source File: Attacher.java    From SprintNBA with Apache License 2.0 6 votes vote down vote up
@Override public void onDrag(float dx, float dy) {

        DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();

        if (draweeView != null && !mScaleDragDetector.isScaling()) {
            mMatrix.postTranslate(dx, dy);
            checkMatrixAndInvalidate();

            ViewParent parent = draweeView.getParent();
            if (parent == null) {
                return;
            }

            if (mAllowParentInterceptOnEdge
                    && !mScaleDragDetector.isScaling()
                    && !mBlockParentIntercept) {
                if (mScrollEdge == EDGE_BOTH || (mScrollEdge == EDGE_LEFT && dx >= 1f) || (
                        mScrollEdge == EDGE_RIGHT
                                && dx <= -1f)) {
                    parent.requestDisallowInterceptTouchEvent(false);
                }
            } else {
                parent.requestDisallowInterceptTouchEvent(true);
            }
        }
    }
 
Example #17
Source File: Attacher.java    From SprintNBA with Apache License 2.0 6 votes vote down vote up
@Override public void run() {

            DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();
            if (draweeView == null) {
                return;
            }

            float t = interpolate();
            float scale = mZoomStart + t * (mZoomEnd - mZoomStart);
            float deltaScale = scale / getScale();

            onScale(deltaScale, mFocalX, mFocalY);

            if (t < 1f) {
                postOnAnimation(draweeView, this);
            }
        }
 
Example #18
Source File: Attacher.java    From TLint with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {

    DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();
    if (draweeView == null) {
        return;
    }

    float t = interpolate();
    float scale = mZoomStart + t * (mZoomEnd - mZoomStart);
    float deltaScale = scale / getScale();

    onScale(deltaScale, mFocalX, mFocalY);

    if (t < 1f) {
        postOnAnimation(draweeView, this);
    }
}
 
Example #19
Source File: FrescoUtils.java    From droidddle with Apache License 2.0 6 votes vote down vote up
public static final void setShotUrl(DraweeView view, String url, String thumbnail/*, BaseControllerListener listener*/) {
        ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
//                .setResizeOptions(
//                        new ResizeOptions(300, 400))
                .setProgressiveRenderingEnabled(true)
                .build();
        ImageRequest lowRequest = null;
        if (!TextUtils.isEmpty(thumbnail)) {
            lowRequest = ImageRequest.fromUri(thumbnail);
        }
        DraweeController draweeController = Fresco.newDraweeControllerBuilder()
                .setImageRequest(imageRequest)
                .setLowResImageRequest(lowRequest)
                .setOldController(view.getController())
                .setAutoPlayAnimations(true)
//                .setControllerListener(listener)
                .build();
        view.setController(draweeController);
    }
 
Example #20
Source File: Attacher.java    From PhotoDraweeView with Apache License 2.0 6 votes vote down vote up
public Attacher(DraweeView<GenericDraweeHierarchy> draweeView) {
    mDraweeView = new WeakReference<>(draweeView);
    draweeView.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER);
    draweeView.setOnTouchListener(this);
    mScaleDragDetector = new ScaleDragDetector(draweeView.getContext(), this);
    mGestureDetector = new GestureDetectorCompat(draweeView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {
                @Override public void onLongPress(MotionEvent e) {
                    super.onLongPress(e);
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getDraweeView());
                    }
                }
            });
    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
}
 
Example #21
Source File: UETFresco.java    From UETool with MIT License 5 votes vote down vote up
private String getFadeDuration(DraweeView draweeView) {
    int duration = 0;
    GenericDraweeHierarchy hierarchy = getGenericDraweeHierarchy(draweeView);
    if (hierarchy != null) {
        duration = hierarchy.getFadeDuration();
    }
    return duration + "ms";
}
 
Example #22
Source File: FrescoUtils.java    From droidddle with Apache License 2.0 5 votes vote down vote up
public static final void setShotHierarchy(Context context, DraweeView view, ScalingUtils.ScaleType type) {
    final Resources res = context.getResources();
    final int color = ThemeUtil.getThemeColor(context, R.attr.colorAccent);
    final ProgressBarDrawable progress = new ProgressBarDrawable();
    progress.setBackgroundColor(Color.parseColor("#33000000"));
    progress.setColor(color);
    GenericDraweeHierarchy gdh = new GenericDraweeHierarchyBuilder(res)
            .setPlaceholderImage(res.getDrawable(R.drawable.placeholder))
            .setProgressBarImage(progress)
            .setActualImageScaleType(type)
            .build();
    view.setHierarchy(gdh);
}
 
Example #23
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 #24
Source File: FrescoConfig.java    From BlueBoard with Apache License 2.0 5 votes vote down vote up
public static ImageRequest getImageRequest(DraweeView view, String uri) {
        ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri))
//            .setAutoRotateEnabled(true)//自动旋转图片方向
//            .setImageDecodeOptions(getImageDecodeOptions())//  图片解码库
//            .setImageType(ImageType.SMALL)//图片类型,设置后可调整图片放入小图磁盘空间还是默认图片磁盘空间
//            .setLocalThumbnailPreviewsEnabled(true)//缩略图预览,影响图片显示速度(轻微)
                .setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH)//请求经过缓存级别  BITMAP_MEMORY_CACHE,ENCODED_MEMORY_CACHE,DISK_CACHE,FULL_FETCH
//            .setPostprocessor(postprocessor)//修改图片
//            .setProgressiveRenderingEnabled(true)//渐进加载,主要用于渐进式的JPEG图,影响图片显示速度(普通)
                .setResizeOptions(new ResizeOptions(view.getLayoutParams().width, view.getLayoutParams().height))//调整大小
//            .setSource(Uri uri)//设置图片地址
                .build();
        return imageRequest;
    }
 
Example #25
Source File: Attacher.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
@Override public void setScale(float scale, float focalX, float focalY, boolean animate) {
    DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();

    if (draweeView == null || scale < mMinScale || scale > mMaxScale) {
        return;
    }

    if (animate) {
        draweeView.post(new AnimatedZoomRunnable(getScale(), scale, focalX, focalY));
    } else {
        mMatrix.setScale(scale, scale, focalX, focalY);
        checkMatrixAndInvalidate();
    }
}
 
Example #26
Source File: Attacher.java    From TLint with Apache License 2.0 5 votes vote down vote up
private RectF getDisplayRect(Matrix matrix) {
    DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();
    if (draweeView == null || (mImageInfoWidth == -1 && mImageInfoHeight == -1)) {
        return null;
    }
    mDisplayRect.set(0.0F, 0.0F, mImageInfoWidth, mImageInfoHeight);
    draweeView.getHierarchy().getActualImageBounds(mDisplayRect);
    matrix.mapRect(mDisplayRect);
    return mDisplayRect;
}
 
Example #27
Source File: Attacher.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
private void checkMinScale() {
    DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();
    if (draweeView == null) {
        return;
    }

    if (getScale() < mMinScale) {
        RectF rect = getDisplayRect();
        if (null != rect) {
            draweeView.post(new AnimatedZoomRunnable(getScale(), mMinScale, rect.centerX(),
                    rect.centerY()));
        }
    }
}
 
Example #28
Source File: Attacher.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
@Override public void onFling(float startX, float startY, float velocityX, float velocityY) {
    DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();
    if (draweeView == null) {
        return;
    }

    mCurrentFlingRunnable = new FlingRunnable(draweeView.getContext());
    mCurrentFlingRunnable.fling(getViewWidth(), getViewHeight(), (int) velocityX,
            (int) velocityY);
    draweeView.post(mCurrentFlingRunnable);
}
 
Example #29
Source File: UETFresco.java    From UETool with MIT License 5 votes vote down vote up
private String isSupportAnimation(DraweeView draweeView) {
    PipelineDraweeControllerBuilder builder = getFrescoControllerBuilder(draweeView);
    if (builder != null) {
        return String.valueOf(builder.getAutoPlayAnimations()).toUpperCase();
    }
    return "";
}
 
Example #30
Source File: Attacher.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
private RectF getDisplayRect(Matrix matrix) {
    DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView();
    if (draweeView == null || (mImageInfoWidth == -1 && mImageInfoHeight == -1)) {
        return null;
    }
    mDisplayRect.set(0.0F, 0.0F, mImageInfoWidth, mImageInfoHeight);
    draweeView.getHierarchy().getActualImageBounds(mDisplayRect);
    matrix.mapRect(mDisplayRect);
    return mDisplayRect;
}