Search in sources :

Example 21 with Rider

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

the class RiderRepository method getAllActiveRidersReturned.

@Override
public RealmList<Rider> getAllActiveRidersReturned() {
    Realm realm = Realm.getInstance(RadioTourApplication.getInstance());
    RealmResults<Rider> results = realm.where(Rider.class).isNotEmpty("raceGroups").findAll();
    RealmList<Rider> res = new RealmList<>();
    res.addAll(results);
    return res;
}
Also used : RealmList(io.realm.RealmList) Realm(io.realm.Realm) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Example 22 with Rider

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

the class RiderRepository method removeRider.

@Override
public void removeRider(Rider rider, OnSaveRiderCallback callback) {
    Realm realm = Realm.getInstance(RadioTourApplication.getInstance());
    realm.beginTransaction();
    Rider foundRider = realm.where(Rider.class).equalTo("id", rider.getId()).findFirst();
    foundRider.deleteFromRealm();
    realm.commitTransaction();
    if (callback != null) {
        callback.onSuccess();
    }
}
Also used : Realm(io.realm.Realm) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Example 23 with Rider

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

the class RiderRepository method getAllRidersReturned.

@Override
public RealmList<Rider> getAllRidersReturned() {
    Realm realm = Realm.getInstance(RadioTourApplication.getInstance());
    RealmResults<Rider> results = realm.where(Rider.class).findAll();
    RealmList<Rider> res = new RealmList<>();
    res.addAll(results);
    return res;
}
Also used : RealmList(io.realm.RealmList) Realm(io.realm.Realm) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Example 24 with Rider

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

the class RiderRepository method updateRiderStageConnection.

@Override
public void updateRiderStageConnection(Rider rider, RealmList<RiderStageConnection> connections, OnUpdateRiderStageCallback callback) {
    Realm realm = Realm.getInstance(RadioTourApplication.getInstance());
    realm.beginTransaction();
    Rider res = realm.where(Rider.class).equalTo("startNr", rider.getStartNr()).findFirst();
    res.removeStages();
    realm.commitTransaction();
    realm.beginTransaction();
    Rider realmRider = realm.where(Rider.class).equalTo("startNr", rider.getStartNr()).findFirst();
    realmRider.appendStages(connections);
    realm.commitTransaction();
    if (callback != null) {
        callback.onSuccess();
    }
}
Also used : Realm(io.realm.Realm) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Example 25 with Rider

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

the class RiderStageConnectionRepository method updateRiderState.

@Override
public void updateRiderState(final RiderStateType type, final Rider rider, OnUpdateRiderStateCallBack callback) {
    Realm realm = Realm.getInstance(RadioTourApplication.getInstance());
    realm.beginTransaction();
    Rider res = realm.where(Rider.class).equalTo("id", rider.getId()).findFirst();
    for (RiderStageConnection sC : res.getRiderStages()) {
        if (sC.getType() == type) {
            sC.setType(RiderStateType.AKTIVE);
        } else {
            sC.setType(type);
        }
    }
    realm.commitTransaction();
    RiderStageConnection state = realm.where(RiderStageConnection.class).equalTo("riders.id", rider.getId()).findFirst();
    if (callback != null)
        callback.onSuccess(state);
}
Also used : RiderStageConnection(ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection) 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