コード例 #1
0
  @SuppressWarnings("static-access")
  @Override
  protected void onPostExecute(String result) {
    super.onPostExecute(result);
    this.result = result;

    LogUtils.d(result); // TODO

    if (!StringUtil.isEmptyString(result)) {
      try {
        this.jsonResult = MyGson.getInstance().fromJson(result, BaseResult.class);
      } catch (Exception e) {
        this.jsonResult = Constants.JSON_ERROR;
        e.printStackTrace();
      }
    } else {
      this.jsonResult = Constants.SERVER_ERROR;
    }
    try {
      JSONObject jo = new JSONObject(result).getJSONObject("resultParm");
      Map<String, String> map = new HashMap<String, String>();
      Iterator<String> keys = jo.keys();

      while (keys.hasNext()) {
        String k = keys.next();
        map.put(k, jo.getString(k));
      }
      this.jsonResult.setResultParam(map);
    } catch (Exception e) {
      e.printStackTrace();
    }
    if (dataReturnListener != null) {
      dataReturnListener.onDataReturn(Tasktag, jsonResult, result);
    }
  }
コード例 #2
0
  @Override
  protected void onPostExecute(String json) {
    super.onPostExecute(json);

    BaseResult jsonResult = null;
    if (!StringUtil.isEmptyString(json)) {
      try {
        jsonResult = MyGson.getInstance().fromJson(json, BaseResult.class);
      } catch (Exception e) {
        jsonResult = Constants.JSON_ERROR;
        e.printStackTrace();
      }
    } else {
      jsonResult = Constants.SERVER_ERROR;
    }
    try {
      JSONObject jo = new JSONObject(json).getJSONObject("resultParm");
      Map<String, String> map = new HashMap<String, String>();
      Iterator<String> keys = jo.keys();

      while (keys.hasNext()) {
        String k = keys.next();
        map.put(k, jo.getString(k));
      }
      jsonResult.setResultParam(map);
    } catch (Exception e) {
      e.printStackTrace();
    }
    if (dataReturnListener != null) {
      dataReturnListener.onDataReturn(taskTag, jsonResult, json);
    }
  }
コード例 #3
0
ファイル: Shop.java プロジェクト: bojueWjt/fishShopSeller
 public static Shop getInstance(Context context) {
   String defValue = "";
   String string = SPUtil.getString(context, Constants.SP_SHOP, Constants.SP_SHOP, defValue);
   Shop bean = string.equals(defValue) ? null : MyGson.getInstance().fromJson(string, Shop.class);
   return bean;
 }
コード例 #4
0
ファイル: Shop.java プロジェクト: bojueWjt/fishShopSeller
 /** "seaRecordId": 1 */
 public boolean saveInstance(Context context) {
   String spString = MyGson.getInstance().toJson(this);
   return SPUtil.saveString(context, Constants.SP_SHOP, Constants.SP_SHOP, spString);
 }