Esempio n. 1
0
  /**
   * 我的任务(已提交)
   *
   * @param context
   * @param view
   * @param aif
   */
  public MTaskOldPage(Context context, View view, ActivityInterface aif) {

    LogPrint.Print("MTaskOldPage==initView===" + this);
    mContext = context;
    activityInterface = aif;
    expandableListView = (MExpandListView) view.findViewById(R.id.my_task_list_old);
    mExpandListAdatpger = new MExpandListAdatpger(context, arrayListOld);
    mExpandListAdatpger.setOnCheckOPenGroupLisrener(this);
    mExpandListAdatpger.setPageListener(this);
    expandableListView.setAdapter(mExpandListAdatpger);
    expandableListView.setOnGroupClickListener(this);
    expandableListView.setOnChildClickListener(this);
    text = (TextView) view.findViewById(R.id.my_task_text);

    expandableListView.setRefreshListener(
        new RefreshList() {

          @Override
          public void onRefershList() {
            if (arrayListOld.size() >= 20) {

              getCimmitDataFromSerlver(true);
            }
          }
        });
  }
Esempio n. 2
0
 public void delete() {
   TaskPoint point = mExpandListAdatpger.getTaskPoint(groupPosition, childPosition);
   TaskDetail detail = mExpandListAdatpger.getTaskDetail(groupPosition);
   String path = SdcardUtil.getSdcardCollInfo() + detail.getId() + "/" + point.getIname();
   mTaskPage.deletePhoto(path);
   mTaskPage.deletePhoto(SdcardUtil.getSdcardCollInfo() + detail.getId());
   DManager.getInstance(mContext).deletePoint(point.getCameraId());
 }
Esempio n. 3
0
 @Override
 public void showOtherPage(int group) {
   TaskDetail detail = mExpandListAdatpger.getTaskDetail(group);
   activityInterface.setOldTaskDetail(detail);
   activityInterface.showPage(
       Configs.VIEW_POSITION_MY_TASK, this, Configs.VIEW_POSITION_OLD_DETAIL, 0, null, null);
 }
Esempio n. 4
0
 @Override
 public void onDetachedFromWindow(int flag) {
   arrayListOld.clear();
   start = 0;
   mExpandListAdatpger.notifyDataSetChanged();
   end = 20;
   super.onDetachedFromWindow(flag);
 }
Esempio n. 5
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();
   }
 }
Esempio n. 6
0
  @Override
  public boolean onChildClick(
      ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
    TaskPoint taskPoint = mExpandListAdatpger.getTaskPoint(groupPosition, childPosition);
    activityInterface.setOldTaskPiint(taskPoint);
    activityInterface.showPage(
        Configs.VIEW_POSITION_MY_OLD,
        mTaskPage,
        Configs.VIEW_POSITION_OLD_ITEM_DETAIL,
        0,
        null,
        null);

    return false;
  }
Esempio n. 7
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();
 }
Esempio n. 8
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();
  }
Esempio n. 9
0
  /**
   * 检测扩展列表的子元素是否选中
   *
   * @param type
   */
  protected HashMap<Integer, LinkedList<Integer>> getCheckedState() {
    HashMap<Integer, LinkedList<Integer>> map = new HashMap<Integer, LinkedList<Integer>>();
    Map<Integer, HashMap<Integer, Boolean>> child = mExpandListAdatpger.getChildGroupSelected();
    if (child.size() > 0) {

      Set<Entry<Integer, HashMap<Integer, Boolean>>> set_child = child.entrySet();
      Iterator<Entry<Integer, HashMap<Integer, Boolean>>> iterator_child = set_child.iterator();
      LinkedList<Integer> list = null;
      while (iterator_child.hasNext()) {
        Entry<Integer, HashMap<Integer, Boolean>> entry = iterator_child.next();
        HashMap<Integer, Boolean> value = entry.getValue();
        int group_positon = entry.getKey();
        Set<Integer> value_set = value.keySet();
        Iterator<Integer> v_iteor = value_set.iterator();
        list = new LinkedList<Integer>();
        while (v_iteor.hasNext()) {
          int childPosition = v_iteor.next();
          list.add(childPosition);
        }
        map.put(group_positon, list);
      }
    }
    return map;
  }
Esempio n. 10
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;
          }
        };
Esempio n. 11
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();
  }