com.facebook.drawee.generic.GenericDraweeHierarchy Java Examples
The following examples show how to use
com.facebook.drawee.generic.GenericDraweeHierarchy.
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 TLint with Apache License 2.0 | 6 votes |
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: SocialPublishActivity.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 6 votes |
@SuppressLint({ "ViewHolder", "InflateParams" }) @Override public View getView(int position, View convertView, ViewGroup parent) { convertView = inflater.inflate(R.layout.item_gridview_image, null); SimpleDraweeView sdv_image = (SimpleDraweeView) convertView .findViewById(R.id.sdv_image); if (position == list.size() && list.size() < 9) { GenericDraweeHierarchy hierarchy = sdv_image.getHierarchy(); hierarchy.setPlaceholderImage(R.drawable.icon_add); } else { Uri uri_temp = getItem(position); sdv_image.setImageURI(uri_temp); } return convertView; }
Example #3
Source File: CommentImageGrid.java From CommentGallery with Apache License 2.0 | 6 votes |
private ViewGroup generateImageLayout() { SquareDraweeView imageView = new SquareDraweeView(mContext); GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(mContext.getResources()); GenericDraweeHierarchy hierarchy = builder .setFadeDuration(300).setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP) .build(); if (mPlaceholderImageResId > 0) { hierarchy.setPlaceholderImage(mPlaceholderImageResId); } if (mFailureImageResId > 0) { hierarchy.setFailureImage(mFailureImageResId); } imageView.setHierarchy(hierarchy); RelativeLayout.LayoutParams imgLp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); imgLp.setMargins(mImageBorderThickness, mImageBorderThickness, mImageBorderThickness, mImageBorderThickness); RelativeLayout mainLayout = new RelativeLayout(mContext); mainLayout.setBackgroundColor(mImageBorderColor); mainLayout.addView(imageView, imgLp); return mainLayout; }
Example #4
Source File: DraweeMocksTest.java From fresco with MIT License | 6 votes |
@Test public void testMockBuilderOfDrawableHierarchies() { GenericDraweeHierarchy gdh = DraweeMocks.mockDraweeHierarchy(); GenericDraweeHierarchyBuilder builder = DraweeMocks.mockBuilderOf(gdh); assertEquals(gdh, builder.build()); assertEquals(gdh, builder.build()); assertEquals(gdh, builder.build()); assertEquals(gdh, builder.build()); assertEquals(gdh, builder.build()); GenericDraweeHierarchy gdh1 = DraweeMocks.mockDraweeHierarchy(); GenericDraweeHierarchy gdh2 = DraweeMocks.mockDraweeHierarchy(); GenericDraweeHierarchy gdh3 = DraweeMocks.mockDraweeHierarchy(); GenericDraweeHierarchyBuilder multiBuilder = DraweeMocks.mockBuilderOf(gdh1, gdh2, gdh3); assertEquals(gdh1, multiBuilder.build()); assertEquals(gdh2, multiBuilder.build()); assertEquals(gdh3, multiBuilder.build()); assertEquals(gdh3, multiBuilder.build()); assertEquals(gdh3, multiBuilder.build()); }
Example #5
Source File: FrescoConfig.java From BlueBoard with Apache License 2.0 | 6 votes |
public static GenericDraweeHierarchy getGenericDraweeHierarchy(Context context) { GenericDraweeHierarchy gdh = new GenericDraweeHierarchyBuilder(context.getResources()) // .reset()//重置 // .setActualImageColorFilter(colorFilter)//颜色过滤 // .setActualImageFocusPoint(focusPoint)//focusCrop, 需要指定一个居中点 // .setActualImageMatrix(actualImageMatrix) // .setActualImageScaleType(actualImageScaleType)//fresco:actualImageScaleType="focusCrop"缩放类型 // .setBackground(background)//fresco:backgroundImage="@color/blue"背景图片 // .setBackgrounds(backgrounds) // .setFadeDuration(fadeDuration)//fresco:fadeDuration="300"加载图片动画时间 .setFailureImage(FrescoConfig.sErrorDrawable)//fresco:failureImage="@drawable/error"失败图 // .setFailureImage(failureDrawable, failureImageScaleType)//fresco:failureImageScaleType="centerInside"失败图缩放类型 // .setOverlay(overlay)//fresco:overlayImage="@drawable/watermark"叠加图 // .setOverlays(overlays) .setPlaceholderImage(FrescoConfig.sPlaceholderDrawable)//fresco:placeholderImage="@color/wait_color"占位图 // .setPlaceholderImage(placeholderDrawable, placeholderImageScaleType)//fresco:placeholderImageScaleType="fitCenter"占位图缩放类型 // .setPressedStateOverlay(drawable)//fresco:pressedStateOverlayImage="@color/red"按压状态下的叠加图 .setProgressBarImage(new ProgressBarDrawable())//进度条fresco:progressBarImage="@drawable/progress_bar"进度条 // .setProgressBarImage(progressBarImage, progressBarImageScaleType)//fresco:progressBarImageScaleType="centerInside"进度条类型 // .setRetryImage(retryDrawable)//fresco:retryImage="@drawable/retrying"点击重新加载 // .setRetryImage(retryDrawable, retryImageScaleType)//fresco:retryImageScaleType="centerCrop"点击重新加载缩放类型 .setRoundingParams(RoundingParams.asCircle())//圆形/圆角fresco:roundAsCircle="true"圆形 .build(); return gdh; }
Example #6
Source File: Attacher.java From PhotoDraweeView with Apache License 2.0 | 6 votes |
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 #7
Source File: CallBackgroundAvatarView.java From actor-platform with GNU Affero General Public License v3.0 | 6 votes |
public void init() { if(blurActor==null){ blurActor = system().actorOf(Props.create(new ActorCreator() { @Override public BlurActor create() { return new BlurActor(); } }), "actor/call_blur"); } GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); GenericDraweeHierarchy hierarchy = builder .setFadeDuration(200) .build(); setHierarchy(hierarchy); }
Example #8
Source File: UETFresco.java From UETool with MIT License | 6 votes |
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 #9
Source File: AvatarView.java From actor-platform with GNU Affero General Public License v3.0 | 6 votes |
public void init(int size, float placeholderTextSize) { this.size = size; this.placeholderTextSize = placeholderTextSize; GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); GenericDraweeHierarchy hierarchy = builder .setFadeDuration(200) .setRoundingParams(new RoundingParams() .setRoundAsCircle(true) .setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY)) //.setActualImageColorFilter(new PorterDuffColorFilter(0x19000000, PorterDuff.Mode.MULTIPLY)) //.setOverlay(new AvatarBorderDrawable()) .build(); setHierarchy(hierarchy); }
Example #10
Source File: UETFresco.java From UETool with MIT License | 6 votes |
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 #11
Source File: Attacher.java From SprintNBA with Apache License 2.0 | 6 votes |
@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 #12
Source File: Attacher.java From TLint with Apache License 2.0 | 5 votes |
@Override public void setScale(float scale, boolean animate) { DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView(); if (draweeView != null) { setScale(scale, (draweeView.getRight()) / 2, (draweeView.getBottom()) / 2, false); } }
Example #13
Source File: DefaultOnDoubleTapListener.java From CanPhotos with Apache License 2.0 | 5 votes |
@Override public boolean onSingleTapConfirmed(MotionEvent e) { if (mAttacher == null) { return false; } DraweeView<GenericDraweeHierarchy> draweeView = mAttacher.getDraweeView(); if (draweeView == null) { return false; } if (mAttacher.getOnPhotoTapListener() != null) { final RectF displayRect = mAttacher.getDisplayRect(); if (null != displayRect) { final float x = e.getX(), y = e.getY(); if (displayRect.contains(x, y)) { float xResult = (x - displayRect.left) / displayRect.width(); float yResult = (y - displayRect.top) / displayRect.height(); mAttacher.getOnPhotoTapListener().onPhotoTap(draweeView, xResult, yResult); return true; } } } if (mAttacher.getOnViewTapListener() != null) { mAttacher.getOnViewTapListener().onViewTap(draweeView, e.getX(), e.getY()); return true; } return false; }
Example #14
Source File: Attacher.java From TLint with Apache License 2.0 | 5 votes |
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 #15
Source File: OverlayMarker.java From react-native-baidu-map with MIT License | 5 votes |
protected void init() { GenericDraweeHierarchy genericDraweeHierarchy = new GenericDraweeHierarchyBuilder(getResources()) .setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER) .setFadeDuration(0) .build(); imageHolder = DraweeHolder.create(genericDraweeHierarchy, getContext()); imageHolder.onAttach(); }
Example #16
Source File: Attacher.java From TLint with Apache License 2.0 | 5 votes |
@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 #17
Source File: DefaultOnDoubleTapListener.java From SprintNBA with Apache License 2.0 | 5 votes |
@Override public boolean onSingleTapConfirmed(MotionEvent e) { if (mAttacher == null) { return false; } DraweeView<GenericDraweeHierarchy> draweeView = mAttacher.getDraweeView(); if (draweeView == null) { return false; } if (mAttacher.getOnPhotoTapListener() != null) { final RectF displayRect = mAttacher.getDisplayRect(); if (null != displayRect) { final float x = e.getX(), y = e.getY(); if (displayRect.contains(x, y)) { float xResult = (x - displayRect.left) / displayRect.width(); float yResult = (y - displayRect.top) / displayRect.height(); mAttacher.getOnPhotoTapListener().onPhotoTap(draweeView, xResult, yResult); return true; } } } if (mAttacher.getOnViewTapListener() != null) { mAttacher.getOnViewTapListener().onViewTap(draweeView, e.getX(), e.getY()); return true; } return false; }
Example #18
Source File: Attacher.java From PhotoDraweeView with Apache License 2.0 | 5 votes |
public void checkMatrixAndInvalidate() { DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView(); if (draweeView == null) { return; } if (checkMatrixBounds()) { draweeView.invalidate(); } }
Example #19
Source File: Attacher.java From TLint with Apache License 2.0 | 5 votes |
private void resetMatrix() { mMatrix.reset(); checkMatrixBounds(); DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView(); if (draweeView != null) { draweeView.invalidate(); } }
Example #20
Source File: Attacher.java From PicKing with Apache License 2.0 | 5 votes |
private int getViewHeight() { DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView(); if (draweeView != null) { return draweeView.getHeight() - draweeView.getPaddingTop() - draweeView.getPaddingBottom(); } return 0; }
Example #21
Source File: Attacher.java From CanPhotos with Apache License 2.0 | 5 votes |
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 #22
Source File: Attacher.java From SprintNBA with Apache License 2.0 | 5 votes |
private int getViewHeight() { DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView(); if (draweeView != null) { return draweeView.getHeight() - draweeView.getPaddingTop() - draweeView.getPaddingBottom(); } return 0; }
Example #23
Source File: DrawableController.java From WindowImageView with MIT License | 5 votes |
private void initDraweeHolder() { if (mDraweeHolder == null) { GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(mContext.getResources()) .build(); mDraweeHolder = DraweeHolder.create(hierarchy, mContext); } }
Example #24
Source File: FrescoAdapter.java From ImageLoadPK with Apache License 2.0 | 5 votes |
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { GenericDraweeHierarchy genericDraweeHierarchy = new GenericDraweeHierarchyBuilder(getContext().getResources()) .setPlaceholderImage(Drawables.sPlaceholderDrawable) .setFailureImage(Drawables.sErrorDrawable) // .setProgressBarImage(new ProgressBarDrawable()) .setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP) .build(); WatchDraweeImage watchDraweeImage = new WatchDraweeImage(getContext(), genericDraweeHierarchy); return new FrescoHolder(watchDraweeImage, getWatchListener(), parent, getContext()); }
Example #25
Source File: DraweeRoundedCornersFragment.java From fresco with MIT License | 5 votes |
private void changeDraweeViewScaleType( SimpleDraweeView draweeView, ScaleType scaleType, @Nullable PointF focusPoint) { final GenericDraweeHierarchy hierarchy = draweeView.getHierarchy(); hierarchy.setActualImageScaleType(scaleType); hierarchy.setActualImageFocusPoint(focusPoint != null ? focusPoint : new PointF(0.5f, 0.5f)); final RoundingParams roundingParams = Preconditions.checkNotNull(hierarchy.getRoundingParams()); if (BITMAP_ONLY_SCALETYPES.contains(scaleType)) { roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY); } else { roundingParams.setOverlayColor(mWindowBackgroundColor); } hierarchy.setRoundingParams(roundingParams); }
Example #26
Source File: BackgroundPreviewView.java From actor-platform with GNU Affero General Public License v3.0 | 5 votes |
public void init(int width, int height, int corenerRadius) { this.width = width; this.height = height; GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources()); GenericDraweeHierarchy hierarchy = builder .setFadeDuration(200) .setRoundingParams(new RoundingParams() .setCornersRadius(corenerRadius) .setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY)) .build(); setHierarchy(hierarchy); }
Example #27
Source File: ImageActivity.java From coderfun with GNU General Public License v3.0 | 5 votes |
private void initSimpleDraweeView() { simpleDraweeView = (SimpleDraweeView) findViewById(R.id.draweeview); GenericDraweeHierarchy hierarchy = simpleDraweeView.getHierarchy(); hierarchy.setProgressBarImage(new ProgressBarDrawable()); Uri uri = Uri.parse(url); simpleDraweeView.setImageURI(uri); }
Example #28
Source File: Attacher.java From PicKing with Apache License 2.0 | 5 votes |
private void resetMatrix() { mMatrix.reset(); checkMatrixBounds(); DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView(); if (draweeView != null) { draweeView.invalidate(); } }
Example #29
Source File: Attacher.java From PicKing with Apache License 2.0 | 5 votes |
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 #30
Source File: Attacher.java From PicKing with Apache License 2.0 | 5 votes |
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())); } } }