/** 从云端获取数据并加入本地的listView */
  private void getLeanCloudData() {
    // leanCloud数据读取

    AVQuery.doCloudQueryInBackground(
        "select * from " + swicthCategory(),
        new CloudQueryCallback<AVCloudQueryResult>() {

          @SuppressWarnings("null")
          @Override
          public void done(AVCloudQueryResult result, AVException cqlException) {

            List<String> names = new ArrayList<String>();

            if (cqlException == null) {
              for (int i = 0; i < result.getResults().size(); i++) {
                String categoryName = titleName;
                String name = result.getResults().get(i).getString("name");
                String remainDays = result.getResults().get(i).getString("remainDays");
                String kiloNum = result.getResults().get(i).getString("kiloNum");
                boolean state = result.getResults().get(i).getBoolean("state");
                Log.e("result: i", "" + name + remainDays + kiloNum);

                HashMap<String, Object> map = new HashMap<String, Object>();
                map.put("name", name);
                map.put("remainDays", remainDays);
                map.put("kiloNum", kiloNum);
                list.add(map);

                //  加入是否过期的物品
                if (!state) {
                  if (!names.isEmpty()) {
                    for (int j = 0; j < names.size(); j++) {
                      if (!names.get(i).equals(name)) {
                        names.add(name);
                      }
                    }
                  } else {
                    names.add(name);
                  }
                }
              }
              if (!names.isEmpty()) {
                createDialog(names, "过期提示");
              }
              // 适配器
              SimpleAdapter adapter =
                  new SimpleAdapter(
                      CategoryActivity.this,
                      list,
                      R.layout.category_list_item,
                      new String[] {"name", "remainDays", "kiloNum"},
                      new int[] {R.id.item_name, R.id.item_days, R.id.item_kilo_num});
              categoryListView.setAdapter(adapter);
            }
          }
        });
  }
  public void getOverdue() {
    AVQuery.doCloudQueryInBackground(
        "select * from overdue",
        new CloudQueryCallback<AVCloudQueryResult>() {

          @Override
          public void done(AVCloudQueryResult result, AVException e) {
            List<String> names = new ArrayList<String>();

            if (e == null) {
              for (int i = 0; i < result.getResults().size(); i++) {
                String name = result.getResults().get(i).getString("name");

                names.add(name);
              }

              if (!names.isEmpty()) {
                createDialog(names, "物品不足提示");
              }
            }
          }
        });
  }