mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-31 13:08:21 +01:00
Show graduated students on top of student select items list
This commit is contained in:
parent
af989ba9f6
commit
6eca8c42f5
@ -12,6 +12,7 @@ import io.github.wulkanowy.data.pojos.RegisterUser
|
|||||||
import io.github.wulkanowy.data.repositories.SchoolsRepository
|
import io.github.wulkanowy.data.repositories.SchoolsRepository
|
||||||
import io.github.wulkanowy.data.repositories.StudentRepository
|
import io.github.wulkanowy.data.repositories.StudentRepository
|
||||||
import io.github.wulkanowy.data.resourceFlow
|
import io.github.wulkanowy.data.resourceFlow
|
||||||
|
import io.github.wulkanowy.sdk.scrapper.exception.StudentGraduateException
|
||||||
import io.github.wulkanowy.sdk.scrapper.login.InvalidSymbolException
|
import io.github.wulkanowy.sdk.scrapper.login.InvalidSymbolException
|
||||||
import io.github.wulkanowy.services.sync.SyncManager
|
import io.github.wulkanowy.services.sync.SyncManager
|
||||||
import io.github.wulkanowy.ui.base.BasePresenter
|
import io.github.wulkanowy.ui.base.BasePresenter
|
||||||
@ -108,8 +109,8 @@ class LoginStudentSelectPresenter @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createItems(): List<LoginStudentSelectItem> = buildList {
|
private fun createItems(): List<LoginStudentSelectItem> = buildList {
|
||||||
val notEmptySymbols = registerUser.symbols.filter { it.schools.isNotEmpty() }
|
val notEmptySymbols = registerUser.symbols.filter { it.shouldShowOnTop() }
|
||||||
val emptySymbols = registerUser.symbols.filter { it.schools.isEmpty() }
|
val emptySymbols = registerUser.symbols.filter { !it.shouldShowOnTop() }
|
||||||
|
|
||||||
if (emptySymbols.isNotEmpty() && notEmptySymbols.isNotEmpty() && emptySymbols.any { it.symbol == loginData.userEnteredSymbol }) {
|
if (emptySymbols.isNotEmpty() && notEmptySymbols.isNotEmpty() && emptySymbols.any { it.symbol == loginData.userEnteredSymbol }) {
|
||||||
add(createEmptySymbolItem(emptySymbols.first { it.symbol == loginData.userEnteredSymbol }))
|
add(createEmptySymbolItem(emptySymbols.first { it.symbol == loginData.userEnteredSymbol }))
|
||||||
@ -127,6 +128,10 @@ class LoginStudentSelectPresenter @Inject constructor(
|
|||||||
add(helpItem)
|
add(helpItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun RegisterSymbol.shouldShowOnTop(): Boolean {
|
||||||
|
return schools.isNotEmpty() || error is StudentGraduateException
|
||||||
|
}
|
||||||
|
|
||||||
private fun createNotEmptySymbolItems(
|
private fun createNotEmptySymbolItems(
|
||||||
notEmptySymbols: List<RegisterSymbol>,
|
notEmptySymbols: List<RegisterSymbol>,
|
||||||
students: List<StudentWithSemesters>,
|
students: List<StudentWithSemesters>,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user