Java Code Examples for com.facebook.drawee.view.SimpleDraweeView#setController()
The following examples show how to use
com.facebook.drawee.view.SimpleDraweeView#setController() .
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: ImageFormatOverrideExample.java From fresco with MIT License | 6 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view); ImageDecodeOptions imageDecodeOptionsWithCustomDecoder = new ImageDecodeOptionsBuilder().setCustomImageDecoder(CUSTOM_COLOR_DECODER).build(); AbstractDraweeController controller = Fresco.newDraweeControllerBuilder() .setImageRequest( ImageRequestBuilder.newBuilderWithResourceId(R.raw.custom_color1) .setImageDecodeOptions(imageDecodeOptionsWithCustomDecoder) .build()) .build(); simpleDraweeView.setController(controller); }
Example 2
Source File: BindingSetters.java From materialup with Apache License 2.0 | 6 votes |
@BindingAdapter({"bind:normalUrl", "bind:teaserUrl"}) public static void loadImage(SimpleDraweeView view, String normal, String teaser) { ImageRequest imageRequest = ImageRequest.fromUri(normal); ImageRequest lowRequest = null; if (!TextUtils.isEmpty(teaser)) { lowRequest = ImageRequest.fromUri(teaser); } DraweeController draweeController = Fresco.newDraweeControllerBuilder() .setImageRequest(imageRequest) .setLowResImageRequest(lowRequest) .setOldController(view.getController()) .setAutoPlayAnimations(true) .build(); view.setController(draweeController); }
Example 3
Source File: ForumListAdapter.java From SprintNBA with Apache License 2.0 | 6 votes |
@Override protected void onBindData(EasyRVHolder viewHolder, final int position, final ForumsData.Forum item) { if (!item.fid.equals("0")) { viewHolder.setText(R.id.tvTeamFullName, item.name); SimpleDraweeView ivTeamLogo = viewHolder.getView(R.id.ivTeamLogo); ivTeamLogo.setController(FrescoUtils.getController(item.logo, ivTeamLogo)); } else { viewHolder.setText(R.id.tvForumName, item.name); } viewHolder.getItemView().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (listener != null && !item.fid.equals("0")) listener.onItemClick(v, position, item); } }); helper.showItemAnim(viewHolder.getItemView(), position); }
Example 4
Source File: VideoListCell.java From YcShareElement with Apache License 2.0 | 6 votes |
public void showWebp(final SimpleDraweeView simpleDraweeView, final String url, boolean autoplay) { simpleDraweeView.getHierarchy().setBackgroundImage(new ColorDrawable(Color.GRAY)); simpleDraweeView.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.CENTER_CROP); DraweeController controller = Fresco.newDraweeControllerBuilder() .setOldController(simpleDraweeView.getController()) .setControllerListener(new DeliveryControllerListener<ImageInfo>(null) { @Override public void onFinalImageSet(String s, @Nullable ImageInfo imageInfo, @Nullable Animatable animatable) { super.onFinalImageSet(s, imageInfo, animatable); simpleDraweeView.getHierarchy().setBackgroundImage(null); } }) .setAutoPlayAnimations(autoplay) .setUri(url) .build(); simpleDraweeView.setController(controller); }
Example 5
Source File: ImagePipelineRegionDecodingFragment.java From fresco with MIT License | 6 votes |
@Override public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) { mUri = sampleUris() .createSampleUri(ImageUriProvider.ImageSize.L, ImageUriProvider.Orientation.LANDSCAPE); mFullDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view_full); mFullDraweeView.setController( Fresco.newDraweeControllerBuilder() .setUri(mUri) .setControllerListener(mControllerListener) .build()); mSelectedRegion = (ResizableFrameLayout) view.findViewById(R.id.frame_main); mSelectedRegion.init(view.findViewById(R.id.btn_resize)); mSelectedRegion.setSizeChangedListener(mSizeChangedListener); mRegionDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view_region); mRegionDraweeView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { updateRegion(); } }); }
Example 6
Source File: CanPhotoHelper.java From CanPhotos with Apache License 2.0 | 6 votes |
/** * 设置图片 * * @param image * @param url * @param width * @param heigth */ public void setDraweeImage(SimpleDraweeView image, String url, int width, int heigth) { if (width <= 0) { width = dp2Px(image.getContext(), 50); } if (heigth <= 0) { heigth = dp2Px(image.getContext(), 50); } ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url)).setLocalThumbnailPreviewsEnabled(true).setResizeOptions(new ResizeOptions(width, heigth)).build(); DraweeController draweeController = Fresco.newDraweeControllerBuilder() .setImageRequest(imageRequest) .setAutoPlayAnimations(true) .build(); image.setController(draweeController); }
Example 7
Source File: SingleImageInterceptor.java From Flora with MIT License | 6 votes |
private void load(Uri uri, SimpleDraweeView draweeView, int width, int height) { ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri) .setResizeOptions(new ResizeOptions(width, height)) .setProgressiveRenderingEnabled(true) .setAutoRotateEnabled(true) .build(); PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder() .setImageRequest(request) .setOldController(draweeView.getController()) .setAutoPlayAnimations(true) .build(); draweeView.setController(controller); }
Example 8
Source File: ImageFormatKeyframesFragment.java From fresco with MIT License | 6 votes |
@RequiresApi(api = Build.VERSION_CODES.HONEYCOMB) private void initAnimation(View view) { mSimpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view); mSimpleDraweeView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); DraweeController controller = Fresco.newDraweeControllerBuilder() .setOldController(mSimpleDraweeView.getController()) .setUri(sampleUris().createKeyframesUri()) .setAutoPlayAnimations(true) .build(); mSimpleDraweeView.setController(controller); final SwitchCompat switchBackground = (SwitchCompat) view.findViewById(R.id.switch_background); switchBackground.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mSimpleDraweeView .getHierarchy() .setBackgroundImage(isChecked ? new CheckerBoardDrawable(getResources()) : null); } }); }
Example 9
Source File: FrescoImageloadHelper.java From nono-android with GNU General Public License v3.0 | 6 votes |
public static void LoadImageFromURLAndCallBack(SimpleDraweeView destImageView , String URL,Context context,BaseBitmapDataSubscriber bbds) { int w = destImageView.getWidth(); int h =destImageView.getHeight(); if(w<1){ w = destImageView.getLayoutParams().width; } if(h<1){ h =destImageView.getLayoutParams().height; } ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(URL)) .setResizeOptions(new ResizeOptions(w,h)) .setProgressiveRenderingEnabled(true) .build(); ImagePipeline imagePipeline = Fresco.getImagePipeline(); DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, context); dataSource.subscribe(bbds, CallerThreadExecutor.getInstance()); DraweeController draweeController = Fresco.newDraweeControllerBuilder() .setImageRequest(imageRequest) .setOldController(destImageView.getController()) .setAutoPlayAnimations(true) .build(); destImageView.setController(draweeController); }
Example 10
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 11
Source File: PartialRequestFragment.java From fresco with MIT License | 5 votes |
private void loadImageIntoDrawee(SimpleDraweeView draweeView, @Nullable BytesRange bytesRange) { final ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource( sampleUris().createSampleUri(ImageUriProvider.ImageSize.L)) .setBytesRange(bytesRange) .build(); final DraweeController draweeController = Fresco.newDraweeControllerBuilder() .setOldController(draweeView.getController()) .setImageRequest(imageRequest) .build(); draweeView.setController(draweeController); }
Example 12
Source File: FrescoLoader.java From ImageLoader with Apache License 2.0 | 5 votes |
private void requestForSimpleDraweeView(SimpleDraweeView target, SingleConfig config) { // 数据-model ImageRequest request = buildRequest(config); //view setDraweeHierarchyForDraweeView(config); //controller PipelineDraweeControllerBuilder controller = buildPipelineDraweeController(config,request); controller.setOldController(target.getController()); target.setController(controller.build()); }
Example 13
Source File: DraweeHierarchyFragment.java From fresco with MIT License | 5 votes |
private void setUri(SimpleDraweeView draweeView, Uri uri, boolean retryEnabled) { draweeView.setController( Fresco.newDraweeControllerBuilder() .setOldController(draweeView.getController()) .setTapToRetryEnabled(retryEnabled) .setUri(uri) .build()); }
Example 14
Source File: MainActivity.java From AndroidPlayground with MIT License | 5 votes |
private void showGif() { Uri uri = Uri.parse("http://d.hiphotos.baidu" + ".com/zhidao/pic/item/0d338744ebf81a4c6a74d7cdd42a6059252da66b.jpg"); SimpleDraweeView draweeView = (SimpleDraweeView) findViewById(R.id.my_image_view); DraweeController controller = Fresco.newDraweeControllerBuilder().setUri(uri).setAutoPlayAnimations(true).build(); draweeView.setController(controller); }
Example 15
Source File: FeedAdapter.java From Flora with MIT License | 5 votes |
private void load(Uri uri, SimpleDraweeView draweeView, int width, int height) { ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri) .setResizeOptions(new ResizeOptions(width, height)) .setProgressiveRenderingEnabled(true) .setAutoRotateEnabled(true) .build(); PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder() .setImageRequest(request) .setOldController(draweeView.getController()) .setAutoPlayAnimations(true) .build(); draweeView.setController(controller); }
Example 16
Source File: MatchLMaxPlayerdapter.java From SprintNBA with Apache License 2.0 | 5 votes |
@Override public void convert(EasyLVHolder viewHolder, int position, MatchStat.MaxPlayers item) { viewHolder.setText(R.id.tvLeftPlayerName, item.leftPlayer.name) .setText(R.id.tvLeftPlayerType, item.leftPlayer.position + " #" + item.rightPlayer.jerseyNum) .setText(R.id.tvRightPlayerName, item.rightPlayer.name) .setText(R.id.tvRightPlayerType, item.rightPlayer.position + " #" + item.rightPlayer.jerseyNum) .setText(R.id.tvType, item.text); SimpleDraweeView ivLeft = viewHolder.getView(R.id.ivLeftPlayerIcon); ivLeft.setController(FrescoUtils.getController(item.leftPlayer.icon, ivLeft)); SimpleDraweeView ivRight = viewHolder.getView(R.id.ivRightPlayerIcon); ivRight.setController(FrescoUtils.getController(item.rightPlayer.icon, ivRight)); }
Example 17
Source File: TeamsListAdapter.java From SprintNBA with Apache License 2.0 | 5 votes |
@Override public void convert(EasyLVHolder viewHolder, final int position, final Teams.TeamsBean.Team team) { viewHolder.setText(R.id.tvTeamFullName, team.fullCnName); SimpleDraweeView iv = viewHolder.getView(R.id.ivTeamLogo); iv.setController(FrescoUtils.getController(team.logo, iv)); viewHolder.getConvertView().setOnClickListener(new NoDoubleClickListener() { @Override protected void onNoDoubleClick(View view) { if (listener != null) listener.onItemClick(view, position, team); } }); }
Example 18
Source File: ImageFormatWebpFragment.java From fresco with MIT License | 4 votes |
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { final SimpleDraweeView draweeWebpStatic = view.findViewById(R.id.drawee_view_webp_static); draweeWebpStatic.setImageURI(sampleUris().createWebpStaticUri()); final SimpleDraweeView draweeWebpTranslucent = view.findViewById(R.id.drawee_view_webp_translucent); draweeWebpTranslucent.setImageURI(sampleUris().createWebpTranslucentUri()); final SwitchCompat switchBackground = view.findViewById(R.id.switch_background); switchBackground.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { draweeWebpTranslucent .getHierarchy() .setBackgroundImage(isChecked ? new CheckerBoardDrawable(getResources()) : null); } }); final SimpleDraweeView draweeWebpAnimated = view.findViewById(R.id.drawee_view_webp_animated); draweeWebpAnimated.setController( Fresco.newDraweeControllerBuilder() .setAutoPlayAnimations(true) .setOldController(draweeWebpAnimated.getController()) .setUri(sampleUris().createWebpAnimatedUri()) .build()); final TextView supportStatusTextView = view.findViewById(R.id.text_webp_support_status); final StringBuilder sb = new StringBuilder(); sb.append("WebpSupportStatus.sIsSimpleWebpSupported = ") .append(WebpSupportStatus.sIsSimpleWebpSupported) .append('\n'); sb.append("WebpSupportStatus.sIsExtendedWebpSupported = ") .append(WebpSupportStatus.sIsExtendedWebpSupported) .append('\n'); sb.append("WebpSupportStatus.sIsWebpSupportRequired = ") .append(WebpSupportStatus.sIsWebpSupportRequired) .append('\n'); supportStatusTextView.setText(sb.toString()); }
Example 19
Source File: ScheduleAdapter.java From SprintNBA with Apache License 2.0 | 4 votes |
@Override protected void onBindData(final EasyRVHolder viewHolder, final int position, final Matchs.MatchsDataBean.MatchesBean item) { Matchs.MatchsDataBean.MatchesBean.MatchInfoBean matchInfo = item.matchInfo; SimpleDraweeView ivLeft = viewHolder.getView(R.id.ivLeftTeam); ivLeft.setController(FrescoUtils.getController(matchInfo.leftBadge, ivLeft)); SimpleDraweeView ivRight = viewHolder.getView(R.id.ivRightTeam); ivRight.setController(FrescoUtils.getController(matchInfo.rightBadge, ivRight)); String status; if (((matchInfo.quarter.contains("第4节") || matchInfo.quarter.contains("加时")) && !matchInfo.leftGoal.equals(matchInfo.rightGoal)) && matchInfo.quarterTime.contains("00:00")) { status = "已结束"; } else if (matchInfo.quarter.equals("") && matchInfo.quarterTime.equals("12:00")) { status = matchInfo.startTime; } else { status = matchInfo.quarter + " " + matchInfo.quarterTime; } String broadcasters = ""; if (matchInfo.broadcasters != null) { for (String str : matchInfo.broadcasters) { broadcasters += str + "/"; } } if (broadcasters.length() > 1) { broadcasters = broadcasters.substring(0, broadcasters.length() - 1); } viewHolder.setText(R.id.tvLeftTeam, matchInfo.leftName) .setText(R.id.tvRightTeam, matchInfo.rightName) .setText(R.id.tvMatchStatus, status) .setText(R.id.tvLeftTeamPoint, matchInfo.leftGoal) .setText(R.id.tvRightTeamPoint, matchInfo.rightGoal) .setText(R.id.tvMatchDesc, matchInfo.matchDesc) .setText(R.id.tvBroadcasters, broadcasters); viewHolder.getItemView().setOnClickListener(new NoDoubleClickListener() { @Override protected void onNoDoubleClick(View view) { if (mOnItemClickListener != null) mOnItemClickListener.onItemClick(viewHolder.getItemView(), position, item); } }); helper.showItemAnim(viewHolder.getItemView(), position); }
Example 20
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); }