code: private static int[] calculateGridParam(int imagesSize) {
          int[] gridParam = new int[2];
          if (imagesSize < 3) {
              gridParam[0] = 1;
              gridParam[1] = imagesSize;
          } else if (imagesSize <= 4) {
              gridParam[0] = 2;
              gridParam[1] = 2;
          } else {
              gridParam[0] = imagesSize / 3 + (imagesSize % 3 == 0 ? 0 : 1);
              gridParam[1] = 3;
          }
          return gridParam;
      }
docs: 设置宫格参数
  
  @param imagesSize 图片数量
  @return 宫格参数 gridParam[0] 宫格行数 gridParam[1] 宫格列数