use of ch.hsr.sa.radiotour.dataaccess.models.Rider in project app by TourLive.
the class RaceGroupRepositoryInstrumentedTest method createRiders.
private void createRiders() {
this.riders.clear();
for (int i = 0; i < 3; i++) {
Rider rider = new Rider();
rider.setTeamShortName("T");
rider.setTeamName("TEST");
rider.setCountry("T");
rider.setName("TEST " + i);
rider.setStartNr(i);
this.riders.add(rider);
synchronized (this) {
riderRepository.addRider(rider, onSaveRiderCallback);
}
}
}
use of ch.hsr.sa.radiotour.dataaccess.models.Rider in project app by TourLive.
the class RaceGroupRepositoryInstrumentedTest method deleteRiderInRaceGroup.
@Test
public void deleteRiderInRaceGroup() {
RaceGroup raceGroup = new RaceGroup();
raceGroup.setType(RaceGroupType.NORMAL);
raceGroup.setPosition(1);
raceGroup.setRiders(riders);
synchronized (this) {
raceGroupRepository.addRaceGroup(raceGroup, onSaveRaceGroupCallback);
}
RealmResults<RaceGroup> res = realm.where(RaceGroup.class).findAll();
RealmResults<Rider> resRiders = realm.where(Rider.class).findAll();
Rider riderToDelete = resRiders.get(0);
assertEquals(3, res.get(0).getRiders().size());
synchronized (this) {
raceGroupRepository.deleteRiderInRaceGroup(res.first(), riderToDelete, onUpdateRaceGroupCallBack);
}
RealmResults<RaceGroup> endRes = realm.where(RaceGroup.class).findAll();
assertEquals(2, endRes.get(0).getRiders().size());
}
use of ch.hsr.sa.radiotour.dataaccess.models.Rider in project app by TourLive.
the class RiderStageConnectionRepositoryInstrumentedTest method initalRider.
private void initalRider() {
Rider rider = new Rider();
rider.setTeamShortName("T");
rider.setTeamName("TEST");
rider.setCountry("T");
rider.setName("TEST");
rider.setStartNr(1);
synchronized (this) {
riderRepository.addRider(rider, onSaveRiderCallback);
}
}
use of ch.hsr.sa.radiotour.dataaccess.models.Rider in project app by TourLive.
the class MaillotsAdapter method getActualLeader.
private void getActualLeader(String type, MaillotViewHolder holder) {
Rider rider = null;
RiderRanking riderRanking = null;
switch(type) {
case "leader":
riderRanking = RiderRankingPresenter.getInstance().getFirstInRanking(RankingType.VIRTUAL);
rider = riderRanking.getRiderStageConnection().getRiders();
holder.leaderVirtInfo.setText(String.format("%s, %s, (%d)", rider.getName(), rider.getTeamName(), riderRanking.getRank()));
break;
case "mountain":
riderRanking = RiderRankingPresenter.getInstance().getFirstInRanking(RankingType.MOUNTAIN);
rider = riderRanking.getRiderStageConnection().getRiders();
holder.leaderVirtInfo.setText(String.format("%s, %s, (%d)", rider.getName(), rider.getTeamName(), riderRanking.getRank()));
break;
case "points":
riderRanking = RiderRankingPresenter.getInstance().getFirstInRanking(RankingType.POINTS);
rider = riderRanking.getRiderStageConnection().getRiders();
holder.leaderVirtInfo.setText(String.format("%s, %s, (%d)", rider.getName(), rider.getTeamName(), riderRanking.getRank()));
break;
case "bestSwiss":
riderRanking = RiderRankingPresenter.getInstance().getFirstInRanking(RankingType.SWISS);
rider = riderRanking.getRiderStageConnection().getRiders();
holder.leaderVirtInfo.setText(String.format("%s, %s, (%d)", rider.getName(), rider.getTeamName(), riderRanking.getRank()));
break;
default:
break;
}
if (rider != null) {
holder.leaderVirtStart.setText(String.valueOf(rider.getStartNr()));
holder.leaderVirtFlag.setImageResource(UIUtilitis.getCountryFlag(String.valueOf(rider.getCountry())));
holder.leaderVirtFlag.setAdjustViewBounds(true);
}
}
use of ch.hsr.sa.radiotour.dataaccess.models.Rider in project app by TourLive.
the class MaillotsAdapter method getRealLeader.
private void getRealLeader(Maillot maillot, MaillotViewHolder holder) {
Rider rider = maillot.getRider();
if (rider != null) {
holder.leaderRealStart.setText(String.valueOf(rider.getStartNr()));
holder.leaderRealFlag.setImageResource(UIUtilitis.getCountryFlag(String.valueOf(rider.getCountry())));
holder.leaderRealFlag.setAdjustViewBounds(true);
int rank = 0;
switch(maillot.getType()) {
case "leader":
rank = rider.getRiderStages().first().getRiderRanking(RankingType.VIRTUAL).getRank();
break;
case "mountain":
rank = rider.getRiderStages().first().getRiderRanking(RankingType.MOUNTAIN).getRank();
break;
case "points":
rank = rider.getRiderStages().first().getRiderRanking(RankingType.POINTS).getRank();
break;
case "bestSwiss":
rank = rider.getRiderStages().first().getRiderRanking(RankingType.SWISS).getRank();
break;
default:
break;
}
holder.leaderRealInfo.setText(String.format("%s, %s, (%d)", rider.getName(), rider.getTeamName(), rank));
}
}
Aggregations