Search in sources :

Example 36 with Rider

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

the class RaceGroupAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RaceGroupViewHolder holder, int position) {
    GridLayoutManager layoutManager = new GridLayoutManager(context, 1);
    holder.racegroupName.setText(String.valueOf(raceGroups.get(position).getName()));
    holder.gaptimeActual.setText(String.valueOf(convertLongToTimeString(raceGroups.get(position).getActualGapTime())));
    holder.gaptimeBefore.setText(String.valueOf(convertLongToTimeString(raceGroups.get(position).getHistoryGapTime())));
    if (raceGroups.get(position).getType() != RaceGroupType.FELD) {
        RiderRaceGroupAdapter adapter = new RiderRaceGroupAdapter(raceGroups.get(position).getRiders(), fragment);
        holder.racegroupRiders.setLayoutManager(layoutManager);
        holder.racegroupRiders.setAdapter(adapter);
        if (raceGroups.get(position).getType() == RaceGroupType.LEAD) {
            holder.gaptimeActual.setBackground(context.getDrawable(R.drawable.background_shape_racetime_before));
        }
        int color = ContextCompat.getColor(context, R.color.colorGrayLight);
        holder.layoutRacegroup.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
    } else {
        RiderRaceGroupAdapter adapter = new RiderRaceGroupAdapter(new RealmList<Rider>(), fragment);
        holder.racegroupRiders.setLayoutManager(layoutManager);
        holder.racegroupRiders.setAdapter(adapter);
        int color = ContextCompat.getColor(context, R.color.colorGrayMiddle);
        holder.layoutRacegroup.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
        holder.gaptimeActual.setBackground(context.getDrawable(R.drawable.background_shape_racetime));
    }
    holder.racegroupCount.setText(String.valueOf(raceGroups.get(position).getRidersCount()));
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Example 37 with Rider

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

the class RiderEditAdapter method updateAnimateRiderInGroup.

public void updateAnimateRiderInGroup(String raceGroupId) {
    RealmList<Rider> ridersToUpdate = RaceGroupPresenter.getInstance().getRaceGroupById(raceGroupId).getRiders();
    if (!holderHashMap.isEmpty()) {
        for (Rider r : ridersToUpdate) {
            if (holderHashMap.get(r.getStartNr()) != null) {
                TextView tvNumber = holderHashMap.get(r.getStartNr()).tvNummer;
                animateRiderInGroup(tvNumber, r.getStartNr());
            }
        }
    }
}
Also used : TextView(android.widget.TextView) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Example 38 with Rider

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

the class RiderListAdapter method updateAnimateRiderInGroup.

public void updateAnimateRiderInGroup(String raceGroupId) {
    RaceGroup raceGroup = RaceGroupPresenter.getInstance().getRaceGroupById(raceGroupId);
    if (!holderHashMap.isEmpty()) {
        for (Rider r : raceGroup.getRiders()) {
            if (holderHashMap.get(r.getStartNr()) != null) {
                TextView tvNumber = holderHashMap.get(r.getStartNr()).tvNummer;
                handler.post(() -> animateRiderInGroup(tvNumber, r.getStartNr()));
            }
        }
    }
}
Also used : RaceGroup(ch.hsr.sa.radiotour.dataaccess.models.RaceGroup) TextView(android.widget.TextView) Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Example 39 with Rider

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

the class RiderRaceGroupAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RiderRaceGroupAdapter.RiderRaceGroupViewHolder holder, int position) {
    Rider rider = riders.get(position);
    holder.racegroupRiderName.setText(String.valueOf(rider.getName()));
    if (rider.getStartNr() < 900) {
        holder.racegroupRiderStartNr.setText(String.valueOf(rider.getStartNr()));
        holder.racegroupRiderTeam.setText(String.valueOf(rider.getTeamShortName()));
        holder.racegroupRiderVirtualRank.setText(Integer.toString(rider.getRiderStages().first().getRiderRanking(RankingType.VIRTUAL).getRank()));
        setTrictos(rider, holder);
    } else {
        holder.racegroupRiderStartNr.setText(R.string.race_startnr_unknownrider);
        holder.racegroupRiderTeam.setText(R.string.race_startnr_unknownrider);
    }
    holder.racegroupRiderCountry.setImageResource(UIUtilitis.getCountryFlag(riders.get(position).getCountry()));
}
Also used : Rider(ch.hsr.sa.radiotour.dataaccess.models.Rider)

Example 40 with Rider

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

the class RiderRaceGroupFragment method onClick.

@Override
public void onClick(View view) {
    RealmList<Rider> selectedRiders = adapter.getSelectedRiders();
    switch(view.getId()) {
        case R.id.btn_Defect:
            addRiderToResetAfterTabChange(selectedRiders);
            updateRiderStates(RiderStateType.DEFECT);
            break;
        case R.id.btn_DNC:
            updateRiderStates(RiderStateType.DNC);
            break;
        case R.id.btn_Doctor:
            addRiderToResetAfterTabChange(selectedRiders);
            updateRiderStates(RiderStateType.DOCTOR);
            break;
        case R.id.btn_Drop:
            addRiderToResetAfterTabChange(selectedRiders);
            updateRiderStates(RiderStateType.DROP);
            break;
        case R.id.btn_Quit:
            updateRiderStates(RiderStateType.QUIT);
            break;
        case R.id.btn_UnkownRiders:
            FragmentManager fm = getFragmentManager();
            UnknownRiderDialogFragment alertDialog = UnknownRiderDialogFragment.newInstance();
            alertDialog.setTargetFragment(RiderRaceGroupFragment.this, 300);
            alertDialog.show(fm, "");
            break;
        default:
            break;
    }
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) 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