@Override
  public View getView(int position, View convertView, ViewGroup parent) {

    IconModel typeIcon = (IconModel) getItem(position);

    ViewHolder viewHolder;
    if (convertView == null) {
      convertView = mInflater.inflate(R.layout.icon_item_layout, parent, false);

      viewHolder = new ViewHolder();
      viewHolder.tvIcon = (TextView) convertView.findViewById(R.id.icon_item);
      viewHolder.imgIcon = (ImageView) convertView.findViewById(R.id.icon_item_image);

      convertView.setTag(viewHolder);
    } else {
      viewHolder = (ViewHolder) convertView.getTag();
    }

    viewHolder.tvIcon.setText(typeIcon.type);
    viewHolder.tvIcon.setTextColor(context.getResources().getColor(typeIcon.typeTextColor));
    viewHolder.imgIcon.setImageResource(
        Utils.getImageResourceId(context, typeIcon.iconImageToShow));

    return convertView;
  }
    @Override
    protected Map<String, List> doInBackground(Void... params) {
      Map<String, List> result = new HashMap<>();

      List<String> types = new ArrayList<>();
      List<Float> percents = new ArrayList<>();
      List<ChartItemModel> datas = new ArrayList<>();

      // 所有记录总金额
      totalAmount = DataSupport.sum(AccountModel.class, TableConstants.AMOUNT, float.class);

      // 查询类别、图标、类别总金额
      Cursor cursor = DataSupport.findBySQL(QUERY_TYPES);
      if (cursor != null && cursor.moveToFirst()) {
        do {
          String type = cursor.getString(cursor.getColumnIndex(TableConstants.TYPE));
          String iconImageName =
              cursor.getString(cursor.getColumnIndex(TableConstants.ICONIMAGENAME));
          float sum =
              DataSupport.where(TableConstants.TYPE + " = ?", type)
                  .sum(AccountModel.class, TableConstants.AMOUNT, float.class);

          types.add(type);
          percents.add(sum / totalAmount);

          ChartItemModel chartItemModel = new ChartItemModel();
          chartItemModel.type = type;
          chartItemModel.percent = Utils.convertFloatToPercent(sum / totalAmount);
          chartItemModel.iconImageName = iconImageName;
          chartItemModel.sum = sum;
          datas.add(chartItemModel);

        } while (cursor.moveToNext());
        cursor.close();
      }

      result.put("types", types);
      result.put("percents", percents);
      result.put("datas", datas);

      return result;
    }