diff --git a/app/build.gradle b/app/build.gradle index d7551376..01e60382 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -122,7 +122,7 @@ configurations.all { } dependencies { - implementation "io.github.wulkanowy:sdk:0.14.0" + implementation "io.github.wulkanowy:sdk:069677aa2089b5678adbcae79dc253220995f172" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "androidx.core:core-ktx:1.2.0-rc01" diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsFragment.kt index 5bcf167e..a65cab9c 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsFragment.kt @@ -47,6 +47,13 @@ class GradeStatisticsFragment : BaseFragment(), GradeStatisticsView, GradeView.G override val isBarViewEmpty get() = gradeStatisticsChartPoints.isEmpty + override val currentType + get() = when (gradeStatisticsTypeSwitch.checkedRadioButtonId) { + R.id.gradeStatisticsTypeSemester -> ViewType.SEMESTER + R.id.gradeStatisticsTypePartial -> ViewType.PARTIAL + else -> ViewType.POINTS + } + private lateinit var gradeColors: List> private val vulcanGradeColors = listOf( @@ -272,13 +279,7 @@ class GradeStatisticsFragment : BaseFragment(), GradeStatisticsView, GradeView.G override fun onResume() { super.onResume() - gradeStatisticsTypeSwitch.setOnCheckedChangeListener { _, checkedId -> - presenter.onTypeChange(when (checkedId) { - R.id.gradeStatisticsTypeSemester -> ViewType.SEMESTER - R.id.gradeStatisticsTypePartial -> ViewType.PARTIAL - else -> ViewType.POINTS - }) - } + gradeStatisticsTypeSwitch.setOnCheckedChangeListener { _, _ -> presenter.onTypeChange() } } override fun onSaveInstanceState(outState: Bundle) { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsPresenter.kt index 9795c130..bea70ea4 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsPresenter.kt @@ -94,7 +94,8 @@ class GradeStatisticsPresenter @Inject constructor( } } - fun onTypeChange(type: ViewType) { + fun onTypeChange() { + val type = view?.let { it.currentType } ?: ViewType.POINTS Timber.i("Select grade stats semester: $type") disposable.clear() view?.run { @@ -214,7 +215,7 @@ class GradeStatisticsPresenter @Inject constructor( private fun showErrorViewOnError(message: String, error: Throwable) { view?.run { - if (isBarViewEmpty || isPieViewEmpty) { + if ((isBarViewEmpty && currentType == ViewType.POINTS) || (isPieViewEmpty) && currentType != ViewType.POINTS) { lastError = error setErrorDetails(message) showErrorView(true) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsView.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsView.kt index a214744c..003520fb 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsView.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/statistics/GradeStatisticsView.kt @@ -10,6 +10,8 @@ interface GradeStatisticsView : BaseView { val isBarViewEmpty: Boolean + val currentType: ViewType + fun initView() fun updateSubjects(data: ArrayList) diff --git a/app/src/test/java/io/github/wulkanowy/data/repositories/attendance/AttendanceRemoteTest.kt b/app/src/test/java/io/github/wulkanowy/data/repositories/attendance/AttendanceRemoteTest.kt index 318d4ff7..b471dc52 100644 --- a/app/src/test/java/io/github/wulkanowy/data/repositories/attendance/AttendanceRemoteTest.kt +++ b/app/src/test/java/io/github/wulkanowy/data/repositories/attendance/AttendanceRemoteTest.kt @@ -57,6 +57,7 @@ class AttendanceRemoteTest { subject = "Fizyka", name = "Obecność", date = date, + timeId = 0, number = 0, deleted = false, excusable = false, @@ -65,7 +66,8 @@ class AttendanceRemoteTest { lateness = false, presence = false, categoryId = 1, - absence = false + absence = false, + excuseStatus = null ) } }