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;
}
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()));
}
}
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);
}
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;
}
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();
}
}
Aggregations