Ejemplo n.º 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);
    }
  }
Ejemplo n.º 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);
    }
  }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 /** "seaRecordId": 1 */
 public boolean saveInstance(Context context) {
   String spString = MyGson.getInstance().toJson(this);
   return SPUtil.saveString(context, Constants.SP_SHOP, Constants.SP_SHOP, spString);
 }