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();
  }
 /**
  * 获取兴趣爱好
  *
  * @return
  */
 public static ArrayList<Hobby> getHobbyData() {
   ArrayList<Hobby> allHobbys = null;
   allHobbys = (ArrayList<Hobby>) DataSupport.findAll(Hobby.class);
   if (allHobbys == null || allHobbys.isEmpty()) {
     Hobby hobby1 = new Hobby(1, "上网");
     allHobbys.add(hobby1);
     Hobby hobby2 = new Hobby(2, "研究汽车");
     allHobbys.add(hobby2);
     Hobby hobby3 = new Hobby(3, "养小动物");
     allHobbys.add(hobby3);
     Hobby hobby4 = new Hobby(4, "摄影");
     allHobbys.add(hobby4);
     Hobby hobby5 = new Hobby(5, "看电影");
     allHobbys.add(hobby5);
     Hobby hobby6 = new Hobby(6, "听音乐");
     allHobbys.add(hobby6);
     Hobby hobby7 = new Hobby(7, "写作");
     allHobbys.add(hobby7);
     Hobby hobby8 = new Hobby(8, "购物");
     allHobbys.add(hobby8);
     Hobby hobby9 = new Hobby(9, "做手工艺");
     allHobbys.add(hobby9);
     Hobby hobby10 = new Hobby(10, "做手工");
     allHobbys.add(hobby10);
     Hobby hobby11 = new Hobby(11, "跳舞");
     allHobbys.add(hobby11);
     Hobby hobby12 = new Hobby(12, "看展览");
     allHobbys.add(hobby12);
     Hobby hobby13 = new Hobby(13, "烹饪");
     allHobbys.add(hobby13);
     Hobby hobby14 = new Hobby(14, "读书");
     allHobbys.add(hobby14);
     Hobby hobby15 = new Hobby(15, "会话");
     allHobbys.add(hobby15);
     Hobby hobby16 = new Hobby(16, "研究计算机");
     allHobbys.add(hobby16);
     Hobby hobby17 = new Hobby(17, "做运动");
     allHobbys.add(hobby17);
     Hobby hobby18 = new Hobby(18, "旅游");
     allHobbys.add(hobby18);
     Hobby hobby19 = new Hobby(19, "玩电玩");
     allHobbys.add(hobby19);
     Hobby hobby20 = new Hobby(20, "其它");
     allHobbys.add(hobby20);
     DataSupport.saveAll(allHobbys);
   }
   return allHobbys;
 }
  @Override
  protected void successViewCompleted(View successView) {

    ButterKnife.bind(this, successView);
    getSunyardOil();
    registered_success.setOnClickListener(this);
    registration_agreement.setOnClickListener(this);

    latitude =
        SharedPreferencesUtil.getFromFileByDefault(
            mContext, "latitude", Constants.DEFAULT_LATITUDE);
    longitude =
        SharedPreferencesUtil.getFromFileByDefault(
            mContext, "longitude", Constants.DEFAULT_LONGITUDE);
    cityName =
        SharedPreferencesUtil.getFromFileByDefault(
            mContext, "cityName", Constants.DEFAULT_CITYNAME);
    List<CityListDetail> cityListDetails =
        DataSupport.select("sid", "divisionname")
            .where("divisionname like ?", cityName + '%')
            .find(CityListDetail.class);

    // cityListDetails.get(0).getSid()
    // SharedPreferencesUtil.getFromFileByDefault(mContext,"",Constants.DEFAULTY_CITYCODE);

    if (cityListDetails != null && cityListDetails.size() > 0) {
      cityId = cityListDetails.get(0).getSid();
    } else {
      cityId = Constants.DEFAULTY_CITYCODE;
    }

    time = new TimeCount(120000, 1000); // 构造CountDownTimer对象
  }
Beispiel #4
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);
 }
Beispiel #5
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);
 }
 /**
  * 获取个性特征
  *
  * @return
  */
 public static ArrayList<Disposition> getDispositionData() {
   ArrayList<Disposition> allDisposition = null;
   allDisposition = (ArrayList<Disposition>) DataSupport.findAll(Disposition.class);
   if (allDisposition == null || allDisposition.isEmpty()) {
     Disposition disposition1 = new Disposition(1, "宅");
     allDisposition.add(disposition1);
     Disposition disposition2 = new Disposition(2, "感性");
     allDisposition.add(disposition2);
     Disposition disposition3 = new Disposition(3, "体贴");
     allDisposition.add(disposition3);
     Disposition disposition4 = new Disposition(4, "憨厚");
     allDisposition.add(disposition4);
     Disposition disposition5 = new Disposition(5, "稳重");
     allDisposition.add(disposition5);
     Disposition disposition6 = new Disposition(6, "好强");
     allDisposition.add(disposition6);
     Disposition disposition7 = new Disposition(7, "冷静");
     allDisposition.add(disposition7);
     Disposition disposition8 = new Disposition(8, "温柔");
     allDisposition.add(disposition8);
     Disposition disposition9 = new Disposition(9, "闷骚");
     allDisposition.add(disposition9);
     Disposition disposition10 = new Disposition(10, "自我");
     allDisposition.add(disposition10);
     Disposition disposition11 = new Disposition(11, "幽默");
     allDisposition.add(disposition11);
     Disposition disposition12 = new Disposition(12, "正直");
     allDisposition.add(disposition12);
     Disposition disposition13 = new Disposition(13, "讲义气");
     allDisposition.add(disposition13);
     Disposition disposition14 = new Disposition(14, "孝顺");
     allDisposition.add(disposition14);
     Disposition disposition15 = new Disposition(15, "勇敢");
     allDisposition.add(disposition15);
     Disposition disposition16 = new Disposition(16, "有责任心");
     allDisposition.add(disposition16);
     Disposition disposition17 = new Disposition(17, "好动");
     allDisposition.add(disposition17);
     Disposition disposition18 = new Disposition(18, "随和");
     allDisposition.add(disposition18);
     DataSupport.saveAll(allDisposition);
   }
   return allDisposition;
 }
    @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 saveInfo(String id) {
    if (pDialog != null) {
      pDialog.dismiss();
    }
    ContentValues values = new ContentValues();
    values.put("state", "已派工");
    DataSupport.updateAll(BusinessData.class, values, "user = ? and orderId = ?", userNo, orderId);
    ToastUtil.showToast(DistributeActivity.this, "派工成功", Toast.LENGTH_SHORT);

    Intent intent = new Intent("action.com.gzrijing.workassistant.LeaderFragment.Distribute");
    intent.putExtra("orderId", orderId);
    sendBroadcast(intent);
    finish();
  }
 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);
     }
   }
 }
    /**
     * 这个函数有毒
     *
     * @param params
     * @return
     */
    @Override
    protected List<AppInfo> doInBackground(Void... params) {

      appInfos.clear();
      appInfos.addAll(adapter.getAppInfos());

      List<MonitorApp> all = DataSupport.findAll(MonitorApp.class);

      //  去除掉所有已经加载过的app
      Iterator<MonitorApp> iterator = all.iterator();
      while (iterator.hasNext()) {
        MonitorApp app = iterator.next();

        for (AppInfo info : appInfos) {
          if (info.getPackName().equals(app.getPackName())) {
            iterator.remove();
          }
        }
      }

      List<AppInfo> temp = new ArrayList<>();

      for (MonitorApp app : all) {
        AppInfo appInfo = new AppInfo();

        appInfo.setPackName(app.getPackName());
        appInfo.setAppName(app.getAppName());

        // 暂时不获取app的icon
        Drawable icon = getIcon(app.getPackName());

        if (icon != null) {
          if (wantWhite() == app.isWhite()) {
            appInfo.setAppIcon(icon);
            appInfos.add(appInfo);
            temp.add(appInfo);
          }
        }
      }
      return temp;
    }
Beispiel #11
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;
  }
Beispiel #12
0
 /**
  * 根据id加载账单
  *
  * @param id
  * @return
  */
 public static Bill load(Long id) {
   return DataSupport.find(Bill.class, id, true);
 }
Beispiel #13
0
 /**
  * 返回db中账单的总记录数
  *
  * @return
  */
 public static int DataCount() {
   return DataSupport.count(Bill.class);
 }