Search in sources :

Example 11 with Rider

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

the class AdapterUtilitis method removeUnknownRiders.

public static RealmList<Rider> removeUnknownRiders(RealmList<Rider> riders) {
    RealmList<Rider> sortedRiders = riders;
    Iterator<Rider> iterator = sortedRiders.iterator();
    while (iterator.hasNext()) {
        Rider r = iterator.next();
        if (r.isUnknown()) {
            iterator.remove();
        }
    }
    return sortedRiders;
}
Also used : Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Example 12 with Rider

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

the class JudgmentRiderAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(JudgmentRiderViewHolder holder, int position) {
    Rider r = getRiderByRank(position + 1);
    holder.itemRank.setText(String.valueOf(position + 1) + ".");
    if (r == null) {
        holder.itemRiderInfo.setText(context.getResources().getString(R.string.placeholder_rider_judgment));
        holder.itemRiderStartNr.setText("");
    } else {
        holder.itemRiderInfo.setText(r.getName() + ", " + r.getTeamShortName() + ", (" + Integer.toString(r.getRiderStages().first().getRiderRanking(RankingType.VIRTUAL).getRank()) + ")");
        holder.itemRiderStartNr.setText(Integer.toString(r.getStartNr()));
        holder.imgCountry.setImageResource(UIUtilitis.getCountryFlag(r.getCountry()));
    }
}
Also used : Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Example 13 with Rider

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

the class Parser method createDefaultGroup.

private static Thread createDefaultGroup() {
    Runnable runnable = (() -> {
        try {
            RaceGroup raceGroupField = new RaceGroup();
            raceGroupField.setActualGapTime(0);
            raceGroupField.setHistoryGapTime(0);
            raceGroupField.setPosition(1);
            raceGroupField.setType(RaceGroupType.FELD);
            RealmList<Rider> activeRiders = new RealmList<>();
            for (Rider r : Context.getAllRiders()) {
                if (r.getRiderStages().first().getType() == RiderStateType.AKTIVE) {
                    activeRiders.add(r);
                }
            }
            raceGroupField.setRiders(activeRiders);
            Context.addRaceGroup(raceGroupField);
        } catch (Exception e) {
            Log.d(Parser.class.getSimpleName(), "APP - PARSER - RACEGROUP - " + e.getMessage());
        }
    });
    return new Thread(runnable);
}
Also used : RaceGroup(ch.hsr.sa.radiotour.dataaccess.models.RaceGroup) RealmList(io.realm.RealmList) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider) JSONException(org.json.JSONException)

Example 14 with Rider

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

the class JudgmentDetailFragment method saveJudgmnet.

public void saveJudgmnet() {
    Rider rider = riderBasicAdapter.getSelectedRider();
    if (rank != 0) {
        JudgmentRiderConnection judgmentRiderConnection = new JudgmentRiderConnection();
        judgmentRiderConnection.setRank(rank);
        RealmList<Rider> riderToAdd = new RealmList<>();
        riderToAdd.add(rider);
        judgmentRiderConnection.setRider(riderToAdd);
        RealmList<Judgement> judgementToAdd = new RealmList<>();
        judgementToAdd.add(judgement);
        judgmentRiderConnection.setJudgements(judgementToAdd);
        JudgmentRiderConnectionPresenter.getInstance().addJudgmentRiderConnection(judgmentRiderConnection);
        updateRiderStateConnectionWithPerformance(rider, rank);
        textViews.get(rank - 1).setText(String.valueOf(rider.getStartNr()));
        riderBasicAdapter.setColorOnRider(rider.getStartNr());
    } else {
        Toast toast = Toast.makeText(getContext(), getResources().getString(R.string.judgment_text), Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, 0, 0);
        toast.show();
        Integer integer = rider.getRiderID();
        riderBasicAdapter.removeRiderFromList(integer);
    }
    riderBasicAdapter.resetSelectedRider();
    rank = 0;
}
Also used : RealmList(io.realm.RealmList) Judgement(ch.hsr.sa.radiotour.dataaccess.models.Judgement) Toast(android.widget.Toast) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider) JudgmentRiderConnection(ch.hsr.sa.radiotour.dataaccess.models.JudgmentRiderConnection)

Example 15 with Rider

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

the class RiderRaceGroupFragment method onNewRaceGroupClicked.

public void onNewRaceGroupClicked(RaceGroup beforeRaceGroup, RaceGroupType raceGroupType) {
    RaceGroup raceGroup = new RaceGroup();
    raceGroup.setPosition(beforeRaceGroup.getPosition() + 1);
    raceGroup.setActualGapTime(beforeRaceGroup.getActualGapTime() + 1);
    raceGroup.setType(raceGroupType);
    if (!adapter.getSelectedRiders().isEmpty()) {
        RealmList<Rider> activeRider = filterNonActiveRiders(adapter.getSelectedRiders());
        if (activeRider.isEmpty()) {
            adapter.resetSelectRiders();
            return;
        }
        raceGroup.setRiders(activeRider);
        RaceGroupPresenter.getInstance().addRaceGroup(raceGroup);
        raceGroupAdapter.notifyDataSetChanged();
        adapter.resetSelectRiders();
    } else if (!unknownRiders.isEmpty()) {
        raceGroup.setRiders(unknownRiders);
        RaceGroupPresenter.getInstance().addRaceGroup(raceGroup);
        raceGroupAdapter.notifyDataSetChanged();
        removeUnknownRiders();
    }
}
Also used : RaceGroup(ch.hsr.sa.radiotour.dataaccess.models.RaceGroup) 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