예제 #1
0
  /**
   * 获取功能表文件夹列数
   *
   * @param standard 竖屏时是设置项参数,横屏时是图标宽度
   * @return
   */
  public int getFolderColumn(int standard) {
    int column = 0;
    try {
      final boolean isVertical = isVertical();
      column = 0;
      int smallerBound = getSmallerBound();

      if (isVertical) {
        switch (standard) {
          case FunAppSetting.LINECOLUMNNUMXY_SPARSE:
            {
              if (smallerBound <= 240) {
                column += 4;
              } else {
                column += 4;
              }
              break;
            }
          case FunAppSetting.LINECOLUMNNUMXY_MIDDLE:
            {
              if (smallerBound <= 240) {
                column += 4;
              } else {
                column += 5;
              }
              break;
            }
          case FunAppSetting.LINECOLUMNNUMXY_MIDDLE_2:
            {
              if (smallerBound <= 240) {
                column += 4;
              } else {
                column += 4;
              }
              break;
            }
          case FunAppSetting.LINECOLUMNNUMXY_THICK:
            {
              if (smallerBound <= 240) {
                column += 5;
              } else {
                column += 5;
              }
              break;
            }
          case FunAppSetting.LINECOLUMNNUMXY_DIY:
            {
              // 功能表设置数据
              FunAppSetting setting = GOLauncherApp.getSettingControler().getFunAppSetting();
              column = setting.getColNum();

              break;
            }
          default:
            {
              if (smallerBound <= 240) {
                column += 4;
              } else {
                column += 4;
              }
              break;
            }
        }
      } else {
        column = (getLongerBound() - getStatusBarHeight()) / standard;
      }
    } catch (NullPointerException e) {
      column = 4;
      e.printStackTrace();
    }
    return column;
  }
예제 #2
0
  /** 根据行列数设置Grid的规格 当规格发生改变时返回true */
  public boolean setGridStandard(int standard, XBaseGrid grid, long gridId) {
    try {
      final boolean isVertical = isVertical();
      int row = 0;
      int column = 0;
      int smallerBound = getSmallerBound();
      FunAppSetting setting = GOLauncherApp.getSettingControler().getFunAppSetting();
      switch (standard) {
        case FunAppSetting.LINECOLUMNNUMXY_SPARSE:
          {
            if (isVertical) {
              if (smallerBound <= 240) {
                row += 3;
                column += 4;
              } else {
                row += 4;
                column += 4;
              }
              if (null != grid) {
                if ((grid.getColunmNums() != column) || (grid.getRowNums() != row)) {
                  grid.setColunmNums(column);
                  grid.setRowNums(row);
                  setRCNum(column, row, gridId);
                  return true;
                }
              }
            } else {
              if (smallerBound <= 240) {
                row += 3;
                column += 4;
              } else {
                row += 3;
                column += 5;
              }
              if (null != grid) {
                if ((grid.getColunmNums() != row) || (grid.getRowNums() != column)) {
                  grid.setColunmNums(row);
                  grid.setRowNums(column);
                  setRCNum(column, row, gridId);
                  return true;
                }
              }
            }
            setRCNum(column, row, gridId);
            break;
          }
        case FunAppSetting.LINECOLUMNNUMXY_MIDDLE:
          {
            if (isVertical) {
              if (smallerBound <= 240) {
                if (gridId == AppFuncConstants.ALLAPPS_GRID) {
                  row += 4;
                } else {
                  row += 3;
                }
                column += 4;
              } else {
                row += 4;
                column += 5;
              }
              if (null != grid) {
                if ((grid.getColunmNums() != column) || (grid.getRowNums() != row)) {
                  grid.setColunmNums(column);
                  grid.setRowNums(row);
                  setRCNum(column, row, gridId);
                  return true;
                }
              }
            } else {
              row += 3;
              if (smallerBound <= 240) {
                if (gridId == AppFuncConstants.ALLAPPS_GRID) {
                  column += 5;
                } else {
                  column += 4;
                }
              } else {
                if (gridId == AppFuncConstants.ALLAPPS_GRID) {
                  column += 6;
                } else {
                  column += 5;
                }
              }
              if (null != grid) {
                if ((grid.getColunmNums() != row) || (grid.getRowNums() != column)) {
                  grid.setColunmNums(row);
                  grid.setRowNums(column);
                  setRCNum(column, row, gridId);
                  return true;
                }
              }
            }
            setRCNum(column, row, gridId);
            break;
          }
        case FunAppSetting.LINECOLUMNNUMXY_MIDDLE_2:
          {
            if (isVertical) {
              if (smallerBound <= 240) {
                if (gridId == AppFuncConstants.ALLAPPS_GRID) {
                  row += 4;
                } else {
                  row += 3;
                }
                column += 4;
              } else {
                row += 5;
                column += 4;
              }
              if (null != grid) {
                if ((grid.getColunmNums() != column) || (grid.getRowNums() != row)) {
                  grid.setColunmNums(column);
                  grid.setRowNums(row);
                  setRCNum(column, row, gridId);
                  return true;
                }
              }
            } else {
              row += 3;
              if (smallerBound <= 240) {
                if (gridId == AppFuncConstants.ALLAPPS_GRID) {
                  column += 5;
                } else {
                  column += 4;
                }
              } else {
                if (gridId == AppFuncConstants.ALLAPPS_GRID) {
                  column += 6;
                } else {
                  column += 5;
                }
              }
              if (null != grid) {
                if ((grid.getColunmNums() != row) || (grid.getRowNums() != column)) {
                  grid.setColunmNums(row);
                  grid.setRowNums(column);
                  setRCNum(column, row, gridId);
                  return true;
                }
              }
            }
            setRCNum(column, row, gridId);
            break;
          }
        case FunAppSetting.LINECOLUMNNUMXY_THICK:
          {
            if (isVertical) {
              if (smallerBound <= 240) {
                column += 5;
                if (gridId == AppFuncConstants.ALLAPPS_GRID) {
                  row += 4;
                } else {
                  row += 3;
                }
              } else {
                column += 5;
                if (gridId == AppFuncConstants.ALLAPPS_GRID) {
                  row += 5;
                } else {
                  row += 4;
                }
              }
              if (null != grid) {
                if ((grid.getColunmNums() != column) || (grid.getRowNums() != row)) {
                  grid.setColunmNums(column);
                  grid.setRowNums(row);
                  setRCNum(column, row, gridId);
                  return true;
                }
              }
            } else {
              if (smallerBound <= 240) {
                row += 4;
                if (gridId == AppFuncConstants.ALLAPPS_GRID) {
                  column += 5;
                } else {
                  column += 4;
                }
              } else {
                row += 4;
                if (gridId == AppFuncConstants.ALLAPPS_GRID) {
                  column += 6;
                } else {
                  column += 5;
                }
              }
              if (null != grid) {
                if ((grid.getColunmNums() != row) || (grid.getRowNums() != column)) {
                  // 横屏时列代表实际行,行代表实际列
                  grid.setColunmNums(row);
                  grid.setRowNums(column);
                  setRCNum(column, row, gridId);
                  return true;
                }
              }
            }
            setRCNum(column, row, gridId);
            break;
          }
        case FunAppSetting.LINECOLUMNNUMXY_DIY:
          {
            // 功能表设置数据
            if (grid != null) {
              if (isVertical) {
                grid.setColunmNums(setting.getColNum());
                grid.setRowNums(setting.getRowNum());
              } else {
                grid.setColunmNums(setting.getRowNum());
                grid.setRowNums(setting.getColNum());
              }
            }
            return true;
          }
        case FunAppSetting.LINECOLUMNNUMXY_AUTO_FIT:
          {
            AppFuncAutoFitManager autoFitMgr = AppFuncAutoFitManager.getInstance(mContext);
            if (grid != null) {
              if (isVertical) {
                grid.setColunmNums(autoFitMgr.getAppDrawerColumnsV());
                grid.setRowNums(autoFitMgr.getAppDrawerRowsV());
              } else {
                grid.setRowNums(autoFitMgr.getAppDrawerColumnsH());
                grid.setColunmNums(autoFitMgr.getAppDrawerRowsH());
              }
            }
            break;
          }
        default:
          {
            if (isVertical()) {
              if (smallerBound <= 240) {
                row += 3;
                column += 4;
              } else {
                row += 4;
                column += 4;
              }
              if (null != grid) {
                if ((grid.getColunmNums() != column) || (grid.getRowNums() != row)) {
                  grid.setColunmNums(column);
                  grid.setRowNums(row);
                  setRCNum(column, row, gridId);
                  return true;
                }
              }

            } else {
              if (smallerBound <= 240) {
                row += 3;
                column += 4;
              } else {
                row += 3;
                column += 5;
              }
              if (null != grid) {
                if ((grid.getColunmNums() != row) || (grid.getRowNums() != column)) {
                  grid.setColunmNums(row);
                  grid.setRowNums(column);
                  setRCNum(column, row, gridId);
                  return true;
                }
              }
            }
            break;
          }
      }
    } catch (NullPointerException e) {
      e.printStackTrace();
    }
    return false;
  }