Пример #1
0
  /**
   * Convert a json object from rest service to a user object
   *
   * @param token the token got by the rest service
   * @return the user object
   */
  public static Notification parse(JSONObject token) {
    try {
      Notification notification = new Notification();
      notification.setId(token.getInt("id"));
      notification.setUserFrom(token.getString("source"));
      notification.setMessage(token.getString("content"));
      notification.setType(stringToType(token.getString("type")));
      notification.setRead(token.getBoolean("read"));
      return notification;

    } catch (JSONException e) {
      e.printStackTrace();
      return null;
    }
  }