use of com.facebook.imagepipeline.common.ResizeOptions in project actor-platform by actorapp.
the class AvatarView method bindRaw.
public void bindRaw(String fileName) {
if (bindedFile != null) {
bindedFile.detach();
bindedFile = null;
}
currentId = 0;
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(new File(fileName))).setResizeOptions(new ResizeOptions(size, size)).setAutoRotateEnabled(true).build();
PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(getController()).setImageRequest(request).build();
setController(controller);
}
use of com.facebook.imagepipeline.common.ResizeOptions in project actor-platform by actorapp.
the class CallBackgroundAvatarView method bind.
public void bind(Avatar avatar) {
// Same avatar
if (avatar != null && getImage(avatar) != null && getImage(avatar).getFileReference().getFileId() == currentId) {
return;
}
fastThumbLoader = new FastThumbLoader(this);
fastThumbLoader.setBlur(10);
if (bindedFile != null) {
bindedFile.detach();
bindedFile = null;
}
setImageURI(null);
if (avatar == null || getImage(avatar) == null) {
currentId = 0;
return;
}
currentId = getImage(avatar).getFileReference().getFileId();
bindedFile = messenger().bindFile(getImage(avatar).getFileReference(), true, new FileVMCallback() {
@Override
public void onNotDownloaded() {
}
@Override
public void onDownloading(float progress) {
}
@Override
public void onDownloaded(FileSystemReference reference) {
blurActor.send(new BlurActor.RequestBlur(reference.getDescriptor(), 10, new BlurActor.BluredListener() {
@Override
public void onBlured(final File f) {
((BaseActivity) getContext()).runOnUiThread(new Runnable() {
@Override
public void run() {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.fromFile(f)).setResizeOptions(new ResizeOptions(Screen.getWidth(), Screen.getHeight())).build();
PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder().setOldController(getController()).setImageRequest(request).build();
setController(controller);
}
});
}
}));
}
});
}
use of com.facebook.imagepipeline.common.ResizeOptions in project lzc_app_lib by httplzc.
the class BigImgDataRequestHelper method getHolderData.
// 获取holder 的catch
private void getHolderData(final WrapperUri wrapperUri) {
final Uri holderUri = wrapperUri.getLowUri();
if (holderUri == null)
return;
ImagePipeline imagePipeline = Fresco.getImagePipeline();
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(holderUri).setResizeOptions(new ResizeOptions(ScreenData.widthPX / 3, ScreenData.heightPX / 3)).build();
DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(request, "");
dataSource.subscribe(new BaseDataSubscriber<CloseableReference<CloseableImage>>() {
@Override
protected void onNewResultImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
if (!dataSource.isFinished()) {
return;
}
CloseableReference<CloseableImage> ref = dataSource.getResult();
if (ref != null && ref.isValid()) {
try {
if (data.get(wrapperUri.getUri()) == null) {
holderData.put(holderUri, ref.clone());
if (imgDataLoadCompleteListener != null)
imgDataLoadCompleteListener.onHolderDataLoadComplete(wrapperUri);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
CloseableReference.closeSafely(ref);
}
}
}
@Override
protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
}
}, UiThreadImmediateExecutorService.getInstance());
}
use of com.facebook.imagepipeline.common.ResizeOptions in project lzc_app_lib by httplzc.
the class FunUntil method loadImg.
/**
* 加载图片
* @param targetWidth
* @param targetHeight
* @param simpleDraweeView
* @param path
*/
public static void loadImg(int targetWidth, int targetHeight, SimpleDraweeView simpleDraweeView, String path) {
if (StringManagerUtil.CheckNull(path))
return;
Uri uri = null;
try {
uri = Uri.parse(path);
} catch (Exception e) {
e.printStackTrace();
return;
}
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(targetWidth, targetHeight)).setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH).build();
AbstractDraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(simpleDraweeView.getController()).setImageRequest(request).build();
simpleDraweeView.setController(controller);
}
use of com.facebook.imagepipeline.common.ResizeOptions in project ride-read-android by Ride-Read.
the class FrescoImgLoader method displayImage.
@Override
public void displayImage(Activity activity, Context context, String path, final GalleryImageView imageView, int width, int height) {
GenericDraweeHierarchy hierarchy = // 占位图
new GenericDraweeHierarchyBuilder(context.getResources()).setFadeDuration(300).setPlaceholderImage(R.mipmap.gallery_pick_photo).setFailureImage(// 加载失败图
R.mipmap.gallery_pick_photo).setProgressBarImage(// loading
new ProgressBarDrawable()).build();
final DraweeHolder<GenericDraweeHierarchy> draweeHolder = DraweeHolder.create(hierarchy, context);
imageView.setOnImageViewListener(new GalleryImageView.OnImageViewListener() {
@Override
public void onDraw(Canvas canvas) {
Drawable drawable = draweeHolder.getHierarchy().getTopLevelDrawable();
if (drawable == null) {
imageView.setImageResource(R.mipmap.gallery_pick_photo);
} else {
imageView.setImageDrawable(drawable);
}
}
@Override
public boolean verifyDrawable(Drawable dr) {
return dr == draweeHolder.getHierarchy().getTopLevelDrawable();
}
@Override
public void onDetach() {
draweeHolder.onDetach();
}
@Override
public void onAttach() {
draweeHolder.onAttach();
}
});
Uri uri = new Uri.Builder().scheme(UriUtil.LOCAL_FILE_SCHEME).path(path).build();
ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(uri).setResizeOptions(new ResizeOptions(width, height)).build();
DraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(draweeHolder.getController()).setImageRequest(imageRequest).build();
draweeHolder.setController(controller);
}
Aggregations