diff --git a/src/main/java/de/dennisguse/opentracks/ui/leaderboard/leaderboardFragment/AverageMovingSpeedLeaderboardFragment.java b/src/main/java/de/dennisguse/opentracks/ui/leaderboard/leaderboardFragment/AverageMovingSpeedLeaderboardFragment.java index 52250470e..71bba0269 100644 --- a/src/main/java/de/dennisguse/opentracks/ui/leaderboard/leaderboardFragment/AverageMovingSpeedLeaderboardFragment.java +++ b/src/main/java/de/dennisguse/opentracks/ui/leaderboard/leaderboardFragment/AverageMovingSpeedLeaderboardFragment.java @@ -20,13 +20,15 @@ protected List calculateLatestAverageRankingsData(List { diff --git a/src/main/java/de/dennisguse/opentracks/ui/leaderboard/leaderboardFragment/DistanceLeaderboardFragment.java b/src/main/java/de/dennisguse/opentracks/ui/leaderboard/leaderboardFragment/DistanceLeaderboardFragment.java index c1cae3374..595724df9 100644 --- a/src/main/java/de/dennisguse/opentracks/ui/leaderboard/leaderboardFragment/DistanceLeaderboardFragment.java +++ b/src/main/java/de/dennisguse/opentracks/ui/leaderboard/leaderboardFragment/DistanceLeaderboardFragment.java @@ -20,13 +20,15 @@ protected List calculateLatestAverageRankingsData(List calculateLatestAverageRankingsData(List new SummedStatTrackUser(trackUser)); + statsMap.computeIfAbsent(trackUser.nickname, k -> new SummedStatTrackUser(trackUser, trackUser.trackStatistics.getMovingTime().abs())); SummedStatTrackUser existingRecord = statsMap.get(trackUser.nickname); - existingRecord.getPlaceHolderTrackUser().trackStatistics.setMovingTime( - existingRecord.getPlaceHolderTrackUser().trackStatistics.getMovingTime().plus( - trackUser.trackStatistics.getMovingTime() - ) + Duration oldDuration = (Duration)existingRecord.getScoreSum(); + existingRecord.setScoreSum( + oldDuration.plus(trackUser.trackStatistics.getMovingTime()) ); existingRecord.incrementSumFactorCount(); } @@ -36,7 +35,8 @@ protected List calculateLatestAverageRankingsData(List calculateLatestAverageRankingsData(List { @Override public int compare(SummedStatTrackUser user1, SummedStatTrackUser user2) { - return user2.getPlaceHolderTrackUser().trackStatistics.getMovingTime().compareTo( - user1.getPlaceHolderTrackUser().trackStatistics.getMovingTime()); + Duration user1MovingTime = (Duration) user1.getScoreSum(); + Duration user2MovingTime = (Duration) user2.getScoreSum(); + return user2MovingTime.compareTo(user1MovingTime); } }