Пример #1
0
  private void updateSplits(long cumulativeTime, int cummulativeDistance, boolean reset) {
    MyLog.i("RaceTimerFragment", "updateSplits for Athlete " + mAthleteNumber);
    List<Split> splits = new ArrayList<>();

    if (reset) {
      tvAthletePace.setText(getActivity().getString(R.string.header_pace));
    } else {
      // gets the splits associated with the race Uuid
      splits = Split.getAllSplits(mRaceUuid, false);

      String paceAndDistance =
          CommonMethods.getAveragePaceString(
              cumulativeTime, cummulativeDistance, mPaceDistance, mPoolLengthUnits);

      if (mIsClockRunning) {
        paceAndDistance =
            paceAndDistance
                + CommonMethods.getEstimatedTotalDistance(
                    cumulativeTime, cummulativeDistance, mEventDurationMs, mPoolLengthUnits);
      }

      tvAthletePace.setText(paceAndDistance);
    }

    mSplitArrayAdapter.setData(splits);
    mSplitArrayAdapter.notifyDataSetChanged();
  }
Пример #2
0
 private void startRace() {
   MyLog.i("RaceTimerFragment", "startRace for Athlete " + mAthleteNumber);
   if (mSplitArrayAdapter.getCount() > 0) {
     resetSplits();
   }
   disableAthlete();
   showSplitButton();
   mSelectedSwimEvent = MainActivity.getSelectedSwimEvent();
   mLapNumber = 0;
   mPreviousCummulativeTime = 0;
   mIsClockRunning = true;
   mRaceUuid = UUID.randomUUID().toString();
   switch (mAthleteNumber) {
     case 1:
       MySettings.setAthlete1RaceUuid(mRaceUuid);
       break;
     case 2:
       MySettings.setAthlete2RaceUuid(mRaceUuid);
       break;
   }
 }