code: private int getMargin(int gravity, int margin, int minimumMargin) {
      switch (gravity) {
        case Gravity.CENTER:
          return (margin == INVALID) ? minimumMargin : margin;
        default:
          return (margin == INVALID) ? 0 : margin;
      }
    }
docs: Get margins if provided or assign default values based on gravity
  
  @param gravity       the gravity of the dialog
  @param margin        the value defined in the builder
  @param minimumMargin the minimum margin when gravity center is selected
  @return the value of the margin