Example #1
0
  private void updateMemberScoreResult(Member member, Score score) {
    RealmList<MemberResult> memberResultList = getMatchday().getMemberResults();
    BigDecimal resultScoreValue = null;
    if (memberResultList == null) getMatchday().setMemberResults(new RealmList<MemberResult>());

    MemberResult result = null;
    for (MemberResult mResult : getMatchday().getMemberResults()) {
      if (mResult.getMember().equals(member.getEmail())) {
        result = mResult;
        break;
      }
    }

    if (result == null || (result != null && result.getResultsScore() == null)) {
      boolean addResult = result == null;
      resultScoreValue = new BigDecimal(1);
      if (result == null) result = new MemberResult();
      MemberScoreValue resultScore = new MemberScoreValue();
      resultScore.setScore(score);
      resultScore.setValue(resultScoreValue);
      result.setResultsScore(new RealmList<MemberScoreValue>());
      result.getResultsScore().add(resultScore);
      result.setMember(member.getEmail());
      if (addResult) getMatchday().getMemberResults().add(result);
    } else {
      MemberScoreValue resultScore = null;
      for (MemberScoreValue value : result.getResultsScore()) {
        if (value.getScore().equals(score)) {
          resultScore = value;
          break;
        }
      }

      if (resultScore == null) {
        resultScore = new MemberScoreValue();
        resultScore.setScore(score);
        resultScore.setValue(resultScoreValue);
        result.getResultsScore().add(resultScore);
      } else resultScore.setValue(resultScore.getValue().add(new BigDecimal(1)));
    }
  }
Example #2
0
  private void updateMemberPenaltyResult(Member member, Penalty penalty) {
    RealmList<MemberResult> memberResultList = getMatchday().getMemberResults();
    BigDecimal resultPenaltyValue = null;
    if (memberResultList == null) getMatchday().setMemberResults(new RealmList<MemberResult>());

    MemberResult result = null;
    for (MemberResult mResult : getMatchday().getMemberResults()) {
      if (mResult.getMember().equals(member.getEmail())) {
        result = mResult;
        break;
      }
    }

    if (result == null || (result != null && result.getResultsPenalty() == null)) {
      boolean addPenalty = result == null;
      resultPenaltyValue = new BigDecimal(2);
      if (result == null) result = new MemberResult();
      MemberPenalyValue resultPenalty = new MemberPenalyValue();
      resultPenalty.setPenalty(penalty);
      resultPenalty.setValue(resultPenaltyValue);
      result.setResultsPenalty(new RealmList<MemberPenalyValue>());
      result.getResultsPenalty().add(resultPenalty);
      result.setMember(member.getEmail());
      if (addPenalty) getMatchday().getMemberResults().add(result);
    } else {
      MemberPenalyValue resultPenalty = null;
      for (MemberPenalyValue value : result.getResultsPenalty()) {
        if (value.getPenalty().equals(penalty)) {
          resultPenalty = value;
          break;
        }
      }

      if (resultPenalty == null) {
        resultPenalty = new MemberPenalyValue();
        resultPenalty.setPenalty(penalty);
        resultPenalty.setValue(resultPenaltyValue);
        result.getResultsPenalty().add(resultPenalty);
      } else resultPenalty.setValue(resultPenalty.getValue().add(new BigDecimal(2)));
    }
  }
 @Override
 public void setField(RealmObject object) {
   Member member = (Member) object;
   vorname.getEditText().setText(member.getFirstName());
   nachname.getEditText().setText(member.getLastName());
   email.getEditText().setText(member.getEmail());
   address.getEditText().setText(member.getAddress());
   date.getEditText().setText(member.getBirthday());
 }