Example #1
0
 @Override
 public void onDetachedFromWindow(int flag) {
   arrayListOld.clear();
   start = 0;
   mExpandListAdatpger.notifyDataSetChanged();
   end = 20;
   super.onDetachedFromWindow(flag);
 }
Example #2
0
 /**
  * 加载(已提交)数据
  *
  * @param visible
  */
 public void setListVisible(int visible) {
   vis = visible;
   expandableListView.setVisibility(visible);
   if (visible == View.VISIBLE) {
     getCimmitDataFromSerlver(false);
     // setTotal();
   } else {
     start = 0;
     end = 20;
     mExpandListAdatpger.notifyDataSetChanged();
     arrayListOld.clear();
   }
 }
Example #3
0
 /** 从数据库中获取要显示的数据 */
 private void setTaskDetail(int start, int end) {
   arrayListOld.clear();
   ArrayList<TaskDetail> details =
       DManager.getInstance(mContext).queryAllOldTaskByLimit(start, end);
   if (details.size() > 0) this.start = end;
   for (int i = 0; i < details.size(); i++) {
     TaskDetail taskDetail = details.get(i);
     ArrayList<TaskPoint> points =
         DManager.getInstance(mContext).queryPoint(taskDetail.getId(), MColums.OLD);
     if (points.size() == 0) {
       DManager.getInstance(mContext).deleteOldTaskDetail(taskDetail.getId());
       continue;
     }
     taskDetail.setList(points);
     arrayListOld.add(taskDetail);
   }
   mExpandListAdatpger.notifyDataSetChanged();
 }
Example #4
0
  /** 从数据库中获取要显示的数据 */
  private void setTaskDetail() {
    ArrayList<TaskDetail> details =
        DManager.getInstance(mContext).queryAllOldTaskByLimit(start, end);
    ArrayList<TaskPoint> points = null;
    if (details.size() > 0) start = start + 20;
    for (int i = 0; i < details.size(); i++) {
      TaskDetail taskDetail = details.get(i);
      points = DManager.getInstance(mContext).queryPoint(taskDetail.getId(), MColums.OLD);
      if (points.size() == 0) {
        DManager.getInstance(mContext).deleteOldTaskDetail(taskDetail.getId());
        continue;
      }
      taskDetail.setList(points);
      arrayListOld.add(taskDetail);
    }
    if (details.size() > 0) {

      setTaskSize(details.size(), points.size(), String.valueOf(0));
    }
    if (arrayListOld.size() == 0) expandableListView.setVisibility(View.GONE);
    handler.sendEmptyMessageDelayed(wait_pr0bar, 1000);
    mExpandListAdatpger.notifyDataSetChanged();
  }
Example #5
0
        public void handleMessage(android.os.Message msg) {
          switch (msg.what) {
            case delete_next:
              mExpandListAdatpger.notifyDataSetChanged();

              if (chlid_list.size() > 0) chlid_list.remove(0);
              if (chlid_list.size() > 0) {

                delete();
                setUpload2();
                break;
              } else {
                if (list_group_position.size() > 0) list_group_position.remove(0);
                if (list_group_position.size() > 0) {
                  delete();
                  setUpload();
                  break;
                } else {
                  delete();
                  setTaskDetail(0, start + end);
                  activityInterface.dismissNetDialog();
                  mExpandListAdatpger.notifyDataSetChanged();
                  mExpandListAdatpger.reStore();
                  break;
                }
              }

              // delete();
              // setUpload2();
              // break;
            case delete_false:
              setTaskDetail(0, start + end);
              mExpandListAdatpger.notifyDataSetChanged();
              activityInterface.dismissNetDialog();
              mExpandListAdatpger.reStore();
              break;
            case wait_pr0bar:
              expandableListView.closeFooter();
              break;
            case delete_null:
              activityInterface.dismissNetDialog();

              if (mExpandListAdatpger.getDataSize() > 0)
                Toast.makeText(mContext, "请选择要删除的数据", 0).show();
              else Toast.makeText(mContext, "您没有任何任务", 0).show();
              break;

            case null_null:
              Toast.makeText(mContext, "请选择要删除的点", 0).show();
              break;
            case fail:
              setTaskSize(0, 0, String.valueOf(0));
              expandableListView.closeFooter();
              activityInterface.dismissNetDialog();
              String str = (String) msg.obj;
              activityInterface.ShowCodeDialog(Integer.valueOf(str), MTaskOldPage.this);
              break;
            case netWrong:
              setTaskSize(0, 0, String.valueOf(0));
              expandableListView.closeFooter();
              activityInterface.dismissNetDialog();
              Toast.makeText(mContext, "获取内容失败", 0).show();
              break;
            case TIMEOUT:
              setTaskSize(0, 0, String.valueOf(0));
              expandableListView.closeFooter();
              activityInterface.dismissNetDialog();
              Toast.makeText(mContext, "网络不给力,请检查网络!", 0).show();
              break;
            case success:
              expandableListView.closeFooter();
              ArrayList<TaskDetail> waitTaskList = (ArrayList<TaskDetail>) msg.obj;
              for (int i = 0; i < waitTaskList.size(); i++) {
                TaskDetail cimmit = waitTaskList.get(i);
                arrayListOld.add(cimmit);
              }
              if (waitTaskList.size() > 0) {
                setTaskSize(waitTaskList.size(), 0, String.valueOf(0));
              }
              activityInterface.dismissNetDialog();
              // mExpandListAdatpger.setListTaskDetails(arrayListOld);
              mExpandListAdatpger.notifyDataSetChanged();
              break;

            default:
              break;
          }
        };
Example #6
0
  /**
   * 网络获取已提交任务
   *
   * @param bl false 是刷新 不删除集合
   */
  private void getCimmitDataFromSerlver(boolean bl) {
    activityInterface.showNetWaitDialog(mContext.getResources().getString(R.string.dialog_net));
    if (builder == null) builder = new StringBuilder();
    else builder.delete(0, builder.length());

    TaskDetail taskDe = null;

    if (!bl && arrayListOld.size() > 0) {
      arrayListOld.clear();
      mExpandListAdatpger.notifyDataSetChanged();
    }

    int satrt = arrayListOld.size();
    int end = 20;
    if (arrayListOld.size() > 0) {
      taskDe = arrayListOld.get(arrayListOld.size() - 1);
    }

    builder.append(UrlConfig.getMyTaskCimmit);
    builder.append("token=" + StringUtils.getLoginToken(mContext));
    builder.append("&loginId=" + StringUtils.getLoginId(mContext));
    builder.append("&start=" + satrt);
    builder.append("&max=" + end);

    if (taskDe != null) {
      builder.append("&currentTime=" + taskDe.getCurrentTime());
    }
    LogPrint.Print("getMyTaskCimmit===" + builder.toString());
    httpHandler = new MHttpHandler(mContext);
    httpHandler.setCache(CacheType.NOCACHE);
    httpHandler.setRequest(builder.toString(), HttpRequestType.GET);
    httpHandler.setHttpHandlerListener(
        new HttpHandlerListener() {

          @SuppressWarnings("unused")
          @Override
          public void onResponse(int arg0, String arg1, byte[] data) {
            if (data != null) {
              try {
                String jsonStr = new String(data, "UTF-8");
                JSONObject jsonObject = new JSONObject(jsonStr);

                boolean b = jsonObject.getBoolean("result");
                if (b) {
                  String messageString = jsonObject.getString("message");
                  if (!StringUtils.isNullColums(messageString)) {

                    ArrayList<TaskDetail> waitTaskList = new ArrayList<TaskDetail>();
                    JSONObject dataJson = (JSONObject) jsonObject.get("data");
                    JSONArray jsonRowsArray = (JSONArray) dataJson.get("rows");
                    if (jsonRowsArray.length() > 0) {

                      String curTime = "0";
                      if (jsonObject.getString("id") != null
                          && !jsonObject.getString("id").equals("")) {

                        curTime = jsonObject.getString("id");
                      }
                      TaskDetail task;
                      List<TaskPoint> list;
                      TaskPoint taskPoint;
                      for (int i = 0; i < jsonRowsArray.length(); i++) {
                        task = new TaskDetail();
                        list = new ArrayList<TaskPoint>();
                        // JSONObject json = dataJson.getJSONObject(i);
                        JSONObject jsonTask = jsonRowsArray.getJSONObject(i);
                        task.setStartTime(
                            StringUtils.isNullColums(jsonTask.getString("createTime"))
                                ? ""
                                : jsonTask.getString("createTime"));
                        task.setLostTime(
                            StringUtils.isNullColums(jsonTask.getString("exceedTime"))
                                ? ""
                                : jsonTask.getString("exceedTime"));
                        task.setType(jsonTask.getInt("taskType") + "");
                        task.setCloseTime(
                            StringUtils.isNullColums(jsonTask.getString("clostTime"))
                                ? ""
                                : jsonTask.getString("clostTime"));
                        task.setDescription(
                            StringUtils.isNullColums(jsonTask.getString("description"))
                                ? ""
                                : jsonTask.getString("description"));
                        task.setExecutorTime(
                            StringUtils.isNullColums(jsonTask.getString("executorTime"))
                                ? ""
                                : jsonTask.getString("executorTime"));
                        task.setId(jsonTask.getString("id"));
                        task.setUpdateTime(
                            StringUtils.isNullColums(jsonTask.getString("lastUpdateTime"))
                                ? ""
                                : jsonTask.getString("lastUpdateTime"));
                        task.setName(jsonTask.getString("name"));
                        if (jsonTask.getInt("taskType") == 2) {

                          task.setRice(0.5);
                        } else {

                          task.setRice(
                              StringUtils.isNullColums(jsonTask.getDouble("price") + "")
                                  ? Double.parseDouble("0.0")
                                  : jsonTask.getDouble("price"));
                        }
                        // task.setRice(StringUtils.isNullColums(jsonTask.getDouble("price")+"") ?
                        // Double.parseDouble("0.0"):jsonTask.getDouble("price"));
                        task.setRoadcameraCount(jsonTask.getInt("roadcameraCount"));
                        // task.setVerifyInfo(jsonTask.getString("verifyInfo"));
                        task.setCurrentTime(curTime);
                        // 2014-11-7添加任务状态
                        // task.setStatus(jsonTask.getString("status"));
                        JSONArray jsonArray =
                            jsonRowsArray.getJSONObject(i).getJSONArray("roadcameraInfo");
                        for (int j = 0; j < jsonArray.length(); j++) {
                          taskPoint = new TaskPoint();
                          JSONObject object = jsonArray.getJSONObject(j);
                          // taskPoint.setAngle(StringUtils.isNullColums(object.getString("angle"))?"":object.getString("angle"));
                          taskPoint.setContent(object.getString("description"));
                          taskPoint.setOri(object.getString("direction"));
                          taskPoint.setCameraId(object.getString("id"));
                          // taskPoint.setLastTime(StringUtils.isNullColums(object.getString("lastTime"))?"":object.getString("lastTime"));
                          taskPoint.setLat(object.getDouble("latitude") + "");
                          taskPoint.setLon(object.getDouble("longitude") + "");

                          // 电子眼名称
                          taskPoint.setName(
                              StringUtils.isNullColums(object.getString("name"))
                                  ? ""
                                  : object.getString("name"));
                          // 电子眼图片名称
                          taskPoint.setIname(
                              StringUtils.isNullColums(object.getString("iname"))
                                  ? ""
                                  : object.getString("iname"));
                          // 电子眼单号
                          taskPoint.setOrder(
                              StringUtils.isNullColums(object.getString("order"))
                                  ? ""
                                  : object.getString("order"));

                          // taskPoint.setOrder(object.getString("odd"));
                          taskPoint.setPhotoUrl(object.getString("photoUrl"));
                          // taskPoint.setRefectReason(object.getString("refectReason"));
                          taskPoint.setLspeed(object.getString("speed"));
                          taskPoint.setStatus(object.getString("status"));
                          taskPoint.setCameraTypeText(object.getString("type"));
                          taskPoint.setTid(task.getId());
                          list.add(taskPoint);
                        }
                        task.setList(list);
                        waitTaskList.add(task);
                      }
                      Message message = handler.obtainMessage();
                      message.what = success;
                      message.obj = waitTaskList;
                      handler.sendMessage(message);
                    } else {

                      Message message = handler.obtainMessage();
                      message.what = fail;
                      message.obj = jsonObject.getString("message");
                      handler.sendMessage(message);
                    }
                  }

                } else {
                  Message message = handler.obtainMessage();
                  message.what = fail;
                  message.obj = jsonObject.getString("message");
                  handler.sendMessage(message);
                }

              } catch (Exception e) {
                handler.sendEmptyMessage(netWrong);
                e.printStackTrace();
              }

            } else {
              if (arg0 != 200) handler.sendEmptyMessage(netWrong);
              else handler.sendEmptyMessage(TIMEOUT);
            }
          }
        });
    httpHandler.execute();
  }