Java Code Examples for com.facebook.drawee.view.SimpleDraweeView#setHierarchy()
The following examples show how to use
com.facebook.drawee.view.SimpleDraweeView#setHierarchy() .
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: ShareLocationActivity.java From imsdk-android with MIT License | 5 votes |
private SimpleDraweeView createDraweeView() { SimpleDraweeView view = new SimpleDraweeView(this); RoundingParams params = RoundingParams.asCircle(); view.setLayoutParams(new ViewGroup.LayoutParams(Utils.dpToPx(this, 48), Utils.dpToPx(this, 48))); GenericDraweeHierarchy hierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources()) .setPlaceholderImage(getResources().getDrawable(R.drawable.atom_ui_default_gravatar), ScalingUtils.ScaleType.CENTER_CROP) .setRoundingParams(params) .build(); view.setHierarchy(hierarchy); return view; }
Example 2
Source File: FrescoController.java From base-module with Apache License 2.0 | 5 votes |
/** * 加载图片到 View 上,可设置回调监听 * @param draweeView * @param listener */ public void intoTarget(SimpleDraweeView draweeView, ControllerListener listener) { if ((mImageConfig != null && mImageConfig.useNewHierarchy) || !draweeView.hasHierarchy()) { GenericDraweeHierarchy hierarchy = GenericDraweeHierarchyBuilder .newInstance(draweeView.getResources()).build(); draweeView.setHierarchy(hierarchy); } parseImageConfig(draweeView.getHierarchy()); if (mUri != null) { ImageDecodeOptions imageDecodeOptions = ImageDecodeOptions.newBuilder() .setDecodePreviewFrame(true) .build(); ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(mUri) .setProgressiveRenderingEnabled(true) .setImageDecodeOptions(imageDecodeOptions); if (mWidth > 0 && mHeight > 0) { builder.setResizeOptions(new ResizeOptions(mWidth, mHeight)); } else { int width = draweeView.getMeasuredWidth(); int height = draweeView.getMeasuredHeight(); if(width > 0 && height > 0){ builder.setResizeOptions(new ResizeOptions(width, height)); } } ImageRequest request = builder.build(); AbstractDraweeController controller = Fresco.newDraweeControllerBuilder() .setImageRequest(request) .setControllerListener(listener) .setOldController(draweeView.getController()) .setAutoPlayAnimations(true) .build(); draweeView.setController(controller); } else { draweeView.setImageURI(""); } }
Example 3
Source File: ImageLoaderManager.java From AdPlayBanner with Apache License 2.0 | 5 votes |
/** * Fresco设置ScaleType * @param context 上下文 * @param mFrescoView 图片 */ private void frescoViewSetScaleType(Context context, SimpleDraweeView mFrescoView){ if (context == null || mFrescoView == null) { return; } GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(context.getResources()); GenericDraweeHierarchy hierarchy = builder.build(); mFrescoView.setHierarchy(hierarchy); switch (mScaleType) { default: case FIT_XY: hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_XY); break; case FIT_START: hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_START); break; case FIT_CENTER: hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER); break; case FIT_END: hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.FIT_END); break; case CENTER: hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.CENTER); break; case CENTER_CROP: hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP); break; case CENTER_INSIDE: hierarchy.setActualImageScaleType(ScalingUtils.ScaleType.CENTER_INSIDE); break; } }
Example 4
Source File: RecyclerDataAdapter.java From ListItemFold with MIT License | 5 votes |
public ViewHolder(View convertView) { super(convertView); myImageView = (SimpleDraweeView) convertView.findViewById(R.id.my_image_view); myTitle = (TextView) convertView.findViewById(R.id.my_title); myContent = (TextView) convertView.findViewById(R.id.my_content); GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(mContext.getResources()); GenericDraweeHierarchy hierarchy = builder .setFadeDuration(200) .setPlaceholderImage(new ColorDrawable(0xf2f2f2)) .setProgressBarImage(new CircularProgressDrawable()) .build(); myImageView.setHierarchy(hierarchy); convertView.setOnClickListener(this); }
Example 5
Source File: LocationHolder.java From actor-platform with GNU Affero General Public License v3.0 | 5 votes |
public LocationHolder(MessagesAdapter adapter, View itemView, Peer peer) { super(adapter, itemView, false); this.context = adapter.getMessagesFragment().getActivity(); COLOR_PENDING = ActorSDK.sharedActor().style.getConvMediaStatePendingColor(); COLOR_SENT = ActorSDK.sharedActor().style.getConvMediaStateSentColor(); COLOR_RECEIVED = ActorSDK.sharedActor().style.getConvMediaStateDeliveredColor(); COLOR_READ = ActorSDK.sharedActor().style.getConvMediaStateReadColor(); COLOR_ERROR = ActorSDK.sharedActor().style.getConvMediaStateErrorColor(); messageBubble = (FrameLayout) itemView.findViewById(R.id.bubbleContainer); // Content previewView = (SimpleDraweeView) itemView.findViewById(R.id.image); GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(context.getResources()); GenericDraweeHierarchy hierarchy = builder .setFadeDuration(200) .setRoundingParams(new RoundingParams() .setCornersRadius(Screen.dp(2)) .setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY)) .build(); previewView.setHierarchy(hierarchy); time = (TextView) itemView.findViewById(R.id.time); stateIcon = (TintImageView) itemView.findViewById(R.id.stateIcon); onConfigureViewHolder(); }
Example 6
Source File: PhotoHolder.java From actor-platform with GNU Affero General Public License v3.0 | 4 votes |
public PhotoHolder(MessagesAdapter adapter, View itemView, Peer peer) { super(adapter, itemView, false); this.context = adapter.getMessagesFragment().getActivity(); COLOR_PENDING = ActorSDK.sharedActor().style.getConvMediaStatePendingColor(); COLOR_SENT = ActorSDK.sharedActor().style.getConvMediaStateSentColor(); COLOR_RECEIVED = ActorSDK.sharedActor().style.getConvMediaStateDeliveredColor(); COLOR_READ = ActorSDK.sharedActor().style.getConvMediaStateReadColor(); COLOR_ERROR = ActorSDK.sharedActor().style.getConvMediaStateErrorColor(); messageBubble = (FrameLayout) itemView.findViewById(R.id.bubbleContainer); overlay = itemView.findViewById(R.id.photoOverlay); // Content previewView = (SimpleDraweeView) itemView.findViewById(R.id.image); GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(context.getResources()); GenericDraweeHierarchy hierarchy = builder .setFadeDuration(200) .setRoundingParams(new RoundingParams() .setCornersRadius(Screen.dp(2)) .setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY)) .build(); previewView.setHierarchy(hierarchy); animationController = new BaseControllerListener<ImageInfo>() { @Override public void onFinalImageSet( String id, ImageInfo imageInfo, Animatable anim) { PhotoHolder.this.anim = anim; playAnimation(); } }; fastThumbLoader = new FastThumbLoader(previewView); time = (TextView) itemView.findViewById(R.id.time); duration = (TextView) itemView.findViewById(R.id.duration); stateIcon = (TintImageView) itemView.findViewById(R.id.stateIcon); progressContainer = itemView.findViewById(R.id.progressBg); progressValue = (TextView) itemView.findViewById(R.id.progressValue); progressValue.setTextColor(ActorSDK.sharedActor().style.getTextPrimaryInvColor()); progressView = (CircularView) itemView.findViewById(R.id.progressView); progressView.setColor(Color.WHITE); progressIcon = (ImageView) itemView.findViewById(R.id.contentIcon); onConfigureViewHolder(); }
Example 7
Source File: MainActivity.java From Fresco with Apache License 2.0 | 4 votes |
private void initView() { //获取SimpleDraweeView sdv = (SimpleDraweeView) findViewById(R.id.main_sdv); //初始化多张背景图集合 List<Drawable> bgs = new ArrayList<Drawable>(); bgs.add(ContextCompat.getDrawable(this,R.mipmap.bg_zero)); bgs.add(ContextCompat.getDrawable(this,R.mipmap.bg_one)); bgs.add(ContextCompat.getDrawable(this,R.mipmap.bg_two)); //初始化多张叠加图集合 List<Drawable> overlays = new ArrayList<Drawable>(); overlays.add(ContextCompat.getDrawable(this,R.mipmap.overlay_one)); overlays.add(ContextCompat.getDrawable(this,R.mipmap.overlay_two)); overlays.add(ContextCompat.getDrawable(this, R.mipmap.overlay_three)); GenericDraweeHierarchy hierarchy = new GenericDraweeHierarchyBuilder(getResources()) //设置淡入淡出动画持续时间 .setFadeDuration(5000) //设置单张背景图 .setBackground(ContextCompat.getDrawable(this, R.mipmap.bg_zero)) //设置多张背景图 //.setBackgrounds(bgs) //设置单张叠加图 //.setOverlay(ContextCompat.getDrawable(this,R.mipmap.overlay_one)) //设置多张叠加图 //.setOverlays(overlays) //设置占位图及它的缩放类型 .setPlaceholderImage(ContextCompat.getDrawable(this, R.mipmap.icon_placeholder), ScalingUtils.ScaleType.FOCUS_CROP) //设置正在加载图及其缩放类型 .setProgressBarImage(ContextCompat.getDrawable(this, R.mipmap.icon_progress_bar), ScalingUtils.ScaleType.FOCUS_CROP) //设置失败图及其缩放类型 .setFailureImage(ContextCompat.getDrawable(this, R.mipmap.icon_failure), ScalingUtils.ScaleType.FOCUS_CROP) //设置重试图及其缩放类型 .setRetryImage(ContextCompat.getDrawable(this, R.mipmap.icon_retry), ScalingUtils.ScaleType.FOCUS_CROP) //构建 .build(); //设置GenericDraweeHierarchy sdv.setHierarchy(hierarchy); //构建Controller DraweeController controller = Fresco.newDraweeControllerBuilder() //设置点击重试是否开启 .setTapToRetryEnabled(true) //构建 .build(); //设置Controller sdv.setController(controller); //开始下载 sdv.setImageURI(imageUrl); }
Example 8
Source File: MainActivity.java From Fresco with Apache License 2.0 | 4 votes |
private void initView() { //获取SimpleDraweeView sdv = (SimpleDraweeView) findViewById(R.id.main_sdv); //初始化圆角圆形参数对象 RoundingParams rp = new RoundingParams(); //设置图像是否为圆形 rp.setRoundAsCircle(true); //设置圆角半径 //rp.setCornersRadius(20); //分别设置左上角、右上角、左下角、右下角的圆角半径 //rp.setCornersRadii(20,25,30,35); //分别设置(前2个)左上角、(3、4)右上角、(5、6)左下角、(7、8)右下角的圆角半径 //rp.setCornersRadii(new float[]{20,25,30,35,40,45,50,55}); //设置边框颜色及其宽度 rp.setBorder(Color.BLACK, 10); //设置叠加颜色 rp.setOverlayColor(Color.GRAY); //设置圆形圆角模式 //rp.setRoundingMethod(RoundingParams.RoundingMethod.BITMAP_ONLY); //设置圆形圆角模式 rp.setRoundingMethod(RoundingParams.RoundingMethod.OVERLAY_COLOR); //获取GenericDraweeHierarchy对象 GenericDraweeHierarchy hierarchy = GenericDraweeHierarchyBuilder.newInstance(getResources()) //设置圆形圆角参数 .setRoundingParams(rp) //设置圆角半径 //.setRoundingParams(RoundingParams.fromCornersRadius(20)) //分别设置左上角、右上角、左下角、右下角的圆角半径 //.setRoundingParams(RoundingParams.fromCornersRadii(20,25,30,35)) //分别设置(前2个)左上角、(3、4)右上角、(5、6)左下角、(7、8)右下角的圆角半径 //.setRoundingParams(RoundingParams.fromCornersRadii(new float[]{20,25,30,35,40,45,50,55})) //设置圆形圆角参数;RoundingParams.asCircle()是将图像设置成圆形 //.setRoundingParams(RoundingParams.asCircle()) //设置淡入淡出动画持续时间(单位:毫秒ms) .setFadeDuration(5000) //构建 .build(); //设置Hierarchy sdv.setHierarchy(hierarchy); //构建Controller DraweeController controller = Fresco.newDraweeControllerBuilder() //设置需要下载的图片地址 .setUri(imageUrl) //设置点击重试是否开启 .setTapToRetryEnabled(true) //构建 .build(); //设置Controller sdv.setController(controller); }