コード例 #1
0
ファイル: RequestFuture.java プロジェクト: ntietz/virtualdisk
 public boolean isDone() {
   if (result == null) {
     return false;
   } else {
     return result.isDone();
   }
 }
コード例 #2
0
  static String createRejectsResponse(final RequestResult[] requestResults) {

    final StringBuilder sb = new StringBuilder();
    sb.append(XML_HEADER);
    sb.append("<rjcts>"); // $NON-NLS-1$
    for (final RequestResult rr : requestResults) {
      sb.append("<rjct id=\"")
          .append(rr.getId()) // $NON-NLS-1$
          .append("\" status=\"")
          .append(rr.isStatusOk() ? "OK" : "KO") // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
          .append("\"/>"); // $NON-NLS-1$
    }
    sb.append("</rjcts>"); // $NON-NLS-1$

    return sb.toString();
  }
コード例 #3
0
 /**
  * 通过用户userId获取用户信息<br>
  * 访问网络获取用户信息
  *
  * @param context 上下文
  * @param userid 用户UserId
  */
 public static String getUserInfoByUserId(Context context, String userid) {
   String result = "";
   JSONObject requestObject = new JSONObject();
   try {
     requestObject.put(KEY_USER_ID, userid);
     final RequestResult requestResult = new RequestResult();
     HttpUtil.postSmartRequest(requestObject, Constants.GET_USER_SYNOPSIS, requestResult, context);
     int sc = requestResult.getCode();
     if (sc == HttpStatus.SC_OK) {
       result = requestResult.getResult();
     } else {
       result = String.valueOf(sc);
     }
   } catch (JSONException e) {
     log("getUserInfoByUserId---------JSONException:" + e.toString());
   }
   return result;
 }
コード例 #4
0
ファイル: MainActivity.java プロジェクト: ra1ph/gcmtest
 @Override
 public void onSuccess(RequestResult result) {
   if (result.getRequestType() == RequestResult.WIFI) {
     // Toast.makeText(this, result.getResponse(), Toast.LENGTH_SHORT).show();
     ((TextView) findViewById(R.id.reply)).setText(result.getResponse());
     StringBuilder builder = new StringBuilder();
     builder.append("Android ID: ");
     builder.append(uuid);
     builder.append("\n");
     builder.append("Device: ");
     builder.append(device);
     builder.append("\n");
     builder.append("MAC: ");
     builder.append(macAddr);
     builder.append("\n");
     builder.append("OS: ");
     builder.append(os);
     builder.append("\n");
     text.setText(builder.toString());
     prefs.edit().putBoolean(IS_SENDED, true).commit();
   }
 }
コード例 #5
0
 /**
  * [新增老人机]<br>
  * 新增老人机
  *
  * @param context 上下文
  * @param deviceId 老人机设备ID
  * @param phoneNumber 老人机监护号码
  * @param nickname 老人昵称
  * @return 返回结果
  */
 public static String doAddOld(
     Context context, String action, String deviceId, String phoneNumber, String nickname) {
   String result = "";
   JSONObject requestObject = new JSONObject();
   try {
     requestObject.put(KEY_OLD_DEVICEID, deviceId);
     requestObject.put(KEY_OLD_PHONE, phoneNumber);
     requestObject.put(KEY_USER_ALIAS, nickname);
     log("--doAddOld--" + requestObject);
     final RequestResult requestResult = new RequestResult();
     HttpUtil.postSmartRequest(requestObject, action, requestResult, context);
     int sc = requestResult.getCode();
     if (sc == HttpStatus.SC_OK) {
       result = requestResult.getResult();
       log("doAddOld---------result:" + result);
     } else {
       result = String.valueOf(sc);
       log("doAddOld---------code:" + sc);
     }
   } catch (JSONException e) {
     log("doAddOld---------JSONException:" + e.toString());
   }
   return result;
 }