Java 类com.facebook.imagepipeline.image.ImageInfo 实例源码

项目:RunMap    文件:SplashActivity.java   
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    ButterKnife.bind(this);
    Uri uri = Uri.parse("asset:///splash.webp");
    mSplashPresenter = new SplashPresenterImpl(this);
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setUri(uri)
            .setAutoPlayAnimations(true)
            .setControllerListener(new BaseControllerListener<ImageInfo>(){
                @Override
                public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable animatable) {
                    super.onFinalImageSet(id, imageInfo, animatable);
                    mSplashPresenter.startCountDown(1);
                }
            })
            .build();
    splashDraweee.setController(controller);
}
项目:react-native-udesk    文件:UdeskUtil.java   
public static void loadImage(final PhotoDraweeView mPhotoDraweeView,
                             Uri uri) {
    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setUri(uri);
    controller.setAutoPlayAnimations(true);
    controller.setOldController(mPhotoDraweeView.getController());
    controller.setControllerListener(new BaseControllerListener<ImageInfo>() {
        @Override
        public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            super.onFinalImageSet(id, imageInfo, animatable);
            if (imageInfo == null || mPhotoDraweeView == null) {
                return;
            }
            mPhotoDraweeView.update(imageInfo.getWidth(), imageInfo.getHeight());
        }
    });
    mPhotoDraweeView.setController(controller.build());
}
项目:android-photo-picker    文件:PhotoDraweeView.java   
public void loadImage(String url,String lowurl, int placeHolderResId, int errorResId,ScalingUtils.ScaleType scaleType){
    final boolean isHttp = url.startsWith("http");
    Uri uri = isHttp ? Uri.parse(url) :  Uri.fromFile(new File(url));
    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder()
         .setImageRequest(ImageRequest.fromUri(uri));
    if(lowurl!=null &&  lowurl.startsWith("http")) {
        controller .setLowResImageRequest(ImageRequest.fromUri(lowurl));
    }
    getHierarchy().setActualImageScaleType(scaleType);
                    // controller.setUri(URI);
    getHierarchy().setPlaceholderImage(getResources().getDrawable( placeHolderResId ),scaleType);
    getHierarchy().setFailureImage(getResources().getDrawable(errorResId),scaleType);
    controller.setOldController(this.getController())
         .setControllerListener(new BaseControllerListener<ImageInfo>() {
             @Override
             public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
                 if (imageInfo == null) {
                     return;
                 }
                 PhotoDraweeView.this.update(imageInfo.getWidth(), imageInfo.getHeight());
             }
         });
    this.setController(controller.build());
}
项目:Li-MVPArms    文件:FrescoHelper.java   
/**
     * 图像选项类
     * @param uri 图片路径
     * @param oldController DraweeView.getoldcontroller
     * @param controllerListener 监听
     * @return
     */
    public static DraweeController getImageViewController(String uri, DraweeController oldController,
            ControllerListener<ImageInfo> controllerListener) {
        PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder();
        if (!TextUtils.isEmpty(uri)) {
//          Logger.d("StringUtils.utf8Encode(uri)"+StringUtils.utf8Encode(uri));
            builder.setUri(Uri.parse(uri));
        }
        if (oldController != null) {
            builder.setOldController(oldController);
        }
        if (controllerListener != null) {
            builder.setControllerListener(controllerListener);
        }
        return builder.build();
    }
项目:android-base    文件:FrescoUtils.java   
/**
 * showThumb
 *
 * @param draweeView     draweeView
 * @param url            url
 * @param resizeWidthDp  resizeWidth
 * @param resizeHeightDp resizeHeight
 */
public static void showThumb(SimpleDraweeView draweeView, String url, int resizeWidthDp, int resizeHeightDp) {
    try {
        if (!isInit)
            return;
        if (url == null || "".equals(url))
            return;
        if (draweeView == null)
            return;
        initialize(draweeView.getContext());
        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
                .setResizeOptions(new ResizeOptions(DimenUtils.dip2px(draweeView.getContext(), resizeWidthDp), DimenUtils.dip2px(draweeView.getContext(), resizeHeightDp)))
                .build();
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setImageRequest(request)
                .setOldController(draweeView.getController())
                .setControllerListener(new BaseControllerListener<ImageInfo>())
                .build();
        draweeView.setController(controller);
    } catch (Exception e) {
    }
}
项目:miku    文件:ImageUtils.java   
public static DraweeController showResGif(int resourceId, SimpleDraweeView simpleDraweeView) {
    ControllerListener controllerListener = new BaseControllerListener<ImageInfo>() {
        @Override
        public void onFinalImageSet(
                String id,
                @Nullable ImageInfo imageInfo,
                @Nullable Animatable anim) {
            if (anim != null) {
                anim.start();
            }
        }
    };

    Uri uri = Uri.parse("res://com.blinnnk.gaia/" + resourceId);
    DraweeController draweeController = Fresco.newDraweeControllerBuilder()
            .setUri(uri)
            .setControllerListener(controllerListener)
            .build();
    simpleDraweeView.setController(draweeController);
    return draweeController;
}
项目:Elephant    文件:PhotoShowActivity.java   
@Override
public void initLoad() {
    super.initLoad();

    if (!TextUtils.isEmpty(mImageUrl)) {
        PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
        controller.setUri(mImageUrl);
        controller.setOldController(mPhotoIv.getController());
        controller.setControllerListener(new BaseControllerListener<ImageInfo>() {
            @Override
            public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
                super.onFinalImageSet(id, imageInfo, animatable);
                if (imageInfo == null || mPhotoIv == null) {
                    return;
                }
                mPhotoIv.update(imageInfo.getWidth(), imageInfo.getHeight());
            }
        });
        mPhotoIv.setController(controller.build());
    }
}
项目:android-jungle-framework    文件:FrescoImageLoaderEngine.java   
private DraweeController createDraweeController(
        DraweeView draweeView, Uri uri, ControllerListener<ImageInfo> listener) {

    JungleSize size = ImageLoaderUtils.getAppropriateSize(draweeView);
    ImageRequest request = ImageRequestBuilder
            .newBuilderWithSource(uri)
            .setResizeOptions(new ResizeOptions(size.mWidth, size.mHeight))
            .setAutoRotateEnabled(true)
            .build();

    return Fresco.newDraweeControllerBuilder()
            .setUri(uri)
            .setImageRequest(request)
            .setControllerListener(listener)
            .setAutoPlayAnimations(true)
            .setOldController(draweeView.getController())
            .build();
}
项目:ImageLoaders    文件:MainActivity.java   
private void loadByFresco(String url) {
    Uri uri = Uri.parse(url);
    ControllerListener listener = new BaseControllerListener<ImageInfo>() {
        @Override
        public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            super.onFinalImageSet(id, imageInfo, animatable);
            Log.d(TAG, "Fresco----->onFinalImageSet: " + LogTime.getElapsedMillis(startTimeFresco) + "ms");
            textFresco.setText(getString(R.string.text_load_time, "Fresco", String.format("%.6f", LogTime.getElapsedMillis(startTimeFresco))));

        }
    };
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setControllerListener(listener)
            .setUri(uri)
            .build();
    imgFresco.setController(controller);
}
项目:AndroidImageSelect    文件:PhotoDraweeViewUtil.java   
public static void display(final PhotoDraweeView draweeView, Uri uri) {
    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setUri(uri);
    controller.setOldController(draweeView.getController());
    controller.setControllerListener(new BaseControllerListener<ImageInfo>() {
        @Override
        public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            super.onFinalImageSet(id, imageInfo, animatable);
            if (imageInfo == null || draweeView == null) {
                return;
            }
            draweeView.update(imageInfo.getWidth(), imageInfo.getHeight());
        }
    });
    draweeView.setController(controller.build());
}
项目:SneezeReader    文件:ArticleAdapter.java   
/**
 * 更新图片的尺寸
 * @param imageView
 * @param imageInfo
 */
private void updateImageSize(SimpleDraweeView imageView, ImageInfo imageInfo){

    if(imageInfo != null){
        Log.d(TAG, "ImageInfo: width=" + imageInfo.getWidth() + ", height=" + imageInfo.getHeight());

        ViewGroup.LayoutParams lp = imageView.getLayoutParams();
        final int imageWidth = imageView.getMeasuredWidth();
        final int imageHeight = imageView.getMeasuredHeight();

        lp.width = imageWidth;
        lp.height = imageWidth * imageInfo.getHeight() / imageInfo.getWidth();

        imageView.setLayoutParams(lp);
        imageView.setAspectRatio((float)imageInfo.getWidth() / imageInfo.getHeight());
    }

}
项目:phphub-android    文件:GalleryActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String imageUrl = getIntent().getStringExtra(IMAGE_URL);
    if (!TextUtils.isEmpty(imageUrl)) {
        PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder();
        builder.setUri(Uri.parse(imageUrl));
        builder.setOldController(photoView.getController());
        builder.setControllerListener(new BaseControllerListener<ImageInfo>() {
            @Override
            public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
                super.onFinalImageSet(id, imageInfo, animatable);
                if (imageInfo == null || photoView == null) {
                    return;
                }
                photoView.update(imageInfo.getWidth(), imageInfo.getHeight());
            }
        });
        photoView.setController(builder.build());
    }
}
项目:meiShi    文件:MediasAdapter.java   
@Override
public void onBindItemViewHolder(final ViewHolder holder, final int position) {
    MediaEntity entity = getItem(position);
    holder.mImageViewCover.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onItemClickListener.onItemClick(getItem(position));
        }
    });
    holder.mTextViewLikesCount.setTextImageStart(18, R.mipmap.ic_thumb_up_gray_18dp, " " + entity.getLikes_count());
    holder.mTextViewRecommendCaption.setText(entity.getCaption());

    String url = entity.getCover_pic().replace("!thumb320", "");
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setControllerListener(new BaseControllerListener<ImageInfo>() {
                @Override
                public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
                    float aspectRatio = (float)imageInfo.getWidth() / (float)imageInfo.getHeight();
                    holder.mImageViewCover.setAspectRatio(aspectRatio);
                }
            })
            .setUri(Uri.parse(url))
            .build();
    holder.mImageViewCover.setController(controller);
    AppUtils.loadSmallUserAvata(getItem(position).getUser(), holder.mImageViewAvatar);
}
项目:ImageLoaders    文件:MainActivity.java   
private void loadByFresco(String url) {
    Uri uri = Uri.parse(url);
    ControllerListener listener = new BaseControllerListener<ImageInfo>() {
        @Override
        public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            super.onFinalImageSet(id, imageInfo, animatable);
            Log.d(TAG, "Fresco----->onFinalImageSet: " + LogTime.getElapsedMillis(startTimeFresco) + "ms");
            textFresco.setText(getString(R.string.text_load_time, "Fresco", String.format("%.6f", LogTime.getElapsedMillis(startTimeFresco))));

        }
    };
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setControllerListener(listener)
            .setUri(uri)
            .build();
    imgFresco.setController(controller);
}
项目:GitHub    文件:DraweeSpanStringBuilder.java   
@Override
public void onFinalImageSet(
    String id,
    ImageInfo imageInfo,
    Animatable animatable) {
  if (mEnableResizing &&
      imageInfo != null &&
      mDraweeSpan.getDraweeHolder().getTopLevelDrawable() != null) {
    Drawable topLevelDrawable = mDraweeSpan.getDraweeHolder().getTopLevelDrawable();
    Rect topLevelDrawableBounds = topLevelDrawable.getBounds();
    if (mFixedHeight != UNSET_SIZE) {
      float imageWidth = ((float) mFixedHeight / imageInfo.getHeight()) * imageInfo.getWidth();
      int imageWidthPx = (int) imageWidth;
      if (topLevelDrawableBounds.width() != imageWidthPx ||
          topLevelDrawableBounds.height() != mFixedHeight) {
        topLevelDrawable.setBounds(0, 0, imageWidthPx, mFixedHeight);

        if (mDraweeSpanChangedListener != null) {
          mDraweeSpanChangedListener.onDraweeSpanChanged(DraweeSpanStringBuilder.this);
        }
      }
    } else if (topLevelDrawableBounds.width() != imageInfo.getWidth() ||
        topLevelDrawableBounds.height() != imageInfo.getHeight()) {
      topLevelDrawable.setBounds(0, 0, imageInfo.getWidth(), imageInfo.getHeight());

      if (mDraweeSpanChangedListener != null) {
        mDraweeSpanChangedListener.onDraweeSpanChanged(DraweeSpanStringBuilder.this);
      }
    }
  }
}
项目:TakeRest    文件:PhotoViewActivity.java   
@Override
protected void init() {
    super.init();
    transparentStatusBar();
    ButterKnife.bind(this);
    url = getIntent().getStringExtra("url");
    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
    controller.setUri(Uri.parse(url));
    controller.setAutoPlayAnimations(true);
    controller.setOldController(photoDraweeView.getController());
    controller.setControllerListener(new BaseControllerListener<ImageInfo>() {
        @Override
        public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
            super.onFinalImageSet(id, imageInfo, animatable);
            if (imageInfo == null || photoDraweeView == null) {
                return;
            }
            photoDraweeView.update(imageInfo.getWidth(), imageInfo.getHeight());
            normalScale = photoDraweeView.getScale();
        }
    });
    photoDraweeView.setController(controller.build());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        String name = getIntent().getStringExtra("transition_name");
        photoDraweeView.setTransitionName(name);
        getWindow().setSharedElementEnterTransition(DraweeTransition.createTransitionSet(
                ScalingUtils.ScaleType.CENTER_CROP, ScalingUtils.ScaleType.FIT_CENTER));
        getWindow().setSharedElementReturnTransition(DraweeTransition.createTransitionSet(
                ScalingUtils.ScaleType.FIT_CENTER, ScalingUtils.ScaleType.CENTER_CROP));
    }
}
项目:cardinalsSample    文件:FrescoManager.java   
/**
 * 改变图片的尺寸
 *
 * @param imageInfo 获取的图片信息
 * @param maxWidth  可显示的最大宽度
 * @param view      图片对象
 */
private static void changeImageSize(ImageInfo imageInfo, int maxWidth, SimpleDraweeView view) {
    int height = imageInfo.getHeight();
    int width = imageInfo.getWidth();
    float scaleWidth = (float) maxWidth / width;
    int realHeight = (int) (height * scaleWidth);
    int realWidth = (int) (width * scaleWidth);
    ViewGroup.LayoutParams params = view.getLayoutParams();
    params.height = realHeight;
    params.width = realWidth;
    view.setLayoutParams(params);
}
项目:react-native-android-bottom-navigation    文件:RNBottomNavigation.java   
@Override
public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable animatable) {
    super.onFinalImageSet(id, imageInfo, animatable);

    final ImageInfo info = mIconImageInfo != null ? mIconImageInfo : imageInfo;
    setDrawable(new DrawableWithIntrinsicSize(mHolder.getTopLevelDrawable(), info));
}
项目:react-native-udesk    文件:UdeskUtil.java   
public static void loadFileFromSdcard(final Context context, final SimpleDraweeView draweeView, Uri loackUri, final int reqWidth, final int reqHeight) {
    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(loackUri)
            .setRotationOptions(RotationOptions.autoRotate())
            .setLocalThumbnailPreviewsEnabled(true)
            .setResizeOptions(new ResizeOptions(dip2px(context, 140), dip2px(context, 220)))
            .build();
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setImageRequest(request)
            .setOldController(draweeView.getController())
            .setTapToRetryEnabled(true)
            .setControllerListener(new BaseControllerListener<ImageInfo>() {
                @Override
                public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable anim) {
                    if (imageInfo == null) {
                        return;
                    }

                    ViewGroup.LayoutParams layoutParams = draweeView.getLayoutParams();
                    int width = reqWidth;
                    int height = reqHeight;
                    int imgWidth = dip2px(context, 140);
                    int imgHight = dip2px(context, 220);
                    int bitScalew = getRatioSize(width, height, imgHight, imgWidth);
                    layoutParams.height = height / bitScalew;
                    layoutParams.width = width / bitScalew;
                    draweeView.requestLayout();
                }
            })
            .setAutoPlayAnimations(true)
            .build();
    draweeView.setController(controller);
}
项目:RNLearn_Project1    文件:ReactToolbar.java   
@Override
public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable animatable) {
  super.onFinalImageSet(id, imageInfo, animatable);

  final ImageInfo info = mIconImageInfo != null ? mIconImageInfo : imageInfo;
  setDrawable(new DrawableWithIntrinsicSize(mHolder.getTopLevelDrawable(), info));
}
项目:RNLearn_Project1    文件:ReactImageView.java   
public void setShouldNotifyLoadEvents(boolean shouldNotify) {
  if (!shouldNotify) {
    mControllerListener = null;
  } else {
    final EventDispatcher mEventDispatcher = ((ReactContext) getContext()).
        getNativeModule(UIManagerModule.class).getEventDispatcher();

    mControllerListener = new BaseControllerListener<ImageInfo>() {
      @Override
      public void onSubmit(String id, Object callerContext) {
        mEventDispatcher.dispatchEvent(
            new ImageLoadEvent(getId(), ImageLoadEvent.ON_LOAD_START));
      }

      @Override
      public void onFinalImageSet(
          String id,
          @Nullable final ImageInfo imageInfo,
          @Nullable Animatable animatable) {
        if (imageInfo != null) {
          mEventDispatcher.dispatchEvent(
            new ImageLoadEvent(getId(), ImageLoadEvent.ON_LOAD,
              mImageSource.getSource(), imageInfo.getWidth(), imageInfo.getHeight()));
          mEventDispatcher.dispatchEvent(
            new ImageLoadEvent(getId(), ImageLoadEvent.ON_LOAD_END));
        }
      }

      @Override
      public void onFailure(String id, Throwable throwable) {
        mEventDispatcher.dispatchEvent(
          new ImageLoadEvent(getId(), ImageLoadEvent.ON_ERROR));
        mEventDispatcher.dispatchEvent(
          new ImageLoadEvent(getId(), ImageLoadEvent.ON_LOAD_END));
      }
    };
  }

  mIsDirty = true;
}
项目:RNLearn_Project1    文件:ReactToolbar.java   
@Override
public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable animatable) {
  super.onFinalImageSet(id, imageInfo, animatable);

  final ImageInfo info = mIconImageInfo != null ? mIconImageInfo : imageInfo;
  setDrawable(new DrawableWithIntrinsicSize(mHolder.getTopLevelDrawable(), info));
}
项目:RNLearn_Project1    文件:ReactImageView.java   
public void setShouldNotifyLoadEvents(boolean shouldNotify) {
  if (!shouldNotify) {
    mControllerListener = null;
  } else {
    final EventDispatcher mEventDispatcher = ((ReactContext) getContext()).
        getNativeModule(UIManagerModule.class).getEventDispatcher();

    mControllerListener = new BaseControllerListener<ImageInfo>() {
      @Override
      public void onSubmit(String id, Object callerContext) {
        mEventDispatcher.dispatchEvent(
            new ImageLoadEvent(getId(), ImageLoadEvent.ON_LOAD_START));
      }

      @Override
      public void onFinalImageSet(
          String id,
          @Nullable final ImageInfo imageInfo,
          @Nullable Animatable animatable) {
        if (imageInfo != null) {
          mEventDispatcher.dispatchEvent(
            new ImageLoadEvent(getId(), ImageLoadEvent.ON_LOAD,
              mImageSource.getSource(), imageInfo.getWidth(), imageInfo.getHeight()));
          mEventDispatcher.dispatchEvent(
            new ImageLoadEvent(getId(), ImageLoadEvent.ON_LOAD_END));
        }
      }

      @Override
      public void onFailure(String id, Throwable throwable) {
        mEventDispatcher.dispatchEvent(
          new ImageLoadEvent(getId(), ImageLoadEvent.ON_ERROR));
        mEventDispatcher.dispatchEvent(
          new ImageLoadEvent(getId(), ImageLoadEvent.ON_LOAD_END));
      }
    };
  }

  mIsDirty = true;
}
项目:ReactNativeSignatureExample    文件:ReactToolbar.java   
@Override
public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable animatable) {
  super.onFinalImageSet(id, imageInfo, animatable);

  final ImageInfo info = mIconImageInfo != null ? mIconImageInfo : imageInfo;
  setDrawable(new DrawableWithIntrinsicSize(mHolder.getTopLevelDrawable(), info));
}
项目:native-navigation    文件:ReactToolbar.java   
@Override
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
  super.onFinalImageSet(id, imageInfo, animatable);

  final ImageInfo info = mIconImageInfo != null ? mIconImageInfo : imageInfo;
  setDrawable(new DrawableWithIntrinsicSize(mHolder.getTopLevelDrawable(), info));
}
项目:native-navigation    文件:ReactBottomNavigation.java   
@Override
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
  super.onFinalImageSet(id, imageInfo, animatable);

  final ImageInfo info = mIconImageInfo != null ? mIconImageInfo : imageInfo;
  setDrawable(new DrawableWithIntrinsicSize(mHolder.getTopLevelDrawable(), info));
}
项目:android-photo-picker    文件:CommonDraweeView.java   
/***
 * load net work image.
 * @param url the main url of image, from net
 * @param lowUrl the low url, from net or local image file name, can be null.
 * @param placeHolder the place holder. 0 with no place holder
 * @param errorResId error res id , 0 with no error res.
 * @param width the width you want
 * @param height the height you want
 * @param scaleType scale type
 * @param l BaseControllerListener,can be null
 */
public void loadImage(String url, String lowUrl,int placeHolder, int errorResId,
                      ScalingUtils.ScaleType scaleType, int width , int height ,
                      final BaseControllerListener<ImageInfo> l){
    ImageRequest request = ImageRequestBuilder
            .newBuilderWithSource(Uri.parse(url))
            //.setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH)
            .setResizeOptions(new ResizeOptions(width, height))
            .build();
    getHierarchy().setActualImageScaleType(scaleType);
    if(placeHolder!=0) {
        getHierarchy().setPlaceholderImage(getResources().getDrawable( placeHolder ),scaleType);
    }
    if(errorResId!=0){
        getHierarchy().setFailureImage(getResources().getDrawable( errorResId ),scaleType);
    }
    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder()
            .setControllerListener(l)
            .setImageRequest(request)
            .setOldController(getController());
    if(lowUrl!=null){
        Uri lowUri = lowUrl.startsWith("http") ? Uri.parse(lowUrl) : Uri.fromFile(new File(lowUrl));
        controller.setLowResImageRequest(ImageRequestBuilder.newBuilderWithSource(lowUri)
                .setResizeOptions(new ResizeOptions(width, height))
                .build() );
    }
    setController(controller.build());
}
项目:JianshuApp    文件:UniversalDraweeView.java   
private void loadImageURI(Uri uri, @Nullable Object callerContext, int width, int height) {
    // 对URL做格式转换、尺寸限制等处理
    uri = Uri.parse(ImageUtils.format(uri.toString(), DisplayInfo.getWidthPixels()));

    ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(uri);
    imageRequestBuilder.setProgressiveRenderingEnabled(true);

    imageRequestBuilder.setRotationOptions(RotationOptions.autoRotateAtRenderTime());
    if (width > 0 && height > 0) {
        imageRequestBuilder.setResizeOptions(new ResizeOptions(width, height));
    }

    PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder()
            .setCallerContext(callerContext)
            .setImageRequest(imageRequestBuilder.build())
            .setOldController(getController())
            .setAutoPlayAnimations(true)  // 自动播放动态图
            .setTapToRetryEnabled(true)  // 在加载失败时,可以点击重新加载
            .setControllerListener(new BaseControllerListener<ImageInfo>() {
                @Override
                public void onFinalImageSet(String id,
                                            ImageInfo imageInfo,
                                            Animatable animatable) {
                    super.onFinalImageSet(id, imageInfo, animatable);
                    onUpdateImage(imageInfo);
                }
            });
    if (AppUtils.isMainThread()) {
        setController(controller.build());
    } else {
        Observable.just(0)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(it -> setController(controller.build()));
    }
}
项目:GalleryFinal-master    文件:FrescoImageLoader.java   
/**
 * 加载远程图片
 *
 * @param url
 * @param imageSize
 */
private void displayImage(Uri url, ResizeOptions imageSize, final ImageView imageView, final DraweeHolder<GenericDraweeHierarchy> draweeHolder) {
    ImageRequest imageRequest = ImageRequestBuilder
            .newBuilderWithSource(url)
            .setResizeOptions(imageSize)//图片目标大小
            .build();
    ImagePipeline imagePipeline = Fresco.getImagePipeline();

    final DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setOldController(draweeHolder.getController())
            .setImageRequest(imageRequest)
            .setControllerListener(new BaseControllerListener<ImageInfo>() {
                @Override
                public void onFinalImageSet(String s, ImageInfo imageInfo, Animatable animatable) {
                    CloseableReference<CloseableImage> imageReference = null;
                    try {
                        imageReference = dataSource.getResult();
                        if (imageReference != null) {
                            CloseableImage image = imageReference.get();
                            if (image != null && image instanceof CloseableStaticBitmap) {
                                CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
                                Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
                                if (bitmap != null && imageView != null) {
                                    imageView.setImageBitmap(bitmap);
                                }
                            }
                        }
                    } finally {
                        dataSource.close();
                        CloseableReference.closeSafely(imageReference);
                    }
                }
            })
            .setTapToRetryEnabled(true)
            .build();
    draweeHolder.setController(controller);
}
项目:react-native-ibeacon-android    文件:ReactToolbar.java   
@Override
public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable animatable) {
  super.onFinalImageSet(id, imageInfo, animatable);

  final ImageInfo info = mIconImageInfo != null ? mIconImageInfo : imageInfo;
  setDrawable(new DrawableWithIntrinsicSize(mHolder.getTopLevelDrawable(), info));
}
项目:react-native-amap    文件:AMapMarker.java   
@Override
public void onFinalImageSet(
        String id,
        @Nullable final ImageInfo imageInfo,
        @Nullable Animatable animatable) {
    CloseableReference<CloseableImage> imageReference = null;
    try {
        imageReference = dataSource.getResult();
        if (imageReference != null) {
            CloseableImage image = imageReference.get();
            if (image != null && image instanceof CloseableStaticBitmap) {
                CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
                Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
                if (bitmap != null) {
                    bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
                    iconBitmap = bitmap;
                    iconBitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
                }
            }
        }
    } finally {
        dataSource.close();
        if (imageReference != null) {
            CloseableReference.closeSafely(imageReference);
        }
    }
    update();
}
项目:NApply    文件:FrescoAdapter.java   
void updateViewSize(@NonNull SimpleDraweeView draweeView, @Nullable ImageInfo imageInfo) {
        if (imageInfo != null) {
//            draweeView.getLayoutParams().width = imageInfo.getWidth();
            draweeView.getLayoutParams().width = ContextUtils.getMetrics(mContext).widthPixels/2;
            draweeView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
            draweeView.setAspectRatio((float) imageInfo.getWidth() / imageInfo.getHeight());
        }
    }
项目:NApply    文件:FrescoImageLoader.java   
public void setController(@NonNull SimpleDraweeView draweeView, @Nullable String uri,@Nullable ControllerListener<ImageInfo> controllerListener){
    DraweeController draweeController =  initControllerBuilder()
            .setOldController(draweeView.getController())
            .setUri(uri)
            .setControllerListener(controllerListener)
            .build();
    draweeView.setController(draweeController);
}
项目:NApply    文件:FrescoImageLoader.java   
public void setImageRequest(@NonNull SimpleDraweeView draweeView, @Nullable ImageRequest imageRequest, @Nullable ControllerListener<ImageInfo> controllerListener){
    DraweeController draweeController =  initControllerBuilder()
            .setOldController(draweeView.getController())
            .setImageRequest(imageRequest)
            .setControllerListener(controllerListener)
            .build();
    draweeView.setController(draweeController);
}
项目:NApply    文件:FrescoImageLoader.java   
private static void updateViewSize(@NonNull SimpleDraweeView draweeView, @Nullable ImageInfo imageInfo,int width) {
    if (imageInfo != null) {
        draweeView.getLayoutParams().width = width;
        draweeView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
        draweeView.setAspectRatio((float) imageInfo.getWidth() / imageInfo.getHeight());
    }
}
项目:Li-MVPArms    文件:PhotoView.java   
public void setImageUri(String url) {
    ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url)).build();
    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    final DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setOldController(mDraweeHolder.getController())
            .setImageRequest(imageRequest)
            .setControllerListener(new BaseControllerListener<ImageInfo>() {
                @Override
                public void onFinalImageSet(String s, @Nullable ImageInfo imageInfo, @Nullable Animatable animatable) {
                    try {
                        imageReference = dataSource.getResult();
                        if (imageReference != null) {
                            CloseableImage image = imageReference.get();
                            // do something with the image
                            if (image != null && image instanceof CloseableStaticBitmap) {
                                CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
                                Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
                                if (bitmap != null) {
                                    setImageBitmap(bitmap);
                                }
                            }
                        }
                    } finally {
                        dataSource.close();
                        CloseableReference.closeSafely(imageReference);
                    }
                }
            })
            .setTapToRetryEnabled(true)
            .build();
    mDraweeHolder.setController(controller);
}
项目:Li-MVPArms    文件:PhotoView.java   
public void setImageUri(String uri, int width, int height) {
    ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri))
            .setAutoRotateEnabled(true)
            .setResizeOptions(new ResizeOptions(width, height))
            .build();
    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    final DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, this);
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setOldController(mDraweeHolder.getController())
            .setImageRequest(imageRequest)
            .setControllerListener(new BaseControllerListener<ImageInfo>() {
                @Override
                public void onFinalImageSet(String s, @Nullable ImageInfo imageInfo, @Nullable Animatable animatable) {
                    try {
                        imageReference = dataSource.getResult();
                        if (imageReference != null) {
                            CloseableImage image = imageReference.get();
                            if (image != null && image instanceof CloseableStaticBitmap) {
                                CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image;
                                Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap();
                                if (bitmap != null) {
                                    setImageBitmap(bitmap);
                                }
                            }
                        }
                    } finally {
                        dataSource.close();
                        CloseableReference.closeSafely(imageReference);
                    }
                }
            })
            .setTapToRetryEnabled(true)
            .build();
    mDraweeHolder.setController(controller);
}
项目:FrescoCustomCacheKey    文件:FrescoImageLoader.java   
/**
 * 获取DraweeController
 *
 * @param imageRequest 设置单个图片请求~~~不可与setFirstAvailableImageRequests共用,配合setLowResImageRequest为高分辨率的图
 * @param lowResImageRequest 先下载显示低分辨率的图
 * @param firstAvailableImageRequests 本地图片复用,可加入ImageRequest数组
 * @param controllerListener 监听图片下载完毕等
 * @param tapToRetryEnabled 点击重新加载图
 */
public static PipelineDraweeControllerBuilder getDraweeController(SimpleDraweeView view, @Nullable ImageRequest imageRequest, ImageRequest lowResImageRequest, @Nullable ImageRequest[] firstAvailableImageRequests, @Nullable ControllerListener<ImageInfo> controllerListener, boolean tapToRetryEnabled) {
    PipelineDraweeControllerBuilder builder = Fresco
            .newDraweeControllerBuilder();
    //自动播放图片动画
    builder.setAutoPlayAnimations(true);
    //点击重新加载图
    builder.setTapToRetryEnabled(tapToRetryEnabled);
    if (firstAvailableImageRequests != null &&
            firstAvailableImageRequests.length > 0) {
        //本地图片复用,可加入ImageRequest数组
        builder.setFirstAvailableImageRequests(firstAvailableImageRequests);
    } else if (imageRequest != null) {
        //设置单个图片请求~~~不可与setFirstAvailableImageRequests共用,配合setLowResImageRequest为高分辨率的图
        builder.setImageRequest(imageRequest);
        if (lowResImageRequest != null) {
            //先下载显示低分辨率的图
            builder.setLowResImageRequest(lowResImageRequest);
        }
    }
    if (controllerListener != null) {
        //监听图片下载完毕等
        builder.setControllerListener(controllerListener);
    }
    //DraweeController复用
    builder.setOldController(view.getController());
    return builder;
}
项目:react-native-box-loaders    文件:ReactToolbar.java   
@Override
public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable animatable) {
  super.onFinalImageSet(id, imageInfo, animatable);

  final ImageInfo info = mIconImageInfo != null ? mIconImageInfo : imageInfo;
  setDrawable(new DrawableWithIntrinsicSize(mHolder.getTopLevelDrawable(), info));
}
项目:FrescoPlus    文件:FetchImageControllerListenerSupplier.java   
@Override
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
    super.onFinalImageSet(id, imageInfo, animatable);
    if(FPFetchCallback ==null || imageInfo == null)
        return;
    FrescoLogger.getLogger().log("Bitmap:[height="+imageInfo.getHeight()+",width="+imageInfo.getWidth()+"]");
    FPFetchCallback.onSuccess(imageInfo);
}