@Override
            public boolean onDoubleTap(MotionEvent ev) {
                try {
                    float scale = getScale();
                    float x = ev.getX();
                    float y = ev.getY();

                    if (scale < getMediumScale()) {
                        setScale(getMediumScale(), x, y, true);
                    } else if (scale >= getMediumScale() && scale < getMaximumScale()) {
                        setScale(getMaximumScale(), x, y, true);
                    } else {
                        setScale(getMinimumScale(), x, y, true);
                    }
                } catch (ArrayIndexOutOfBoundsException e) {
                    // Can sometimes happen when getX() and getY() is called
                }

                return true;
            }
The component of {@link PhotoView} which does the work allowing for zooming, scaling, panning, etc.
It is made public in case you need to subclass something other than {@link ImageView} and still
gain the functionality that {@link PhotoView} offers
main/src/main/java/com/quxianggif/common/view/photoview/PhotoViewAttacher.java