コード例 #1
0
  public List<Info> doGetInfoTask(Task task) {
    List<Info> infos = null;
    String getinfo_url = null;
    Map<String, Object> taskParams = task.getTaskParams();
    int mode = (Integer) taskParams.get(Task.TA_GETINFO_MODE);
    String infoId = null;
    switch (mode) {
      case Task.TA_GETINFO_MODE_FIRSTTIME:
        getinfo_url = HttpClientUtil.BASE_URL + "data/news/newsList2Down_2";
        break;

      case Task.TA_GETINFO_MODE_PULLREFRESH:
        infoId = (String) taskParams.get(Task.TA_GETINFO_INFOID);
        getinfo_url = HttpClientUtil.BASE_URL + "data/news/newsList2Down_2?news_id=" + infoId;
        break;

      case Task.TA_GETINFO_MODE_LOADMORE:
        infoId = (String) taskParams.get(Task.TA_GETINFO_INFOID);
        getinfo_url = HttpClientUtil.BASE_URL + "data/news/newsList2Up_2?news_id=" + infoId;
        break;

      default:
        break;
    }
    try {
      String jsonString = HttpClientUtil.getRequest(getinfo_url);
      infos = JsonUtil.getInfos(jsonString);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return infos;
  }
コード例 #2
0
  /*
   * 获取List<Status>(任务)
   * 分为三种,分别是第一次加载,下拉刷新,上拉加载更多
   */
  public List<Status> doGetStatusTask(Task task) {
    List<Status> listStatus = null;
    String getstatus_url = null;
    Map<String, Object> taskParams = task.getTaskParams();
    int type = (Integer) taskParams.get(Task.TA_GETSTATUS_TYPE);
    int mode = (Integer) taskParams.get(Task.TA_GETSTATUS_MODE);
    String statusId = null, personId = null;
    switch (mode) {
      case Task.TA_GETSTATUS_MODE_FIRSTTIME:
        getstatus_url = HttpClientUtil.BASE_URL + "data/task/taskList2Down";
        break;

      case Task.TA_GETSTATUS_MODE_LOADMORE:
        statusId = (String) taskParams.get(Status.STATUS_ID);
        getstatus_url = HttpClientUtil.BASE_URL + "data/task/taskList2Up?task_id=" + statusId;
        break;

      default:
        break;
    }

    switch (type) {
      case Task.TA_GETSTATUS_TYPE_ALL:
        break;

      case Task.TA_GETSTATUS_TYPE_MY_RELEASE:
        personId = (String) taskParams.get(Person.PERSON_ID);
        if (Task.TA_GETSTATUS_MODE_FIRSTTIME == mode) {
          getstatus_url += "?my=" + personId;
        } else {
          getstatus_url += "&my=" + personId;
        }
        break;

      case Task.TA_GETSTATUS_TYPE_MY_SIGNUP:
        personId = (String) taskParams.get(Person.PERSON_ID);
        if (Task.TA_GETSTATUS_MODE_FIRSTTIME == mode) {
          getstatus_url += "?sign=" + personId;
        } else {
          getstatus_url += "&sign=" + personId;
        }
        break;

      default:
        break;
    }

    try {
      String jsonString = HttpClientUtil.getRequest(getstatus_url);
      /*如果数组长度为0,则链表长度为0,但他不为空,因为在里面已经new了,
       * 所以有联网状态下,没有更新与没有更多的时候,0 == listStatus.size() 成立,但listStatus不为空*/
      listStatus = JsonUtil.getListStatus(jsonString);
    } catch (Exception e) {
      /*没网络,会返回null*/
      e.printStackTrace();
    }
    return listStatus;
  }
コード例 #3
0
 public SignUpListTaskDetail doGetSignUpListDetailTask(Task task) {
   SignUpListTaskDetail st = null;
   Map<String, Object> taskParams = task.getTaskParams();
   String signUpId = (String) taskParams.get(SignUp.SIGNUP_ID);
   String url = HttpClientUtil.BASE_URL + "/data/sign/sd?sign_id=" + signUpId;
   try {
     String jsonString = HttpClientUtil.getRequest(url);
     st = JsonUtil.getSignUpListTaskDetail(jsonString);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return st;
 }
コード例 #4
0
 public List<SignUp> doGetSignUpListTask(Task task) {
   List<SignUp> signUps = null;
   Map<String, Object> taskParams = task.getTaskParams();
   String statusId = (String) taskParams.get(Status.STATUS_ID);
   String get_signup_list_url = HttpClientUtil.BASE_URL + "data/sign/signlist?task_id=" + statusId;
   try {
     String jsonString = HttpClientUtil.getRequest(get_signup_list_url);
     signUps = JsonUtil.getSignUps(jsonString);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return signUps;
 }
コード例 #5
0
 public Status doGetTaskDetail(Task task) {
   Status status = null;
   Map<String, Object> taskParams = task.getTaskParams();
   String statusId = (String) taskParams.get(Status.STATUS_ID);
   String get_task_url = HttpClientUtil.BASE_URL + "data/task/info?task_id=" + statusId;
   try {
     String jsonString = HttpClientUtil.getRequest(get_task_url);
     status = JsonUtil.getStatus(jsonString);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return status;
 }
コード例 #6
0
 public List<Rank> doGetRankTask(Task task) {
   List<Rank> ranks = null;
   Map<String, Object> taskParams = task.getTaskParams();
   String mode = (String) taskParams.get(Task.TA_GETRANK_MODE);
   String get_rank_url = HttpClientUtil.BASE_URL + "data/ranking/list?type=" + mode;
   try {
     String jsonString = HttpClientUtil.getRequest(get_rank_url);
     ranks = JsonUtil.getRanks(jsonString);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return ranks;
 }
コード例 #7
0
 /*获取Person信息*/
 public Person doGetUserDataTask(Task task) {
   Person person = null;
   Map<String, Object> taskParams = task.getTaskParams();
   String personId = (String) taskParams.get(Task.TA_GETUSERDATA_TASKPARAMS);
   String getuserdata_url = HttpClientUtil.BASE_URL + "data/user/userInfo?users_id=" + personId;
   try {
     String jsonString = HttpClientUtil.getRequest(getuserdata_url);
     person = JsonUtil.getPerson(jsonString);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return person; // 此处如果未连接网络的话,返回的是null
 }
コード例 #8
0
 /*
  * 获取留言
  */
 public List<com.example.taupstairs.bean.Message> doGetMessageTask(Task task) {
   List<com.example.taupstairs.bean.Message> messages = null;
   Map<String, Object> taskParams = task.getTaskParams();
   String statusId = (String) taskParams.get(Status.STATUS_ID);
   String get_message_url =
       HttpClientUtil.BASE_URL + "data/taskmsg/taskMsgList2Down?task_id=" + statusId;
   try {
     String jsonString = HttpClientUtil.getRequest(get_message_url);
     messages = JsonUtil.getMessages(jsonString);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return messages;
 }
コード例 #9
0
 public Object doGetInfoDetailTask(Task task) {
   Object result = null;
   Map<String, Object> taskParams = task.getTaskParams();
   String infoSource = (String) taskParams.get(Info.INFO_SOURCE);
   String infoType = (String) taskParams.get(Info.INFO_TYPE);
   String getinfo_detail_url =
       HttpClientUtil.BASE_URL + "data/news/detail?source=" + infoSource + "&type=" + infoType;
   if (infoType.equals("2") || infoType.equals("5")) {
     getinfo_detail_url =
         HttpClientUtil.BASE_URL + "data/news/detail_2?source=" + infoSource + "&type=" + infoType;
   }
   try {
     String jsonString = HttpClientUtil.getRequest(getinfo_detail_url);
     int type = Integer.parseInt(infoType);
     result = JsonUtil.getInfoDetail(type, jsonString);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return result;
 }