private void savePicToDB(File pic) {
    // 获取当前任务实体类
    UploadPgrwInfo uploadPgrwInfo = DataSupport.find(UploadPgrwInfo.class, taskId);
    // 查找当前任务当前位置的图片集合
    List<UploadImageEntity> infos =
        DataSupport.where(
                "djh = ? and filefl = ? and filewz = ?",
                uploadPgrwInfo.getPgdh(),
                getFileFl(llIndex) + "",
                gvIndex + "")
            .find(UploadImageEntity.class);
    // 集合不会空说明之前已经有图了,要删掉再保存
    if (!infos.isEmpty()) {
      for (UploadImageEntity entity : infos) {
        DataSupport.delete(UploadImageEntity.class, entity.getId());
        Picasso.with(this).invalidate(entity.getFilerealpath());
      }
    }
    UploadImageEntity uploadImageEntity = new UploadImageEntity();
    uploadImageEntity.setDjh(uploadPgrwInfo.getPgdh());
    uploadImageEntity.setFilefl(getFileFl(llIndex));
    uploadImageEntity.setExfile(".jpg");
    uploadImageEntity.setFilewz(gvIndex + "");
    uploadImageEntity.setFilerealpath(pic.getAbsolutePath());
    uploadImageEntity.setFilenames(pic.getName());
    uploadImageEntity.save();

    uploadPgrwInfo.getImageEntityList().add(uploadImageEntity);
    uploadPgrwInfo.save();
  }
Exemplo n.º 2
0
 public static List<Bill> billList(Date d, int typeId) {
   return DataSupport.where(
           "datetime >= ? and datetime <= ? and billtype_id = ?",
           String.valueOf(d.getStart()),
           String.valueOf(d.getEnd()),
           String.valueOf(typeId))
       .find(Bill.class);
 }
Exemplo n.º 3
0
 /**
  * 返回账单集合,有起始时间作为约束 根据时间排序,不然会导致分组错误
  *
  * @return
  */
 public static List<Bill> billList(Date d) {
   return DataSupport.where(
           "datetime >= ? and datetime <= ?",
           String.valueOf(d.getStart()),
           String.valueOf(d.getEnd()))
       .order("datetime")
       .find(Bill.class);
 }
    @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;
    }
 private void updateItemList() {
   // 获取到当前数据库存储图片的集合(存在filePath)
   // 值得注意的是任务表和图片表是一对多,uploadpgrwinfo_id在图片实体添加到任务实体中自动生成
   uploadImgList =
       DataSupport.where(
               "uploadpgrwinfo_id = ? and filefl = ? ", taskId + "", getFileFl(llIndex) + "")
           .find(UploadImageEntity.class);
   // 遍历当前当前数据库存储的图片集合,实例化为gridView的item
   for (UploadImageEntity info : uploadImgList) {
     int index = Integer.parseInt(info.getFilewz());
     if (index <= itemList.size()) {
       itemList.get(index - 1).setImgPath(info.getFilerealpath());
     } else {
       // 如果超出固定Item数目,则new一个item出来
       DisImgItem item = new DisImgItem();
       item.setImgPath(info.getFilerealpath());
       itemList.add(item);
     }
   }
 }
Exemplo n.º 6
0
  public List<Message> getAllCaptchMessages() {
    List<String> dateGroups = new ArrayList<>();
    ContentResolver contentResolver = mContext.getContentResolver();
    Cursor cursor =
        contentResolver.query(ALL_MESSAGE_URI, ALL_THREADS_PROJECTION, null, null, "date desc");
    List<Message> smsMessages = new ArrayList<>();
    while ((cursor.moveToNext())) {
      int indexBody = cursor.getColumnIndex("body");
      int indexAddress = cursor.getColumnIndex("address");
      int indexThreadId = cursor.getColumnIndex("thread_id");
      String strbody = cursor.getString(indexBody);
      String strAddress = cursor.getString(indexAddress);
      if (!StringUtils.isPersonalMoblieNO(strAddress)) {
        boolean isCpatchasMessage = false;
        if (!StringUtils.isContainsChinese(strbody)) {
          if (StringUtils.isCaptchasMessageEn(strbody)
              && !StringUtils.tryToGetCaptchasEn(strbody).equals("")) {
            isCpatchasMessage = true;
          }
        } else if (StringUtils.isCaptchasMessage(strbody)
            && !StringUtils.tryToGetCaptchas(strbody).equals("")) {
          isCpatchasMessage = true;
        }
        if (isCpatchasMessage) {
          int date = cursor.getColumnIndex("date");
          // 格式化短信日期提示
          SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd hh:mm");
          Date formatDate = new Date(Long.parseLong(cursor.getString(date)));
          long threadId = cursor.getLong(indexThreadId);

          // 获得短信的各项内容
          String dateMms = dateFormat.format(formatDate);
          Message message = new Message();
          String company = StringUtils.getContentInBracket(strbody, strAddress);
          if (company != null) {
            message.setCompanyName(company);
          }
          String captchas = StringUtils.tryToGetCaptchas(strbody);
          if (!captchas.equals("")) {
            message.setCaptchas(captchas);
          }
          int columnIndex = cursor.getColumnIndex("_id");
          String smsId = cursor.getString(columnIndex);
          message.setIsMessage(true);
          message.setDate(formatDate);
          message.setSender(strAddress);
          message.setThreadId(threadId);
          message.setContent(strbody);
          message.setSmsId(smsId);
          message.setReceiveDate(dateMms);
          String resultContent = StringUtils.getResultText(message, false);
          if (resultContent != null) {
            message.setResultContent(resultContent);
          }
          smsMessages.add(message);
        }
      }
    }

    List<Message> localMessages =
        DataSupport.where("readStatus = ?", "0").order("date asc").find(Message.class);
    for (Message message : localMessages) {
      if (message.getDate() != null) {
        message.setIsMessage(true);
        boolean find = false;
        for (int u = 0; u < smsMessages.size(); u++) {
          if (message.getDate().getTime() > smsMessages.get(u).getDate().getTime()) {
            smsMessages.add(u, message);
            find = true;
            break;
          }
        }
        if (!find) {
          smsMessages.add(message);
        }
      }
    }

    List<Message> unionMessages = new ArrayList<>();
    for (Message message : smsMessages) {
      String group = TimeUtils.getInstance().getDateGroup(message.getDate());
      if (dateGroups.size() == 0) {
        dateGroups.add(group);
        Message dateMessage = new Message();
        dateMessage.setReceiveDate(group);
        dateMessage.setIsMessage(false);
        unionMessages.add(dateMessage);
      } else {
        if (!group.equals(dateGroups.get(dateGroups.size() - 1))) {
          dateGroups.add(group);
          Message dateMessage = new Message();
          dateMessage.setReceiveDate(group);
          dateMessage.setIsMessage(false);
          unionMessages.add(dateMessage);
        }
      }
      unionMessages.add(message);
    }

    cursor.close();
    return unionMessages;
  }