コード例 #1
0
  @Override
  public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
    Log.i(TAG, "response123=" + response);
    ArrayList<T> models = new ArrayList<T>();
    boolean isSuccess;
    try {
      isSuccess = response.getBoolean("isSuccess");
      String message = response.getString("message");
      if (isSuccess) {
        String jsonObjectData = response.getString("data");
        Log.i(TAG, "jsonObjectData=" + jsonObjectData);
        JSONArray jsona = new JSONArray(jsonObjectData);
        for (int j = 0; j < jsona.length(); j++) {
          JSONObject jsonObjitem = jsona.getJSONObject(j);
          T obj = (T) Class.forName(c.getName()).newInstance();
          obj.parse(jsonObjitem);
          if (obj != null) models.add(obj);
        }
        PersistenceHelper.saveModelList(context, models, key);
        SafeHandler.onSuccess(handler, models);
      } else {
        SafeHandler.onFailure(handler, message);
      }
    } catch (Exception e) {

    }
  }
コード例 #2
0
 private void handleFailure(int statusCode, String error) {
   Log.i(TAG, "statusCode4=" + statusCode);
   error = ErrorType.errorMessage(context, ErrorType.ErrorApiForbidden);
   SafeHandler.onFailure(handler, error);
 }