Search in sources :

Example 31 with Rider

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);
        }
    }
}
Also used : Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Example 32 with Rider

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());
}
Also used : RaceGroup(ch.hsr.sa.radiotour.dataaccess.models.RaceGroup) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider) Test(org.junit.Test)

Example 33 with Rider

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);
    }
}
Also used : Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Example 34 with Rider

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);
    }
}
Also used : RiderRanking(ch.hsr.sa.radiotour.dataaccess.models.RiderRanking) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Example 35 with Rider

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));
    }
}
Also used : Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Aggregations

Rider (ch.hsr.sa.radiotour.dataaccess.models.Rider)46 RealmList (io.realm.RealmList)17 Realm (io.realm.Realm)13 RaceGroup (ch.hsr.sa.radiotour.dataaccess.models.RaceGroup)9 Test (org.junit.Test)9 RiderStageConnection (ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection)5 TextView (android.widget.TextView)3 Judgement (ch.hsr.sa.radiotour.dataaccess.models.Judgement)3 JSONException (org.json.JSONException)3 Fragment (android.support.v4.app.Fragment)2 View (android.view.View)2 JudgmentRiderConnection (ch.hsr.sa.radiotour.dataaccess.models.JudgmentRiderConnection)2 RiderRanking (ch.hsr.sa.radiotour.dataaccess.models.RiderRanking)2 Manifest (android.Manifest)1 AlertDialog (android.app.AlertDialog)1 TimePickerDialog (android.app.TimePickerDialog)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 PackageManager (android.content.pm.PackageManager)1 Location (android.location.Location)1