Actually making it work (without flying ... if you could do it with flying, it would be great), I have to override the PhotoViewAttacher methods and associate them with them. Actually, I didn’t want the scaling option to be restarted, but also to drag. I did it as follows:
private boolean DEBUG = true;
private boolean actionL = false;
private boolean actionR = false;
private boolean scalingL = false;
private boolean scalingR = false;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
photoViewAttacherL = new PhotoViewAttacher(photoL){
@Override
public void onDrag(float dx, float dy) {
if (!scalingL && !actionL) {
actionL = true;
if (DEBUG) Dbg.d("DRAG", "x: " + dx + " y: " + dy);
photoViewAttacherR.onDrag(dx, dy);
super.onDrag(dx, dy);
actionL = false;
}
}
@Override
public void onFling(float startX, float startY, float velocityX, float velocityY) {
}
@Override
public boolean onTouch(View v, MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_UP){
scalingL = false;
scalingR = false;
}
return super.onTouch(v, ev);
}
@Override
public void onScale(float scaleFactor, float focusX, float focusY) {
if (!actionL) {
actionL = true;
if (DEBUG)
Dbg.d("SCALE", "factor: " + scaleFactor + " x: " + focusX + " y: " + focusY);
scalingL = true;
photoViewAttacherR.onScale(scaleFactor, focusX, focusY);
super.onScale(scaleFactor, focusX, focusY);
actionL = false;
}
}
};
photoViewAttacherR = new PhotoViewAttacher(photoR){
@Override
public void onDrag(float dx, float dy) {
if (!scalingR && !actionR) {
actionR = true;
if (DEBUG) Dbg.d("DRAG", "x: " + dx + " y: " + dy);
photoViewAttacherL.onDrag(dx, dy);
super.onDrag(dx, dy);
actionR = false;
}
}
@Override
public void onFling(float startX, float startY, float velocityX, float velocityY) {
}
@Override
public boolean onTouch(View v, MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_UP){
scalingL = false;
scalingR = false;
}
return super.onTouch(v, ev);
}
@Override
public void onScale(float scaleFactor, float focusX, float focusY) {
if (!actionR) {
actionR = true;
if (DEBUG)
Dbg.d("SCALE", "factor: " + scaleFactor + " x: " + focusX + " y: " + focusY);
scalingR = true;
photoViewAttacherL.onScale(scaleFactor, focusX, focusY);
super.onScale(scaleFactor, focusX, focusY);
actionR = false;
}
}
};
}