コード例 #1
0
  @Override
  protected void preLoadData(Bundle savedInstanceState) {
    super.preLoadData(savedInstanceState);

    account = AccountProxy.getInstance().getCurrentAccount();

    /** 获取身体状况资料 */
    mBodyStateTask =
        new EditQAHealthTask(account.getAccessToken(), null, null, null, true, "sick_");
    mBodyStateTask.setProgress(
        new CustomDialogProgress(this, getString(string.punlic_personal_loading)));
    mBodyStateTask.setTaskHost(
        new TaskHost() {
          @Override
          public void onPostExecute(int requestCode, BaseResult result) {
            super.onPostExecute(requestCode, result);
            switch (result.getErrorCode()) {
              case LocalCode.CODE_SUCCESS:
                bodyStates = QAHealth.createQAHealthList((NetworkClientResult) result);
                AccountPreference.getInstance().saveBodyState(bodyStates);
                fillView();
                break;
              default:
                ErrorDialogUtil.showErrorToast(
                    SettingChangeBodyStateActivity.this,
                    CloudStatusCodeProxy.TYPE_SETTING,
                    result.getErrorCode());
                finish();
                break;
            }
          }
        });
    mBodyStateTask.execute();
  }
コード例 #2
0
  private void submitQuestionnaire() {

    if (mSubmitTask == null || mSubmitTask.getStatus() != Status.RUNNING) {
      final String uploadJSON = obtainBodyStateJSON(bodyStates);
      mSubmitTask = new EditQAHealthTask(account.getAccessToken(), uploadJSON, null);
      mSubmitTask.setProgress(
          new CustomDialogProgress(this, getString(string.punlic_personal_change)));
      mSubmitTask.setTaskHost(
          new TaskHost() {
            public void onPostExecute(int requestCode, BaseResult result) {
              switch (result.getErrorCode()) {
                case LocalCode.CODE_SUCCESS:
                  // 保存身体状况
                  AccountPreference.getInstance().saveBodyState(bodyStates);
                  ToastUtils.show(
                      SettingChangeBodyStateActivity.this,
                      getString(string.personal_change_success));
                  setResult(RESULT_OK);
                  finish();
                  break;
                default:
                  ErrorDialogUtil.showErrorToast(
                      SettingChangeBodyStateActivity.this,
                      CloudStatusCodeProxy.TYPE_SETTING,
                      result.getErrorCode());
                  break;
              }
            };
          });
      mSubmitTask.execute();
    }
  }