private void requestVerifyCode(String verifyCode) {
   CallService csPost =
       new CallService(
           CallMethod.POST, cmdVerifySignupPhone, null, null, deviceId, version, locale, this);
   try {
     String url =
         Webservice.get(
             Webservice.confirmSignupPhone,
             URLEncoder.encode(phoneCode, "UTF-8"),
             URLEncoder.encode(phoneNumber, "UTF-8"),
             URLEncoder.encode(verifyCode, "UTF-8"));
     csPost.execute(url);
   } catch (UnsupportedEncodingException e) {
     Log.d(TAG + ":checkRegister", e.getMessage());
     hideLoading();
   }
 }
예제 #2
0
 private void requestGetUserInfo() {
   CallService customPost =
       new CallService(
           CallMethod.POST,
           "getUserInfo",
           mActivity.getUserId(),
           mActivity.getToken(),
           mActivity.getDeviceId(),
           mActivity.getVersion(),
           mActivity.getLocale(),
           new JsonCallBackListener() {
             @Override
             public void handleData(String mCmd, JSONObject json) throws JSONException {
               //                if (mActivity != null) {
               //                    mActivity.hideLoading();
               //                }
               if (json != null) {
                 int status = json.getInt("StatusCode");
                 if (status == 1) {
                   JSONObject userInfo = json.getJSONArray("Data").getJSONObject(0);
                   BLSharePreferences.setUserInfo(context, userInfo.toString());
                   setInfo(userInfo);
                   sendBroadcastUpdateProfile();
                 }
               }
               hideLoading();
             }
           });
   try {
     String url = Webservice.makeGetProfileURL(userID);
     customPost.execute(url);
   } catch (Exception e) {
     hideLoading();
     Logs.log(e);
     //            if (mActivity != null) {
     //                mActivity.hideLoading();
     //            }
   }
 }
예제 #3
0
  private void requestUpdateAvatar() {
    final File file = new File(filePath);
    if (file.exists() && file.canRead() && file.isFile()) {
      if (file.length() > Values.FILE_SIZE_LIMIT) {
        hideLoading();
        UIUtils.alert(context, getString(R.string.file_size_must_be_less_than_size_limit, "30MB"));
        return;
      }
    } else {
      hideLoading();
      UIUtils.alert(context, R.string.file_not_found);
      return;
    }
    //        Toast.makeText(context, "requestUpdateAvatar() called!", Toast.LENGTH_SHORT).show();
    try {
      final String url =
          Webservice.get(Webservice.URL_UPDATE_PROFILE_AVATAR, mActivity.getUserId());

      uploadTask =
          new AsyncTask<Object, Object, String>() {
            @Override
            protected String doInBackground(Object... params) {
              String response =
                  HttpUtils.uploadFileByPost(
                      url,
                      mActivity.getUserId(),
                      mActivity.getToken(),
                      mActivity.getDeviceId(),
                      mActivity.getVersion(),
                      mActivity.getLocale(),
                      file,
                      Contains.FILE_TYPE_IMAGE,
                      filePath);
              return response;
            }

            @Override
            protected void onPostExecute(String response) {
              if (response != null) {
                try {
                  JSONObject json = new JSONObject(response);
                  //                            Log.d(TAG, json.toString());
                  //                            UIUtils.alert(context, "return: " +
                  // json.toString());
                  if (json != null) {
                    int status = json.getInt("StatusCode");
                    if (status == 1) {
                      JSONObject userInfo = json.getJSONObject("Data");
                      BLSharePreferences.setUserInfo(context, userInfo.toString());
                      setInfo(userInfo);
                      sendBroadcastUpdateProfile();
                    } else {
                      try {
                        String errorCode = json.get("errorCode").toString();
                        if (errorCode.equals(ErrorCode.CODE_CONNECT_SERVER_FAIL)) {
                          UIUtils.alert(
                              context,
                              R.string.connect_to_server_failed_plz_wait_a_moment_and_try_again);
                        } else {
                          UIUtils.alert(context, "errorCode: " + errorCode);
                        }
                      } catch (Exception e) {
                        UIUtils.alert(context, json.toString());
                        Log.d(TAG, json.toString());
                      }
                    }
                  }
                } catch (Exception e) {
                  e.printStackTrace();
                  UIUtils.alert(context, "Exception: " + e.getMessage());
                }
              } else {
                UIUtils.alert(context, R.string.upload_failed);
              }
              hideLoading();
            }
          };

      boolean isPending = (uploadTask.getStatus().equals(AsyncTask.Status.PENDING));
      if (isPending) {
        Log.i(TAG, "upFile + " + isPending);
        uploadTask.execute();
        if (uploadTask.getStatus().equals(AsyncTask.Status.FINISHED)) {
          uploadTask = null;
        }
      }

    } catch (Exception e) {
      hideLoading();
      e.printStackTrace();
    }
  }