예제 #1
0
  /**
   * @description:成功后调用
   * @author:hc
   * @return:void
   * @param arg2
   */
  @Override
  public void onSuccess(String result) {

    Gson gson = new Gson();

    LogUtils.d("结果是: %s", result);

    try {
      if (success != null) success.onSuccess(gson.fromJson(result, cls));
    } catch (JsonSyntaxException e) {

      if (error != null) error.onError(e);
    }
  }
예제 #2
0
  /**
   * @description: 获取参数
   * @author:hc
   * @return:RequestParams
   * @return
   */
  @Override
  public RequestParams getParams() {

    RequestParams requestParams = new RequestParams();

    StringBuilder stringBuilder = new StringBuilder();
    Iterator<String> iterator = params.keySet().iterator();

    while (iterator.hasNext()) {

      String key = iterator.next().toString();

      if (params.get(key) instanceof File) {

        File tFile = (File) params.get(key);
        LogUtils.d(
            "%s %d  %s %s  %s",
            "is file", tFile.length(), key, tFile.exists(), tFile.getAbsolutePath());

        try {
          requestParams.put(key, tFile, "application/octet-stream");
        } catch (FileNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }

      } else {
        String val = params.get(key).toString();
        stringBuilder.append("&" + key + "=" + val);
        requestParams.put(key, params.get(key));
      }
    }

    LogUtils.d("提交参数为:%s", stringBuilder.toString());

    return requestParams;
  }