本文整理汇总了Java中com.facebook.drawee.generic.GenericDraweeHierarchy.setPlaceholderImage方法的典型用法代码示例。如果您正苦于以下问题:Java GenericDraweeHierarchy.setPlaceholderImage方法的具体用法?Java GenericDraweeHierarchy.setPlaceholderImage怎么用?Java GenericDraweeHierarchy.setPlaceholderImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.facebook.drawee.generic.GenericDraweeHierarchy
的用法示例。
在下文中一共展示了GenericDraweeHierarchy.setPlaceholderImage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: setDefaultImage
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入方法依赖的package包/类
public void setDefaultImage(Bitmap bitmap) {
GenericDraweeHierarchy hierarchy = getHierarchy();
hierarchy.setPlaceholderImage(new BitmapDrawable(bitmap), ScalingUtils.ScaleType.FOCUS_CROP);
setHierarchy(hierarchy);
}
示例4: instantiateItem
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入方法依赖的package包/类
@Override
public Object instantiateItem(final ViewGroup container, int position) {
if(mData != null && mData.size() > position){
ZoomableDraweeView zoomableDraweeView = null;
if(mImageViewList != null && mImageViewList.length > position && mImageViewList[position] != null){
zoomableDraweeView = mImageViewList[position];
}else{
zoomableDraweeView = new ZoomableDraweeView(container.getContext());
zoomableDraweeView.setAllowTouchInterceptionWhileZoomed(true);
// needed for double tap to zoom
zoomableDraweeView.setIsLongpressEnabled(false);
zoomableDraweeView.setSwipeDownListener(mSwipeDownListener);
final ZoomableDraweeView finalZoomableDraweeView = zoomableDraweeView;
zoomableDraweeView.setTapListener(new DoubleTapGestureListener(finalZoomableDraweeView){
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
if(mItemClickListener != null){
mItemClickListener.onClick(finalZoomableDraweeView);
}
return super.onSingleTapConfirmed(e);
}
});
DraweeController controller = Fresco.newDraweeControllerBuilder()
.setUri(mData.get(position % mData.size()))
.build();
zoomableDraweeView.setController(controller);
GenericDraweeHierarchyBuilder builder =
new GenericDraweeHierarchyBuilder(container.getResources());
GenericDraweeHierarchy hierarchy = builder
.setFadeDuration(300).setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER)
.build();
if(mPlaceholderImageResId > 0){
hierarchy.setPlaceholderImage(mPlaceholderImageResId, ScalingUtils.ScaleType.FIT_CENTER);
}
if(mFailureImageResId > 0){
hierarchy.setFailureImage(mFailureImageResId, ScalingUtils.ScaleType.FIT_CENTER);
}
zoomableDraweeView.setHierarchy(hierarchy);
mImageViewList[position] = zoomableDraweeView;
}
container.addView(zoomableDraweeView);
return zoomableDraweeView;
}
return null;
}
示例5: maybeUpdateView
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入方法依赖的package包/类
public void maybeUpdateView() {
if (!mIsDirty) {
return;
}
boolean doResize = shouldResize(mUri);
if (doResize && (getWidth() <= 0 || getHeight() <=0)) {
// If need a resize and the size is not yet set, wait until the layout pass provides one
return;
}
GenericDraweeHierarchy hierarchy = getHierarchy();
hierarchy.setActualImageScaleType(mScaleType);
if (mLoadingImageDrawable != null) {
hierarchy.setPlaceholderImage(mLoadingImageDrawable, ScalingUtils.ScaleType.CENTER);
}
boolean usePostprocessorScaling =
mScaleType != ScalingUtils.ScaleType.CENTER_CROP &&
mScaleType != ScalingUtils.ScaleType.FOCUS_CROP;
float hierarchyRadius = usePostprocessorScaling ? 0 : mBorderRadius;
RoundingParams roundingParams = hierarchy.getRoundingParams();
roundingParams.setCornersRadius(hierarchyRadius);
roundingParams.setBorder(mBorderColor, mBorderWidth);
if (mOverlayColor != Color.TRANSPARENT) {
roundingParams.setOverlayColor(mOverlayColor);
} else {
// make sure the default rounding method is used.
roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
}
hierarchy.setRoundingParams(roundingParams);
hierarchy.setFadeDuration(
mFadeDurationMs >= 0
? mFadeDurationMs
: mIsLocalImage ? 0 : REMOTE_IMAGE_FADE_DURATION_MS);
Postprocessor postprocessor = usePostprocessorScaling ? mRoundedCornerPostprocessor : null;
ResizeOptions resizeOptions = doResize ? new ResizeOptions(getWidth(), getHeight()) : null;
ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri)
.setPostprocessor(postprocessor)
.setResizeOptions(resizeOptions)
.setAutoRotateEnabled(true)
.setProgressiveRenderingEnabled(mProgressiveRenderingEnabled)
.build();
// This builder is reused
mDraweeControllerBuilder.reset();
mDraweeControllerBuilder
.setAutoPlayAnimations(true)
.setCallerContext(mCallerContext)
.setOldController(getController())
.setImageRequest(imageRequest);
if (mControllerListener != null && mControllerForTesting != null) {
ForwardingControllerListener combinedListener = new ForwardingControllerListener();
combinedListener.addListener(mControllerListener);
combinedListener.addListener(mControllerForTesting);
mDraweeControllerBuilder.setControllerListener(combinedListener);
} else if (mControllerForTesting != null) {
mDraweeControllerBuilder.setControllerListener(mControllerForTesting);
} else if (mControllerListener != null) {
mDraweeControllerBuilder.setControllerListener(mControllerListener);
}
setController(mDraweeControllerBuilder.build());
mIsDirty = false;
}
示例6: maybeUpdateView
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入方法依赖的package包/类
public void maybeUpdateView() {
if (!mIsDirty) {
return;
}
boolean doResize = shouldResize(mUri);
if (doResize && (getWidth() <= 0 || getHeight() <=0)) {
// If need a resize and the size is not yet set, wait until the layout pass provides one
return;
}
GenericDraweeHierarchy hierarchy = getHierarchy();
hierarchy.setActualImageScaleType(mScaleType);
if (mLoadingImageDrawable != null) {
hierarchy.setPlaceholderImage(mLoadingImageDrawable, ScalingUtils.ScaleType.CENTER);
}
boolean usePostprocessorScaling =
mScaleType != ScalingUtils.ScaleType.CENTER_CROP &&
mScaleType != ScalingUtils.ScaleType.FOCUS_CROP;
RoundingParams roundingParams = hierarchy.getRoundingParams();
if (usePostprocessorScaling) {
roundingParams.setCornersRadius(0);
} else {
cornerRadii(sComputedCornerRadii);
roundingParams.setCornersRadii(sComputedCornerRadii[0], sComputedCornerRadii[1], sComputedCornerRadii[2], sComputedCornerRadii[3]);
}
roundingParams.setBorder(mBorderColor, mBorderWidth);
if (mOverlayColor != Color.TRANSPARENT) {
roundingParams.setOverlayColor(mOverlayColor);
} else {
// make sure the default rounding method is used.
roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
}
hierarchy.setRoundingParams(roundingParams);
hierarchy.setFadeDuration(
mFadeDurationMs >= 0
? mFadeDurationMs
: mIsLocalImage ? 0 : REMOTE_IMAGE_FADE_DURATION_MS);
Postprocessor postprocessor = usePostprocessorScaling ? mRoundedCornerPostprocessor : null;
ResizeOptions resizeOptions = doResize ? new ResizeOptions(getWidth(), getHeight()) : null;
ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri)
.setPostprocessor(postprocessor)
.setResizeOptions(resizeOptions)
.setAutoRotateEnabled(true)
.setProgressiveRenderingEnabled(mProgressiveRenderingEnabled)
.build();
// This builder is reused
mDraweeControllerBuilder.reset();
mDraweeControllerBuilder
.setAutoPlayAnimations(true)
.setCallerContext(mCallerContext)
.setOldController(getController())
.setImageRequest(imageRequest);
if (mControllerListener != null && mControllerForTesting != null) {
ForwardingControllerListener combinedListener = new ForwardingControllerListener();
combinedListener.addListener(mControllerListener);
combinedListener.addListener(mControllerForTesting);
mDraweeControllerBuilder.setControllerListener(combinedListener);
} else if (mControllerForTesting != null) {
mDraweeControllerBuilder.setControllerListener(mControllerForTesting);
} else if (mControllerListener != null) {
mDraweeControllerBuilder.setControllerListener(mControllerListener);
}
setController(mDraweeControllerBuilder.build());
mIsDirty = false;
}
示例7: maybeUpdateView
import com.facebook.drawee.generic.GenericDraweeHierarchy; //导入方法依赖的package包/类
public void maybeUpdateView() {
if (!mIsDirty) {
return;
}
boolean doResize = shouldResize(mUri);
if (doResize && (getWidth() <= 0 || getHeight() <= 0)) {
// If need a resize and the size is not yet set, wait until the layout pass provides one
return;
}
GenericDraweeHierarchy hierarchy = getHierarchy();
hierarchy.setActualImageScaleType(mScaleType);
if (mLoadingImageDrawable != null) {
hierarchy.setPlaceholderImage(mLoadingImageDrawable, ScalingUtils.ScaleType.CENTER);
}
boolean usePostprocessorScaling =
mScaleType != ScalingUtils.ScaleType.CENTER_CROP &&
mScaleType != ScalingUtils.ScaleType.FOCUS_CROP;
float hierarchyRadius = usePostprocessorScaling ? 0 : mBorderRadius;
RoundingParams roundingParams = hierarchy.getRoundingParams();
roundingParams.setCornersRadius(hierarchyRadius);
roundingParams.setBorder(mBorderColor, mBorderWidth);
if (mOverlayColor != Color.TRANSPARENT) {
roundingParams.setOverlayColor(mOverlayColor);
} else {
// make sure the default rounding method is used.
roundingParams.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY);
}
hierarchy.setRoundingParams(roundingParams);
hierarchy.setFadeDuration(
mFadeDurationMs >= 0
? mFadeDurationMs
: mIsLocalImage ? 0 : REMOTE_IMAGE_FADE_DURATION_MS);
Postprocessor postprocessor = usePostprocessorScaling ? mRoundedCornerPostprocessor : null;
ResizeOptions resizeOptions = doResize ? new ResizeOptions(getWidth(), getHeight()) : null;
ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(mUri)
.setPostprocessor(postprocessor)
.setResizeOptions(resizeOptions)
.setAutoRotateEnabled(true)
.setProgressiveRenderingEnabled(mProgressiveRenderingEnabled)
.build();
// This builder is reused
mDraweeControllerBuilder.reset();
mDraweeControllerBuilder
.setAutoPlayAnimations(true)
.setCallerContext(mCallerContext)
.setOldController(getController())
.setImageRequest(imageRequest);
if (mControllerListener != null && mControllerForTesting != null) {
ForwardingControllerListener combinedListener = new ForwardingControllerListener();
combinedListener.addListener(mControllerListener);
combinedListener.addListener(mControllerForTesting);
mDraweeControllerBuilder.setControllerListener(combinedListener);
} else if (mControllerForTesting != null) {
mDraweeControllerBuilder.setControllerListener(mControllerForTesting);
} else if (mControllerListener != null) {
mDraweeControllerBuilder.setControllerListener(mControllerListener);
}
setController(mDraweeControllerBuilder.build());
mIsDirty = false;
}