public static RoomLocationReturn fromServerJson(JsonParser p)
      throws JsonParseException, IOException {

    RoomLocationReturn ret = new RoomLocationReturn();

    RoomLocationEntry entry = new RoomLocationEntry();

    while (p.nextToken() != JsonToken.END_OBJECT) {

      String fieldName = p.getCurrentName();
      if (KEY_BUILDING.equals(fieldName)) {
        p.nextToken();
        entry.setBuildingName(p.getText());
      } else if (KEY_ROOM.equals(fieldName)) {
        p.nextToken();
        entry.setRoomName(p.getText());
      } else if (KEY_LATITUDE.equals(fieldName)) {
        p.nextToken();
        entry.setLatitude(p.getDoubleValue());
      } else if (KEY_LONGITUDE.equals(fieldName)) {
        p.nextToken();
        entry.setLongitude(p.getDoubleValue());
      } else if (KEY_RATING.equals(fieldName)) {
        p.nextToken();
        // We assume that rating <--> productivity (they are interchangeable)
        entry.setProductivity(p.getDoubleValue());
      } else if (KEY_CAPACITY.equals(fieldName)) {
        p.nextToken();
        entry.setCapacity(p.getDoubleValue());
      } else if (KEY_CROWD.equals(fieldName)) {
        p.nextToken();
        entry.setAglCrowd(p.getDoubleValue());
      } else if (KEY_NUM_SURVEYS.equals(fieldName)) {
        p.nextToken();
        entry.setAglSurveys(p.getIntValue());

      } else if (KEY_INTERPOLATED.equals(fieldName)) {
        p.nextToken(); // take the "[" token
        List<NoiseEntry> noises = new ArrayList<NoiseEntry>();
        while (p.nextToken() != JsonToken.END_ARRAY) {
          noises.add(NoiseEntry.fromServerJson(p, entry));
        }
        ret.noises = noises;
      } else if (KEY_COMMENTS.equals(fieldName)) {
        p.nextToken(); // take the "[" token
        List<CommentEntry> comments = new ArrayList<CommentEntry>();
        while (p.nextToken() != JsonToken.END_ARRAY) {
          comments.add(CommentEntry.fromServerJson(p, entry));
        }
        ret.comments = comments;
      }
    }
    entry.setLocal(false);

    ret.entry = entry;

    return ret;
  }
示例#2
0
  private boolean doVote(CommentEntry entry, Vote vote) {
    if (commentActionListener == null) return false;

    boolean performVote = commentActionListener.onCommentVoteClicked(entry.comment, vote);
    if (performVote) {
      entry.vote = vote;
    }

    return performVote;
  }