use of com.facebook.imagepipeline.image.ImageInfo in project ride-read-android by Ride-Read.
the class ImageActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
imageUrl = getIntent().getStringExtra(IMAGE);
if (imageUrl.startsWith("/")) {
imageUrl = "file://" + imageUrl;
}
final PhotoDraweeView photoDraweeView = (PhotoDraweeView) findViewById(R.id.iv_image_activity);
photoDraweeView.setOnViewTapListener(new OnViewTapListener() {
@Override
public void onViewTap(View view, float x, float y) {
onBackPressed();
}
});
PipelineDraweeControllerBuilder controller = Fresco.newDraweeControllerBuilder();
controller.setUri(Uri.parse(imageUrl));
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) {
return;
}
photoDraweeView.update(imageInfo.getWidth(), imageInfo.getHeight());
}
});
photoDraweeView.setController(controller.build());
}
use of com.facebook.imagepipeline.image.ImageInfo in project SherlockAdapter by EvilBT.
the class FrescoUtil method setWrapImage.
public static void setWrapImage(@NonNull final SimpleDraweeView view, @NonNull final String path) {
Preconditions.checkNotNull(view);
Preconditions.checkNotNull(path);
ControllerListener<ImageInfo> controllerListener = new BaseControllerListener<ImageInfo>() {
@Override
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
if (imageInfo == null) {
return;
}
final float width = imageInfo.getWidth();
final float height = imageInfo.getHeight();
if (width * height != 0.0f) {
view.setAspectRatio(width / height);
}
}
};
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(path)).build();
view.setController(Fresco.newDraweeControllerBuilder().setImageRequest(request).setOldController(view.getController()).setControllerListener(controllerListener).build());
}
use of com.facebook.imagepipeline.image.ImageInfo in project remusic by aa112901.
the class QuickControlsFragment method updateNowplayingCard.
public void updateNowplayingCard() {
mTitle.setText(MusicPlayer.getTrackName());
mArtist.setText(MusicPlayer.getArtistName());
ControllerListener controllerListener = new BaseControllerListener<ImageInfo>() {
@Override
public void onFinalImageSet(String id, @Nullable ImageInfo imageInfo, @Nullable Animatable anim) {
if (imageInfo == null) {
return;
}
QualityInfo qualityInfo = imageInfo.getQualityInfo();
FLog.d("Final image received! " + "Size %d x %d", "Quality level %d, good enough: %s, full quality: %s", imageInfo.getWidth(), imageInfo.getHeight(), qualityInfo.getQuality(), qualityInfo.isOfGoodEnoughQuality(), qualityInfo.isOfFullQuality());
}
@Override
public void onIntermediateImageSet(String id, @Nullable ImageInfo imageInfo) {
// FLog.d("Intermediate image received");
}
@Override
public void onFailure(String id, Throwable throwable) {
mAlbumArt.setImageURI(Uri.parse("res:/" + R.drawable.placeholder_disk_210));
}
};
Uri uri = null;
try {
uri = Uri.parse(MusicPlayer.getAlbumPath());
} catch (Exception e) {
e.printStackTrace();
}
if (uri != null) {
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri).build();
DraweeController controller = Fresco.newDraweeControllerBuilder().setOldController(mAlbumArt.getController()).setImageRequest(request).setControllerListener(controllerListener).build();
mAlbumArt.setController(controller);
} else {
mAlbumArt.setImageURI(Uri.parse("content://" + MusicPlayer.getAlbumPath()));
}
}
use of com.facebook.imagepipeline.image.ImageInfo in project SherlockAdapter by EvilBT.
the class FrescoUtil method resizeImage.
public static void resizeImage(@NonNull final SimpleDraweeView view, @NonNull final String path, final int viewWidth) {
Preconditions.checkNotNull(view);
Preconditions.checkNotNull(path);
ControllerListener<ImageInfo> controllerListener = new BaseControllerListener<ImageInfo>() {
@Override
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
if (imageInfo == null) {
return;
}
final float width = imageInfo.getWidth();
final float height = imageInfo.getHeight();
if (width * height != 0.0f) {
final int viewHeight = (int) (height * viewWidth / width);
setResizeImage(view, path, new ResizeOptions(viewWidth, viewHeight));
}
}
};
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(path)).build();
view.setController(Fresco.newDraweeControllerBuilder().setImageRequest(request).setOldController(view.getController()).setControllerListener(controllerListener).build());
}
use of com.facebook.imagepipeline.image.ImageInfo in project SherlockAdapter by EvilBT.
the class FrescoUtil method setWrapAndResizeImage.
public static void setWrapAndResizeImage(@NonNull final SimpleDraweeView view, @NonNull final String path, final int viewWidth, @Nullable final Point size) {
Preconditions.checkNotNull(view);
Preconditions.checkNotNull(path);
ControllerListener<ImageInfo> controllerListener = new BaseControllerListener<ImageInfo>() {
@Override
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
if (imageInfo == null) {
return;
}
final float width = imageInfo.getWidth();
final float height = imageInfo.getHeight();
if (width * height != 0.0f) {
view.setAspectRatio(width / height);
final int viewHeight = (int) (height * viewWidth / width);
if (size != null) {
size.set(viewWidth, viewHeight);
}
setResizeImage(view, path, new ResizeOptions(viewWidth, viewHeight));
}
}
};
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(path)).build();
view.setController(Fresco.newDraweeControllerBuilder().setImageRequest(request).setOldController(view.getController()).setControllerListener(controllerListener).build());
}
Aggregations