@Override
    public boolean canScrollHorizontally(int direction) {
        matrix.getValues(m);
        float x = m[Matrix.MTRANS_X];

        if (getImageWidth() < viewWidth) {
            return false;

        } else if (x >= -1 && direction < 0) {
            return false;

        } else if (Math.abs(x) + viewWidth + 1 >= getImageWidth() && direction > 0) {
            return false;
        }

        return true;
    }
After rotating, the matrix needs to be translated. This function finds the area of image
which was previously centered and adjusts translations so that is again the center, post-rotation.

@param axis          Matrix.MTRANS_X or Matrix.MTRANS_Y
@param trans         the value of trans in that axis before the rotation
@param prevImageSize the width/height of the image before the rotation
@param imageSize     width/height of the image after rotation
@param prevViewSize  width/height of view before rotation
@param viewSize      width/height of view after rotation
@param drawableSize  width/height of drawable
app/src/main/java/com/rozdoum/socialcomponents/views/TouchImageView.java