-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to make PhotoView work with Fresco? #178
Comments
The most likely reason why it doesn't work is because the drawable used by Drawee doesn't expose its intrinsic dimensions (i.e. it always returns -1). Because of that I don't think PhotoView / PhotoViewAttacher can easily be made work with Fresco because PhotoViewAttacher relies on ImageView and Drawee doesn't support ImageView attributes. For example, PhotoViewAttacher sets There is however a way to make Drawee work with some zoomble logic. First, you need to specify a controller listener while building the controller, so that you can intercept the load events (onFinalImageSet for example). See http://frescolib.org/docs/listening-download-events.html#_ |
thinks your help! https://github.com/shen0834/wangyue-learngit/blob/master/SimplePhotoView.java I made a simple implementation, if some one also have the same problem, you can refer to |
@shen0834, thanks! Could you make the behaviour like this: |
i will add description provided 6 hours later ,now it's working time |
@shen0834 have a nice day =) |
It seems Fresco now supports pinch-to-zoom feature, with ZoomableDraweeView. |
Hey guys. If anyone still interested in how to use PhotoViewAttacher with Fresco here is my solution. public class PhotoViewDraweeAttacher extends PhotoViewAttacher<SimpleDraweeView> {
private RectF displayRect;
public PhotoViewDraweeAttacher(SimpleDraweeView imageView) {
super(imageView);
}
public RectF getActualImageBounds() {
try {
if(displayRect==null) {
displayRect = new RectF();
}
getImageView().getHierarchy().getActualImageBounds(displayRect);
} catch (Exception e) {
}
return displayRect;
}
@Override
protected int getImageViewWidth(SimpleDraweeView imageView) {
displayRect = getActualImageBounds();
if (!displayRect.isEmpty()) {
return ((int) displayRect.width());
}
return super.getImageViewWidth(imageView);
}
@Override
protected int getImageViewHeight(SimpleDraweeView imageView) {
displayRect = getActualImageBounds();
if (!displayRect.isEmpty()) {
return ((int) displayRect.height());
}
return super.getImageViewHeight(imageView);
}
@Override
protected int getIntrinsicWidth(SimpleDraweeView imageView) {
displayRect = getActualImageBounds();
if (!displayRect.isEmpty()) {
return ((int) displayRect.width());
}
return super.getIntrinsicWidth(imageView);
}
@Override
protected int getIntrinsicHeight(SimpleDraweeView imageView) {
displayRect = getActualImageBounds();
if (!displayRect.isEmpty()) {
return ((int) displayRect.height());
}
return super.getIntrinsicHeight(imageView);
}
} |
If anyone still interested in PhotoView version that works with Fresco here is my fork https://github.com/namshi/PhotoView/tree/fresco_refactoring Rotation feature not working properly yet. |
Hey @ffelini, thanks for your fork. It works well, but the picture does not stay centered while zooming. I did not investigate it further, but i found another working solution, which does the job. See here: https://github.com/06peng/FrescoDemo/tree/master/app/src/main/java/uk/co/senab/photoview. |
https://github.com/chrisbanes/PhotoView/blob/master/library/src/main/java/uk/co/senab/photoview/PhotoView.java
i'm trying to use fresco replace the imageloder ,
i'm trying to let PhotoView extends SimpleDraweeView , override the method onDraw and onTouchEvent,but PhotoView It doesn't work
Is there a way to make PhotoView work with Fresco?
Thanks!
The text was updated successfully, but these errors were encountered: