forked from github/wulkanowy-mirror
Add total attendance summary (#672)
This commit is contained in:
parent
731afbb00c
commit
c3a6842027
@ -36,6 +36,8 @@ class AttendanceSummaryFragment : BaseFragment(), AttendanceSummaryView, MainVie
|
|||||||
fun newInstance() = AttendanceSummaryFragment()
|
fun newInstance() = AttendanceSummaryFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val totalString get() = getString(R.string.attendance_summary_total)
|
||||||
|
|
||||||
override val titleStringId get() = R.string.attendance_title
|
override val titleStringId get() = R.string.attendance_title
|
||||||
|
|
||||||
override val isViewEmpty get() = attendanceSummaryAdapter.isEmpty
|
override val isViewEmpty get() = attendanceSummaryAdapter.isEmpty
|
||||||
|
@ -144,8 +144,22 @@ class AttendanceSummaryPresenter @Inject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun createAttendanceSummaryTotalItem(attendanceSummary: List<AttendanceSummary>): AttendanceSummaryItem {
|
||||||
|
return AttendanceSummaryItem(
|
||||||
|
month = view?.totalString.orEmpty(),
|
||||||
|
percentage = formatPercentage(attendanceSummary.calculatePercentage()),
|
||||||
|
present = attendanceSummary.sumBy { it.presence }.toString(),
|
||||||
|
absence = attendanceSummary.sumBy { it.absence }.toString(),
|
||||||
|
excusedAbsence = attendanceSummary.sumBy { it.absenceExcused }.toString(),
|
||||||
|
schoolAbsence = attendanceSummary.sumBy { it.absenceForSchoolReasons }.toString(),
|
||||||
|
exemption = attendanceSummary.sumBy { it.exemption }.toString(),
|
||||||
|
lateness = attendanceSummary.sumBy { it.lateness }.toString(),
|
||||||
|
excusedLateness = attendanceSummary.sumBy { it.latenessExcused }.toString()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private fun createAttendanceSummaryItems(attendanceSummary: List<AttendanceSummary>): List<AttendanceSummaryItem> {
|
private fun createAttendanceSummaryItems(attendanceSummary: List<AttendanceSummary>): List<AttendanceSummaryItem> {
|
||||||
return attendanceSummary.sortedByDescending { it.id }.map {
|
return listOf(createAttendanceSummaryTotalItem(attendanceSummary)) + attendanceSummary.sortedByDescending { it.id }.map {
|
||||||
AttendanceSummaryItem(
|
AttendanceSummaryItem(
|
||||||
month = it.month.getFormattedName(),
|
month = it.month.getFormattedName(),
|
||||||
percentage = formatPercentage(it.calculatePercentage()),
|
percentage = formatPercentage(it.calculatePercentage()),
|
||||||
|
@ -4,6 +4,8 @@ import io.github.wulkanowy.ui.base.BaseView
|
|||||||
|
|
||||||
interface AttendanceSummaryView : BaseView {
|
interface AttendanceSummaryView : BaseView {
|
||||||
|
|
||||||
|
val totalString: String
|
||||||
|
|
||||||
val isViewEmpty: Boolean
|
val isViewEmpty: Boolean
|
||||||
|
|
||||||
fun initView()
|
fun initView()
|
||||||
|
@ -151,6 +151,7 @@
|
|||||||
|
|
||||||
<!--Attendance summary-->
|
<!--Attendance summary-->
|
||||||
<string name="attendance_summary_final">Frekwencja</string>
|
<string name="attendance_summary_final">Frekwencja</string>
|
||||||
|
<string name="attendance_summary_total">Razem</string>
|
||||||
|
|
||||||
|
|
||||||
<!--Exam-->
|
<!--Exam-->
|
||||||
|
@ -146,6 +146,7 @@
|
|||||||
|
|
||||||
<!--Attendance summary-->
|
<!--Attendance summary-->
|
||||||
<string name="attendance_summary_final">Посещаемость</string>
|
<string name="attendance_summary_final">Посещаемость</string>
|
||||||
|
<string name="attendance_summary_total">вместе</string>
|
||||||
|
|
||||||
|
|
||||||
<!--Exam-->
|
<!--Exam-->
|
||||||
|
@ -145,6 +145,7 @@
|
|||||||
|
|
||||||
<!--Attendance summary-->
|
<!--Attendance summary-->
|
||||||
<string name="attendance_summary_final">Attendance</string>
|
<string name="attendance_summary_final">Attendance</string>
|
||||||
|
<string name="attendance_summary_total">Total</string>
|
||||||
|
|
||||||
|
|
||||||
<!--Exam-->
|
<!--Exam-->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user