本文整理汇总了Java中com.facebook.drawee.generic.GenericDraweeHierarchy类的典型用法代码示例。如果您正苦于以下问题:Java GenericDraweeHierarchy类的具体用法?Java GenericDraweeHierarchy怎么用?Java GenericDraweeHierarchy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GenericDraweeHierarchy类属于com.facebook.drawee.generic包,在下文中一共展示了GenericDraweeHierarchy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMockBuilderOfDrawableHierarchies
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入依赖的package包/类
@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());
}
示例2: changeDraweeViewScaleType
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入依赖的package包/类
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);
}
示例3: displayImage
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入依赖的package包/类
private void displayImage(SimpleDraweeView draweeView, String url) {
GenericDraweeHierarchy hierarchy = draweeView.getHierarchy();
//设置占位图
if (hierarchy == null) {
hierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources())
.setPlaceholderImage(getResources().getDrawable(R.mipmap.ic_launcher)
, ScalingUtils.ScaleType.CENTER).build();
draweeView.setHierarchy(hierarchy);
} else {
hierarchy.setPlaceholderImage(getResources().getDrawable(R.mipmap.ic_launcher)
, ScalingUtils.ScaleType.CENTER);
}
//构建ImageRequestBuilder,传入请求Uri
ImageRequestBuilder requestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url));
//构建Controller
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setOldController(draweeView.getController())
.setImageRequest(requestBuilder.build())
.build();
//设置图片,Fresco设置显示图片都是通过Controller来实现
draweeView.setController(controller);
}
示例4: generateImageLayout
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入依赖的package包/类
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;
}
示例5: Attacher
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入依赖的package包/类
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));
}
示例6: run
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入依赖的package包/类
@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);
}
}
示例7: createSimpleDraweeView
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入依赖的package包/类
private SimpleDraweeView createSimpleDraweeView() {
SimpleDraweeView view = new SimpleDraweeView(itemView.getContext());
GenericDraweeHierarchyBuilder builder =
new GenericDraweeHierarchyBuilder(itemView.getContext().getResources());
GenericDraweeHierarchy hierarchy = builder
.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP)
.setPlaceholderImage(R.color.loading_color)
.setPlaceholderImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
.setFailureImage(R.mipmap.ic_failed)
.setFailureImageScaleType(ScalingUtils.ScaleType.CENTER)
.build();
view.setHierarchy(hierarchy);
view.setTag(atomicInteger.getAndIncrement());
view.setOnClickListener(this);
return view;
}
示例8: loadHeadView
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入依赖的package包/类
public static void loadHeadView(Context context, SimpleDraweeView simpleDraweeView, Uri httpUri) {
//初始化圆角圆形参数对象
RoundingParams rp = new RoundingParams();
//设置图像是否为圆形
rp.setRoundAsCircle(true);
final GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(context.getResources())
.setRoundingParams(rp)
.build();
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setUri(httpUri)
.setTapToRetryEnabled(true)
.setOldController(simpleDraweeView.getController())
.build();
simpleDraweeView.setHierarchy(hierarchy);
simpleDraweeView.setController(controller);
}
示例9: onDrag
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入依赖的package包/类
@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);
}
}
}
示例10: run
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入依赖的package包/类
@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);
}
}
示例11: init
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入依赖的package包/类
protected void init() {
if (null == mAttacher || null == mAttacher.getImageView()) {
mAttacher = new PhotoViewAttacher(this);
}
if (null != mPendingScaleType) {
setScaleType(mPendingScaleType);
mPendingScaleType = null;
}
if (mDraweeHolder == null) {
GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources())
.setFadeDuration(500)
.setProgressBarImage(new CustomProgressbarDrawable(this))
.build();
mDraweeHolder = DraweeHolder.create(hierarchy, getContext());
}
}
示例12: getGenericDraweeHierarchy
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入依赖的package包/类
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(ConfigConstants.sErrorDrawable)//fresco:failureImage="@drawable/error"失败图
// .setFailureImage(failureDrawable, failureImageScaleType)//fresco:failureImageScaleType="centerInside"失败图缩放类型
// .setOverlay(overlay)//fresco:overlayImage="@drawable/watermark"叠加图
// .setOverlays(overlays)
.setPlaceholderImage(ConfigConstants.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;
}
示例13: onCreate
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_image);
final SimpleDraweeView mImageView = (SimpleDraweeView) findViewById(R.id.view_image_image);
final int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
final GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources())
.setFadeDuration(shortAnimTime)
.setProgressBarImage(new ImageLoadingDrawable(getResources()))
.setFailureImage(getResources().getDrawable(R.drawable.ic_upload_failed), ScalingUtils.ScaleType.CENTER_INSIDE)
.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
.build();
mImageView.setHierarchy(hierarchy);
mImageView.setImageURI(getIntent().getParcelableExtra(EXTRA_IMAGE_URI));
}
示例14: mockBuilderOf
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入依赖的package包/类
/**
* Creates a mock GenericDraweeHierarchyBuilder with stubbed build.
* @param drawableHierarchies drawable hierarchies to return on {@code build()}
* @return mock GenericDraweeHierarchyBuilder
*/
public static GenericDraweeHierarchyBuilder mockBuilderOf(
GenericDraweeHierarchy... drawableHierarchies) {
GenericDraweeHierarchyBuilder builder =
mock(GenericDraweeHierarchyBuilder.class, CALLS_REAL_METHODS);
final Supplier<GenericDraweeHierarchy> gdhProvider = supplierOf(drawableHierarchies);
doAnswer(
new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return gdhProvider.get();
}
}).when(builder).build();
return builder;
}
示例15: onCreateViewHolder
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入依赖的package包/类
@Override
public VolleyDraweeHolder onCreateViewHolder(ViewGroup parent, int viewType) {
GenericDraweeHierarchy gdh = new GenericDraweeHierarchyBuilder(getContext().getResources())
.setPlaceholderImage(Drawables.sPlaceholderDrawable)
.setFailureImage(Drawables.sErrorDrawable)
.build();
InstrumentedDraweeView view = new InstrumentedDraweeView(getContext());
view.setHierarchy(gdh);
return new VolleyDraweeHolder(getContext(), parent, view, getPerfListener());
}