mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-31 17:12:44 +01:00
Visual enhancement of displaying grades point stats (#665)
This commit is contained in:
parent
1e5269c22c
commit
1999cd6eaf
@ -122,7 +122,7 @@ configurations.all {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "io.github.wulkanowy:sdk:8ad4480"
|
implementation "io.github.wulkanowy:sdk:cfda961"
|
||||||
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
implementation "androidx.core:core-ktx:1.2.0-rc01"
|
implementation "androidx.core:core-ktx:1.2.0-rc01"
|
||||||
|
@ -6,6 +6,11 @@ import androidx.sqlite.db.SupportSQLiteDatabase
|
|||||||
class Migration20 : Migration(19, 20) {
|
class Migration20 : Migration(19, 20) {
|
||||||
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(database: SupportSQLiteDatabase) {
|
||||||
|
migrateTimetable(database)
|
||||||
|
truncateSubjects(database)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun migrateTimetable(database: SupportSQLiteDatabase) {
|
||||||
database.execSQL("DROP TABLE Timetable")
|
database.execSQL("DROP TABLE Timetable")
|
||||||
database.execSQL("""
|
database.execSQL("""
|
||||||
CREATE TABLE IF NOT EXISTS `Timetable` (
|
CREATE TABLE IF NOT EXISTS `Timetable` (
|
||||||
@ -30,4 +35,8 @@ class Migration20 : Migration(19, 20) {
|
|||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun truncateSubjects(database: SupportSQLiteDatabase) {
|
||||||
|
database.execSQL("DELETE FROM Subjects")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import io.github.wulkanowy.data.db.dao.GradeStatisticsDao
|
|||||||
import io.github.wulkanowy.data.db.entities.GradePointsStatistics
|
import io.github.wulkanowy.data.db.entities.GradePointsStatistics
|
||||||
import io.github.wulkanowy.data.db.entities.GradeStatistics
|
import io.github.wulkanowy.data.db.entities.GradeStatistics
|
||||||
import io.github.wulkanowy.data.db.entities.Semester
|
import io.github.wulkanowy.data.db.entities.Semester
|
||||||
|
import io.github.wulkanowy.utils.roundToDecimalPlaces
|
||||||
import io.reactivex.Maybe
|
import io.reactivex.Maybe
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
@ -40,9 +41,9 @@ class GradeStatisticsLocal @Inject constructor(
|
|||||||
"Wszystkie" -> gradePointsStatisticsDb.loadAll(semester.semesterId, semester.studentId).flatMap { list ->
|
"Wszystkie" -> gradePointsStatisticsDb.loadAll(semester.semesterId, semester.studentId).flatMap { list ->
|
||||||
if (list.isEmpty()) return@flatMap Maybe.empty<GradePointsStatistics>()
|
if (list.isEmpty()) return@flatMap Maybe.empty<GradePointsStatistics>()
|
||||||
Maybe.just(GradePointsStatistics(semester.studentId, semester.semesterId, subjectName,
|
Maybe.just(GradePointsStatistics(semester.studentId, semester.semesterId, subjectName,
|
||||||
list.fold(.0) { acc, e -> acc + e.others },
|
(list.fold(.0) { acc, e -> acc + e.others } / list.size).roundToDecimalPlaces(2),
|
||||||
list.fold(.0) { acc, e -> acc + e.student })
|
(list.fold(.0) { acc, e -> acc + e.student } / list.size).roundToDecimalPlaces(2)
|
||||||
)
|
))
|
||||||
}
|
}
|
||||||
else -> gradePointsStatisticsDb.loadSubject(semester.semesterId, semester.studentId, subjectName)
|
else -> gradePointsStatisticsDb.loadSubject(semester.semesterId, semester.studentId, subjectName)
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,17 @@ class GradeStatisticsFragment : BaseFragment(), GradeStatisticsView, GradeView.G
|
|||||||
|
|
||||||
animateXY(1000, 1000)
|
animateXY(1000, 1000)
|
||||||
legend.textColor = context.getThemeAttrColor(android.R.attr.textColorPrimary)
|
legend.textColor = context.getThemeAttrColor(android.R.attr.textColorPrimary)
|
||||||
|
|
||||||
|
with(axisLeft) {
|
||||||
|
axisMinimum = 0f
|
||||||
|
axisMaximum = 100f
|
||||||
|
labelCount = 11
|
||||||
|
}
|
||||||
|
with(axisRight) {
|
||||||
|
axisMinimum = 0f
|
||||||
|
axisMaximum = 100f
|
||||||
|
labelCount = 11
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
subjectsAdapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, mutableListOf())
|
subjectsAdapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, mutableListOf())
|
||||||
|
@ -95,7 +95,7 @@ class GradeStatisticsPresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun onTypeChange() {
|
fun onTypeChange() {
|
||||||
val type = view?.let { it.currentType } ?: ViewType.POINTS
|
val type = view?.currentType ?: ViewType.POINTS
|
||||||
Timber.i("Select grade stats semester: $type")
|
Timber.i("Select grade stats semester: $type")
|
||||||
disposable.clear()
|
disposable.clear()
|
||||||
view?.run {
|
view?.run {
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package io.github.wulkanowy.utils
|
||||||
|
|
||||||
|
import kotlin.math.round
|
||||||
|
|
||||||
|
fun Double.roundToDecimalPlaces(places: Int = 2): Double {
|
||||||
|
return round(this * 10 * places) / (10 * places)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user