code: private boolean limitTranslation(Matrix transform, @LimitFlag int limitTypes) {
      if (!shouldLimit(limitTypes, LIMIT_TRANSLATION_X | LIMIT_TRANSLATION_Y)) {
        return false;
      }
      RectF b = mTempRect;
      b.set(mImageBounds);
      transform.mapRect(b);
      float offsetLeft = shouldLimit(limitTypes, LIMIT_TRANSLATION_X) ?
          getOffset(b.left, b.right, mViewBounds.left, mViewBounds.right, mImageBounds.centerX()) : 0;
      float offsetTop = shouldLimit(limitTypes, LIMIT_TRANSLATION_Y) ?
          getOffset(b.top, b.bottom, mViewBounds.top, mViewBounds.bottom, mImageBounds.centerY()) : 0;
      if (offsetLeft != 0 || offsetTop != 0) {
        transform.postTranslate(offsetLeft, offsetTop);
        return true;
      }
      return false;
    }
docs: Limits the translation so that there are no empty spaces on the sides if possible.
  
  <p> The image is attempted to be centered within the view bounds if the transformed image is
  smaller. There will be no empty spaces within the view bounds if the transformed image is
  bigger. This applies to each dimension (horizontal and vertical) independently.
  
  @param limitTypes whether to limit translation along the specific axis.
  @return whether limiting has been applied or not