use of ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnectionComparatorTimeInLead in project app by TourLive.
the class RiderStageConnectionRepository method appendTimeInLeadGroup.
@Override
public void appendTimeInLeadGroup(final RiderStageConnection riderStageConnection, int value) {
Realm realm = Realm.getInstance(RadioTourApplication.getInstance());
realm.executeTransaction((Realm db) -> {
RiderStageConnection res = db.where(RiderStageConnection.class).equalTo("id", riderStageConnection.getId()).findFirst();
res.appendTimeInLeadGroup(value);
List<RiderStageConnection> cons = realm.copyFromRealm(db.where(RiderStageConnection.class).findAll());
cons.sort(new RiderStageConnectionComparatorTimeInLead());
for (int i = 0; i < cons.size(); i++) {
db.where(RiderStageConnection.class).equalTo("id", cons.get(i).getId()).findFirst().getRiderRanking(RankingType.TIME_IN_LEAD).setRank(i + 1);
}
});
}
Aggregations