コード例 #1
0
  /** 获取选择课程列表 */
  private void getCourse() {
    if (!HttpHelper.isNetworkConnected(this)) {
      toast(R.string.toast_netwrok_disconnected);
      return;
    }
    showDialogRes(R.string.loading);
    HttpHelper.getHelper()
        .get(
            ApiUrl.COURSELIST,
            TutorApplication.getHeaders(),
            new RequestParams(),
            new ObjectHttpResponseHandler<CourseListResult>(CourseListResult.class) {

              @Override
              public void onFailure(int status, String message) {
                // 连接超时,再获取一次
                if (0 == status) {
                  getCourse();
                  return;
                }
                dismissDialog();
                toast(R.string.toast_server_error);
              }

              @Override
              public void onSuccess(CourseListResult t) {
                dismissDialog();
                if (null != t) {
                  if (schools != null && schools.size() > 0) {
                    schools.clear();
                  }
                  Course course = new Course();
                  course.setName(getString(R.string.label_please_choose));
                  schools.add(course);
                  schools.addAll(t.getResult());
                  setCourseSpinner();
                } else {
                  toast(R.string.toast_server_error);
                }
              }
            });
  }
コード例 #2
0
  /** 获取区域列表 */
  private void getAreas() {
    if (!HttpHelper.isNetworkConnected(this)) {
      toast(R.string.toast_netwrok_disconnected);
      return;
    }
    HttpHelper.getHelper()
        .get(
            ApiUrl.AREALIST,
            TutorApplication.getHeaders(),
            new RequestParams(),
            new ObjectHttpResponseHandler<AreaListResult>(AreaListResult.class) {

              @Override
              public void onFailure(int status, String message) {
                if (0 == status) {
                  getAreas();
                  return;
                }
                dismissDialog();
                toast(R.string.toast_server_error);
              }

              @Override
              public void onSuccess(AreaListResult t) {
                if (null != t) {
                  Area area = new Area();
                  area.setName(getString(R.string.label_please_choose));
                  citys.add(area);
                  citys.addAll(t.getResult());
                  setAreaSpinner();
                } else {
                  toast(R.string.toast_server_error);
                }
              }
            });
  }