From 6925204019f974fef9bfcbd8c8898fc63de42f0d Mon Sep 17 00:00:00 2001 From: Dominik Korsa Date: Wed, 5 Feb 2020 00:53:07 +0100 Subject: [PATCH] Fix showing empty total summary and ordering of summary months (#678) --- .../attendance/summary/AttendanceSummaryPresenter.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/summary/AttendanceSummaryPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/summary/AttendanceSummaryPresenter.kt index bb46e0c4..18f67726 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/summary/AttendanceSummaryPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/attendance/summary/AttendanceSummaryPresenter.kt @@ -12,6 +12,7 @@ import io.github.wulkanowy.utils.FirebaseAnalyticsHelper import io.github.wulkanowy.utils.SchedulersProvider import io.github.wulkanowy.utils.calculatePercentage import io.github.wulkanowy.utils.getFormattedName +import org.threeten.bp.Month import timber.log.Timber import java.lang.String.format import java.util.Locale.FRANCE @@ -159,7 +160,10 @@ class AttendanceSummaryPresenter @Inject constructor( } private fun createAttendanceSummaryItems(attendanceSummary: List): List { - return listOf(createAttendanceSummaryTotalItem(attendanceSummary)) + attendanceSummary.sortedByDescending { it.id }.map { + if (attendanceSummary.isEmpty()) return emptyList() + return listOf(createAttendanceSummaryTotalItem(attendanceSummary)) + attendanceSummary.sortedByDescending { + if (it.month.value <= Month.JUNE.value) it.month.value + 12 else it.month.value + }.map { AttendanceSummaryItem( month = it.month.getFormattedName(), percentage = formatPercentage(it.calculatePercentage()),