Search in sources :

Example 6 with JudgmentRiderConnection

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

the class JudgmentRiderConnectionInstrumentedTest method addRewardRiderConnection.

@Test
public void addRewardRiderConnection() {
    addRider();
    addJudgment();
    RealmList<Rider> riderList = new RealmList<>();
    RealmList<Judgement> judgementList = new RealmList<>();
    riderList.add(RiderPresenter.getInstance().getRiderByStartNr(15));
    judgementList.add(JudgmentPresenter.getInstance().getJudgmentsById(93).first());
    JudgmentRiderConnection judgmentRiderConnection = new JudgmentRiderConnection();
    judgmentRiderConnection.setRank(1);
    judgmentRiderConnection.setJudgements(judgementList);
    judgmentRiderConnection.setRider(riderList);
    synchronized (this) {
        judgmentRiderConnectionRepository.addJudgmentRiderConnection(judgmentRiderConnection, onSaveJudgmentRiderConnectionCallback);
    }
    Assert.assertEquals(1, realm.where(JudgmentRiderConnection.class).findAll().first().getRank());
}
Also used : RealmList(io.realm.RealmList) Judgement(ch.hsr.sa.radiotour.dataaccess.models.Judgement) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider) JudgmentRiderConnection(ch.hsr.sa.radiotour.dataaccess.models.JudgmentRiderConnection) Test(org.junit.Test)

Example 7 with JudgmentRiderConnection

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

the class JudgmentRiderConnectionInstrumentedTest method clearAllRewardRiderConnections.

@Test
public void clearAllRewardRiderConnections() {
    addRider();
    addJudgment();
    RealmList<Rider> riderList = new RealmList<>();
    RealmList<Judgement> judgementList = new RealmList<>();
    riderList.add(RiderPresenter.getInstance().getRiderByStartNr(15));
    judgementList.add(JudgmentPresenter.getInstance().getJudgmentsById(93).first());
    JudgmentRiderConnection judgmentRiderConnection = new JudgmentRiderConnection();
    judgmentRiderConnection.setRank(1);
    judgmentRiderConnection.setJudgements(judgementList);
    judgmentRiderConnection.setRider(riderList);
    synchronized (this) {
        judgmentRiderConnectionRepository.addJudgmentRiderConnection(judgmentRiderConnection, onSaveJudgmentRiderConnectionCallback);
    }
    synchronized (this) {
        judgmentRiderConnectionRepository.clearAllJudgmentRiderConnections();
    }
    Assert.assertEquals(0, realm.where(JudgmentRiderConnection.class).findAll().size());
}
Also used : RealmList(io.realm.RealmList) Judgement(ch.hsr.sa.radiotour.dataaccess.models.Judgement) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider) JudgmentRiderConnection(ch.hsr.sa.radiotour.dataaccess.models.JudgmentRiderConnection) Test(org.junit.Test)

Example 8 with JudgmentRiderConnection

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

the class JudgementAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(JudgementViewHolder holder, int position) {
    holder.itemTitleJudgement.setText(String.valueOf(judgements.get(position).getName()));
    holder.itemJudgementKM.setText("KM " + judgements.get(position).getDistance());
    LinearLayoutManager layoutManager = new LinearLayoutManager(context);
    RealmList<JudgmentRiderConnection> judgmentRiderConnections = JudgmentRiderConnectionPresenter.getInstance().getJudgmentRiderConnectionsReturnedByJudgment(judgements.get(position));
    JudgmentRiderAdapter adapter = new JudgmentRiderAdapter(RewardPresenter.getInstance().getRewardReturnedByJudgment(judgements.get(position)), judgmentRiderConnections, context);
    holder.rvJudgmentRiders.setLayoutManager(layoutManager);
    holder.rvJudgmentRiders.setAdapter(adapter);
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) JudgmentRiderConnection(ch.hsr.sa.radiotour.dataaccess.models.JudgmentRiderConnection)

Aggregations

JudgmentRiderConnection (ch.hsr.sa.radiotour.dataaccess.models.JudgmentRiderConnection)8 Judgement (ch.hsr.sa.radiotour.dataaccess.models.Judgement)4 RealmList (io.realm.RealmList)4 Rider (ch.hsr.sa.radiotour.dataaccess.models.Rider)3 Realm (io.realm.Realm)2 Test (org.junit.Test)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 Toast (android.widget.Toast)1 Reward (ch.hsr.sa.radiotour.dataaccess.models.Reward)1 RiderStageConnection (ch.hsr.sa.radiotour.dataaccess.models.RiderStageConnection)1