Search in sources :

Example 16 with Rider

use of ch.hsr.sa.radiotour.dataaccess.models.Rider in project app by TourLive.

the class VirtualClassFragment method intiTable.

private void intiTable(View root) {
    recyclerAdapter = new RecyclerAdapter();
    recyclerAdapter.setEmptyItem(new EmptyItem(getString(android.R.string.cancel)));
    recyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
    recyclerView.setAdapter(recyclerAdapter);
    for (Rider r : RiderPresenter.getInstance().getAllRidersReturned()) {
        recyclerAdapter.add(new VirtualClassementRider(this, mContext, r));
    }
}
Also used : RecyclerAdapter(net.gotev.recycleradapter.RecyclerAdapter) VirtualClassementRider(ch.hsr.sa.radiotour.presentation.models.VirtualClassementRider) EmptyItem(ch.hsr.sa.radiotour.presentation.models.EmptyItem) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider) VirtualClassementRider(ch.hsr.sa.radiotour.presentation.models.VirtualClassementRider)

Example 17 with Rider

use of ch.hsr.sa.radiotour.dataaccess.models.Rider in project app by TourLive.

the class MaillotRepository method addRiderToMaillot.

@Override
public void addRiderToMaillot(Maillot maillot, int riderDbId) {
    Realm realm = Realm.getInstance(RadioTourApplication.getInstance());
    Maillot realmMaillot = realm.where(Maillot.class).equalTo("id", maillot.getId()).findFirst();
    Rider rider = realm.where(Rider.class).equalTo("riderID", riderDbId).findFirst();
    realm.beginTransaction();
    realmMaillot.setRider(rider);
    realm.commitTransaction();
}
Also used : Maillot(ch.hsr.sa.radiotour.dataaccess.models.Maillot) Realm(io.realm.Realm) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Example 18 with Rider

use of ch.hsr.sa.radiotour.dataaccess.models.Rider in project app by TourLive.

the class RaceGroupRepository method addInitialRaceGroup.

@Override
public void addInitialRaceGroup(RaceGroup raceGroup, OnSaveRaceGroupCallback callback) {
    Realm realm = Realm.getInstance(RadioTourApplication.getInstance());
    final RaceGroup transferRaceGroup = raceGroup;
    realm.beginTransaction();
    RaceGroup realmRaceGroup = realm.createObject(RaceGroup.class, UUID.randomUUID().toString());
    realmRaceGroup.setType(transferRaceGroup.getType());
    realmRaceGroup.setActualGapTime(transferRaceGroup.getActualGapTime());
    realmRaceGroup.setHistoryGapTime(transferRaceGroup.getHistoryGapTime());
    RealmList<Rider> res = new RealmList<>();
    for (Rider r : transferRaceGroup.getRiders()) {
        RealmResults<Rider> temp = realm.where(Rider.class).equalTo("startNr", r.getStartNr()).findAll();
        res.addAll(temp);
    }
    realmRaceGroup.setPosition(transferRaceGroup.getPosition());
    realmRaceGroup.setRiders(res);
    realm.commitTransaction();
    if (callback != null) {
        callback.onSuccess(realmRaceGroup);
    }
}
Also used : RaceGroup(ch.hsr.sa.radiotour.dataaccess.models.RaceGroup) RealmList(io.realm.RealmList) Realm(io.realm.Realm) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Example 19 with Rider

use of ch.hsr.sa.radiotour.dataaccess.models.Rider in project app by TourLive.

the class RiderRepository method addRider.

@Override
public void addRider(Rider rider, OnSaveRiderCallback callback) {
    Realm realm = Realm.getInstance(RadioTourApplication.getInstance());
    final Rider transferRider = rider;
    realm.executeTransaction((Realm db) -> {
        Rider realmRider = db.createObject(Rider.class, UUID.randomUUID().toString());
        realmRider.setRiderID(transferRider.getRiderID());
        realmRider.setName(transferRider.getName());
        realmRider.setCountry(transferRider.getCountry());
        realmRider.setStartNr(transferRider.getStartNr());
        realmRider.setTeamName(transferRider.getTeamName());
        realmRider.setTeamShortName(transferRider.getTeamShortName());
        realmRider.setUnknown(transferRider.isUnknown());
    });
    if (callback != null)
        callback.onSuccess();
}
Also used : Realm(io.realm.Realm) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Example 20 with Rider

use of ch.hsr.sa.radiotour.dataaccess.models.Rider in project app by TourLive.

the class RiderRepository method getAllRiders.

@Override
public void getAllRiders(OnGetAllRidersCallback callback) {
    Realm realm = Realm.getInstance(RadioTourApplication.getInstance());
    RealmResults<Rider> results = realm.where(Rider.class).findAll();
    RealmList<Rider> res = new RealmList<>();
    res.addAll(results);
    if (callback != null)
        callback.onSuccess(res);
}
Also used : RealmList(io.realm.RealmList) Realm(io.realm.Realm) 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