mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-19 02:56:45 -06:00
Change all entities ids from string to int (#167)
This commit is contained in:
parent
27f6fc7e04
commit
f35d9d4b93
@ -72,7 +72,7 @@ ext.supportVersion = "28.0.0"
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
implementation('com.github.wulkanowy:api:a5667f8000') { exclude module: "threetenbp" }
|
implementation('com.github.wulkanowy:api:1400211f0d') { exclude module: "threetenbp" }
|
||||||
|
|
||||||
implementation "com.android.support:support-v4:$supportVersion"
|
implementation "com.android.support:support-v4:$supportVersion"
|
||||||
implementation "com.android.support:appcompat-v7:$supportVersion"
|
implementation "com.android.support:appcompat-v7:$supportVersion"
|
||||||
|
@ -34,13 +34,13 @@ class AttendanceLocalTest {
|
|||||||
@Test
|
@Test
|
||||||
fun saveAndReadTest() {
|
fun saveAndReadTest() {
|
||||||
attendanceLocal.saveAttendance(listOf(
|
attendanceLocal.saveAttendance(listOf(
|
||||||
Attendance("1", "2", LocalDate.of(2018, 9, 10), 0, "", ""),
|
Attendance(1, 2, LocalDate.of(2018, 9, 10), 0, "", ""),
|
||||||
Attendance("1", "2", LocalDate.of(2018, 9, 14), 0, "", ""),
|
Attendance(1, 2, LocalDate.of(2018, 9, 14), 0, "", ""),
|
||||||
Attendance("1", "2", LocalDate.of(2018, 9, 17), 0, "", "")
|
Attendance(1, 2, LocalDate.of(2018, 9, 17), 0, "", "")
|
||||||
))
|
))
|
||||||
|
|
||||||
val attendance = attendanceLocal
|
val attendance = attendanceLocal
|
||||||
.getAttendance(Semester(1, "1", "2", "", "3", 1),
|
.getAttendance(Semester(1, 1, 2, "", 3, 1),
|
||||||
LocalDate.of(2018, 9, 10),
|
LocalDate.of(2018, 9, 10),
|
||||||
LocalDate.of(2018, 9, 14)
|
LocalDate.of(2018, 9, 14)
|
||||||
)
|
)
|
||||||
|
@ -34,13 +34,13 @@ class ExamLocalTest {
|
|||||||
@Test
|
@Test
|
||||||
fun saveAndReadTest() {
|
fun saveAndReadTest() {
|
||||||
examLocal.saveExams(listOf(
|
examLocal.saveExams(listOf(
|
||||||
Exam("1", "2", LocalDate.of(2018, 9, 10), LocalDate.now(), "", "", "", "", "", ""),
|
Exam(1, 2, LocalDate.of(2018, 9, 10), LocalDate.now(), "", "", "", "", "", ""),
|
||||||
Exam("1", "2", LocalDate.of(2018, 9, 14), LocalDate.now(), "", "", "", "", "", ""),
|
Exam(1, 2, LocalDate.of(2018, 9, 14), LocalDate.now(), "", "", "", "", "", ""),
|
||||||
Exam("1", "2", LocalDate.of(2018, 9, 17), LocalDate.now(), "", "", "", "", "", "")
|
Exam(1, 2, LocalDate.of(2018, 9, 17), LocalDate.now(), "", "", "", "", "", "")
|
||||||
))
|
))
|
||||||
|
|
||||||
val exams = examLocal
|
val exams = examLocal
|
||||||
.getExams(Semester(1, "1", "2", "", "3", 1),
|
.getExams(Semester(1, 1, 2, "", 3, 1),
|
||||||
LocalDate.of(2018, 9, 10),
|
LocalDate.of(2018, 9, 10),
|
||||||
LocalDate.of(2018, 9, 14)
|
LocalDate.of(2018, 9, 14)
|
||||||
)
|
)
|
||||||
|
@ -38,12 +38,12 @@ class SessionLocalTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun saveAndReadTest() {
|
fun saveAndReadTest() {
|
||||||
sessionLocal.saveStudent(Student(email = "test", password = "test123", schoolId = "23", endpoint = "fakelog.cf", loginType = "AUTO")).blockingAwait()
|
sessionLocal.saveStudent(Student(email = "test", password = "test123", schoolSymbol = "23", endpoint = "fakelog.cf", loginType = "AUTO")).blockingAwait()
|
||||||
assert(sharedHelper.getLong(SessionLocal.LAST_USER_KEY, 0) == 1L)
|
assert(sharedHelper.getLong(SessionLocal.LAST_USER_KEY, 0) == 1L)
|
||||||
|
|
||||||
assert(sessionLocal.isSessionSaved)
|
assert(sessionLocal.isSessionSaved)
|
||||||
|
|
||||||
val student = sessionLocal.getLastStudent().blockingGet()
|
val student = sessionLocal.getLastStudent().blockingGet()
|
||||||
assertEquals("23", student.schoolId)
|
assertEquals("23", student.schoolSymbol)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,16 +35,16 @@ class TimetableLocalTest {
|
|||||||
@Test
|
@Test
|
||||||
fun saveAndReadTest() {
|
fun saveAndReadTest() {
|
||||||
timetableDb.saveTimetable(listOf(
|
timetableDb.saveTimetable(listOf(
|
||||||
Timetable("1", "2", 1, LocalDateTime.now(), LocalDateTime.now(),
|
Timetable(1, 2, 1, LocalDateTime.now(), LocalDateTime.now(),
|
||||||
LocalDate.of(2018, 9, 10), "", "", "", "", ""),
|
LocalDate.of(2018, 9, 10), "", "", "", "", ""),
|
||||||
Timetable("1", "2", 1, LocalDateTime.now(), LocalDateTime.now(),
|
Timetable(1, 2, 1, LocalDateTime.now(), LocalDateTime.now(),
|
||||||
LocalDate.of(2018, 9, 14), "", "", "", "", ""),
|
LocalDate.of(2018, 9, 14), "", "", "", "", ""),
|
||||||
Timetable("1", "2", 1, LocalDateTime.now(), LocalDateTime.now(),
|
Timetable(1, 2, 1, LocalDateTime.now(), LocalDateTime.now(),
|
||||||
LocalDate.of(2018, 9, 17), "", "", "", "", "")
|
LocalDate.of(2018, 9, 17), "", "", "", "", "")
|
||||||
))
|
))
|
||||||
|
|
||||||
val exams = timetableDb.getTimetable(
|
val exams = timetableDb.getTimetable(
|
||||||
Semester(0, "1", "2", "3", "", 1),
|
Semester(0, 1, 2, "3", 1, 1),
|
||||||
LocalDate.of(2018, 9, 10),
|
LocalDate.of(2018, 9, 10),
|
||||||
LocalDate.of(2018, 9, 14)
|
LocalDate.of(2018, 9, 14)
|
||||||
).blockingGet()
|
).blockingGet()
|
||||||
|
@ -18,5 +18,5 @@ interface AttendanceDao {
|
|||||||
fun deleteAll(exams: List<Attendance>)
|
fun deleteAll(exams: List<Attendance>)
|
||||||
|
|
||||||
@Query("SELECT * FROM Attendance WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end")
|
@Query("SELECT * FROM Attendance WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end")
|
||||||
fun getExams(diaryId: String, studentId: String, from: LocalDate, end: LocalDate): Maybe<List<Attendance>>
|
fun getExams(diaryId: Int, studentId: Int, from: LocalDate, end: LocalDate): Maybe<List<Attendance>>
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,5 @@ interface ExamDao {
|
|||||||
fun deleteAll(exams: List<Exam>)
|
fun deleteAll(exams: List<Exam>)
|
||||||
|
|
||||||
@Query("SELECT * FROM Exams WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end")
|
@Query("SELECT * FROM Exams WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end")
|
||||||
fun getExams(diaryId: String, studentId: String, from: LocalDate, end: LocalDate): Maybe<List<Exam>>
|
fun getExams(diaryId: Int, studentId: Int, from: LocalDate, end: LocalDate): Maybe<List<Exam>>
|
||||||
}
|
}
|
||||||
|
@ -17,5 +17,5 @@ interface GradeDao {
|
|||||||
fun deleteAll(grades: List<Grade>)
|
fun deleteAll(grades: List<Grade>)
|
||||||
|
|
||||||
@Query("SELECT * FROM Grades WHERE semester_id = :semesterId AND student_id = :studentId")
|
@Query("SELECT * FROM Grades WHERE semester_id = :semesterId AND student_id = :studentId")
|
||||||
fun getGrades(semesterId: String, studentId: String): Maybe<List<Grade>>
|
fun getGrades(semesterId: Int, studentId: Int): Maybe<List<Grade>>
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,5 @@ interface GradeSummaryDao {
|
|||||||
fun deleteAll(gradesSummary: List<GradeSummary>)
|
fun deleteAll(gradesSummary: List<GradeSummary>)
|
||||||
|
|
||||||
@Query("SELECT * FROM grades_summary WHERE student_id = :studentId AND semester_id = :semesterId")
|
@Query("SELECT * FROM grades_summary WHERE student_id = :studentId AND semester_id = :semesterId")
|
||||||
fun getGradesSummary(semesterId: String, studentId: String): Maybe<List<GradeSummary>>
|
fun getGradesSummary(semesterId: Int, studentId: Int): Maybe<List<GradeSummary>>
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,5 @@ interface SemesterDao {
|
|||||||
fun insertAll(semester: List<Semester>)
|
fun insertAll(semester: List<Semester>)
|
||||||
|
|
||||||
@Query("SELECT * FROM Semesters WHERE student_id = :studentId")
|
@Query("SELECT * FROM Semesters WHERE student_id = :studentId")
|
||||||
fun getSemester(studentId: String): Single<List<Semester>>
|
fun getSemester(studentId: Int): Single<List<Semester>>
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,5 @@ interface TimetableDao {
|
|||||||
fun deleteAll(exams: List<Timetable>)
|
fun deleteAll(exams: List<Timetable>)
|
||||||
|
|
||||||
@Query("SELECT * FROM Timetable WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end")
|
@Query("SELECT * FROM Timetable WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end")
|
||||||
fun getTimetable(diaryId: String, studentId: String, from: LocalDate, end: LocalDate): Maybe<List<Timetable>>
|
fun getTimetable(diaryId: Int, studentId: Int, from: LocalDate, end: LocalDate): Maybe<List<Timetable>>
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,10 @@ import java.io.Serializable
|
|||||||
data class Attendance(
|
data class Attendance(
|
||||||
|
|
||||||
@ColumnInfo(name = "student_id")
|
@ColumnInfo(name = "student_id")
|
||||||
var studentId: String,
|
var studentId: Int,
|
||||||
|
|
||||||
@ColumnInfo(name = "diary_id")
|
@ColumnInfo(name = "diary_id")
|
||||||
var diaryId: String,
|
var diaryId: Int,
|
||||||
|
|
||||||
var date: LocalDate,
|
var date: LocalDate,
|
||||||
|
|
||||||
|
@ -10,10 +10,10 @@ import java.io.Serializable
|
|||||||
data class Exam(
|
data class Exam(
|
||||||
|
|
||||||
@ColumnInfo(name = "student_id")
|
@ColumnInfo(name = "student_id")
|
||||||
var studentId: String,
|
var studentId: Int,
|
||||||
|
|
||||||
@ColumnInfo(name = "diary_id")
|
@ColumnInfo(name = "diary_id")
|
||||||
var diaryId: String,
|
var diaryId: Int,
|
||||||
|
|
||||||
var date: LocalDate,
|
var date: LocalDate,
|
||||||
|
|
||||||
|
@ -10,10 +10,10 @@ import java.io.Serializable
|
|||||||
data class Grade(
|
data class Grade(
|
||||||
|
|
||||||
@ColumnInfo(name = "semester_id")
|
@ColumnInfo(name = "semester_id")
|
||||||
var semesterId: String,
|
var semesterId: Int,
|
||||||
|
|
||||||
@ColumnInfo(name = "student_id")
|
@ColumnInfo(name = "student_id")
|
||||||
var studentId: String,
|
var studentId: Int,
|
||||||
|
|
||||||
var subject: String,
|
var subject: String,
|
||||||
|
|
||||||
|
@ -8,10 +8,10 @@ import android.arch.persistence.room.PrimaryKey
|
|||||||
data class GradeSummary(
|
data class GradeSummary(
|
||||||
|
|
||||||
@ColumnInfo(name = "semester_id")
|
@ColumnInfo(name = "semester_id")
|
||||||
var semesterId: String,
|
var semesterId: Int,
|
||||||
|
|
||||||
@ColumnInfo(name = "student_id")
|
@ColumnInfo(name = "student_id")
|
||||||
var studentId: String,
|
var studentId: Int,
|
||||||
|
|
||||||
var subject: String,
|
var subject: String,
|
||||||
|
|
||||||
|
@ -11,16 +11,16 @@ data class Semester(
|
|||||||
var id: Long = 0,
|
var id: Long = 0,
|
||||||
|
|
||||||
@ColumnInfo(name = "student_id")
|
@ColumnInfo(name = "student_id")
|
||||||
var studentId: String,
|
var studentId: Int,
|
||||||
|
|
||||||
@ColumnInfo(name = "diary_id")
|
@ColumnInfo(name = "diary_id")
|
||||||
var diaryId: String,
|
var diaryId: Int,
|
||||||
|
|
||||||
@ColumnInfo(name = "diary_name")
|
@ColumnInfo(name = "diary_name")
|
||||||
var diaryName: String,
|
var diaryName: String,
|
||||||
|
|
||||||
@ColumnInfo(name = "semester_id")
|
@ColumnInfo(name = "semester_id")
|
||||||
var semesterId: String,
|
var semesterId: Int,
|
||||||
|
|
||||||
@ColumnInfo(name = "semester_name")
|
@ColumnInfo(name = "semester_name")
|
||||||
var semesterName: Int,
|
var semesterName: Int,
|
||||||
|
@ -21,13 +21,13 @@ data class Student(
|
|||||||
var symbol: String = "",
|
var symbol: String = "",
|
||||||
|
|
||||||
@ColumnInfo(name = "student_id")
|
@ColumnInfo(name = "student_id")
|
||||||
var studentId: String = "",
|
var studentId: Int = 0,
|
||||||
|
|
||||||
@ColumnInfo(name = "student_name")
|
@ColumnInfo(name = "student_name")
|
||||||
var studentName: String = "",
|
var studentName: String = "",
|
||||||
|
|
||||||
@ColumnInfo(name = "school_id")
|
@ColumnInfo(name = "school_id")
|
||||||
var schoolId: String = "",
|
var schoolSymbol: String = "",
|
||||||
|
|
||||||
@ColumnInfo(name = "school_name")
|
@ColumnInfo(name = "school_name")
|
||||||
var schoolName: String = ""
|
var schoolName: String = ""
|
||||||
|
@ -11,10 +11,10 @@ import java.io.Serializable
|
|||||||
data class Timetable(
|
data class Timetable(
|
||||||
|
|
||||||
@ColumnInfo(name = "student_id")
|
@ColumnInfo(name = "student_id")
|
||||||
var studentId: String,
|
var studentId: Int,
|
||||||
|
|
||||||
@ColumnInfo(name = "diary_id")
|
@ColumnInfo(name = "diary_id")
|
||||||
var diaryId: String,
|
var diaryId: Int,
|
||||||
|
|
||||||
val number: Int = 0,
|
val number: Int = 0,
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class GradeRemote @Inject constructor(private val api: Api) {
|
|||||||
diaryId = semester.diaryId
|
diaryId = semester.diaryId
|
||||||
notifyDataChanged()
|
notifyDataChanged()
|
||||||
}
|
}
|
||||||
}).flatMap { api.getGrades(semester.semesterId.toInt()) }
|
}).flatMap { api.getGrades(semester.semesterId) }
|
||||||
.map { grades ->
|
.map { grades ->
|
||||||
grades.map {
|
grades.map {
|
||||||
Grade(
|
Grade(
|
||||||
|
@ -16,7 +16,7 @@ class GradeSummaryRemote @Inject constructor(private val api: Api) {
|
|||||||
diaryId = semester.diaryId
|
diaryId = semester.diaryId
|
||||||
notifyDataChanged()
|
notifyDataChanged()
|
||||||
}
|
}
|
||||||
}).flatMap { api.getGradesSummary(semester.semesterId.toInt()) }
|
}).flatMap { api.getGradesSummary(semester.semesterId) }
|
||||||
.map { gradesSummary ->
|
.map { gradesSummary ->
|
||||||
gradesSummary.map {
|
gradesSummary.map {
|
||||||
GradeSummary(
|
GradeSummary(
|
||||||
|
@ -22,7 +22,7 @@ class SessionRemote @Inject constructor(private val api: Api) {
|
|||||||
symbol = it.symbol,
|
symbol = it.symbol,
|
||||||
studentId = it.studentId,
|
studentId = it.studentId,
|
||||||
studentName = it.studentName,
|
studentName = it.studentName,
|
||||||
schoolId = it.schoolId,
|
schoolSymbol = it.schoolSymbol,
|
||||||
schoolName = it.schoolName,
|
schoolName = it.schoolName,
|
||||||
endpoint = endpoint,
|
endpoint = endpoint,
|
||||||
loginType = it.loginType.name
|
loginType = it.loginType.name
|
||||||
@ -40,7 +40,7 @@ class SessionRemote @Inject constructor(private val api: Api) {
|
|||||||
studentId = student.studentId,
|
studentId = student.studentId,
|
||||||
diaryId = it.diaryId,
|
diaryId = it.diaryId,
|
||||||
diaryName = it.diaryName,
|
diaryName = it.diaryName,
|
||||||
semesterId = it.semesterId.toString(),
|
semesterId = it.semesterId,
|
||||||
semesterName = it.semesterNumber,
|
semesterName = it.semesterNumber,
|
||||||
current = it.current
|
current = it.current
|
||||||
)
|
)
|
||||||
@ -51,14 +51,14 @@ class SessionRemote @Inject constructor(private val api: Api) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun initApi(student: Student, checkInit: Boolean = false) {
|
fun initApi(student: Student, checkInit: Boolean = false) {
|
||||||
if (if (checkInit) api.studentId.isEmpty() else true) {
|
if (if (checkInit) 0 == api.studentId else true) {
|
||||||
api.run {
|
api.run {
|
||||||
email = student.email
|
email = student.email
|
||||||
password = student.password
|
password = student.password
|
||||||
symbol = student.symbol
|
symbol = student.symbol
|
||||||
host = URL(student.endpoint).run { host + ":$port".removeSuffix(":-1") }
|
host = URL(student.endpoint).run { host + ":$port".removeSuffix(":-1") }
|
||||||
ssl = student.endpoint.startsWith("https")
|
ssl = student.endpoint.startsWith("https")
|
||||||
schoolId = student.schoolId
|
schoolSymbol = student.schoolSymbol
|
||||||
studentId = student.studentId
|
studentId = student.studentId
|
||||||
loginType = Api.LoginType.valueOf(student.loginType)
|
loginType = Api.LoginType.valueOf(student.loginType)
|
||||||
notifyDataChanged()
|
notifyDataChanged()
|
||||||
|
@ -99,11 +99,11 @@ class GradeFragment : BaseFragment(), GradeView, MainView.MenuFragmentView {
|
|||||||
presenter.onChildViewRefresh()
|
presenter.onChildViewRefresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onChildFragmentLoaded(semesterId: String) {
|
fun onChildFragmentLoaded(semesterId: Int) {
|
||||||
presenter.onChildViewLoaded(semesterId)
|
presenter.onChildViewLoaded(semesterId)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun notifyChildLoadData(index: Int, semesterId: String, forceRefresh: Boolean) {
|
override fun notifyChildLoadData(index: Int, semesterId: Int, forceRefresh: Boolean) {
|
||||||
(childFragmentManager.fragments[index] as GradeView.GradeChildView).onParentLoadData(semesterId, forceRefresh)
|
(childFragmentManager.fragments[index] as GradeView.GradeChildView).onParentLoadData(semesterId, forceRefresh)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ class GradePresenter @Inject constructor(
|
|||||||
|
|
||||||
private var semesters = emptyList<Semester>()
|
private var semesters = emptyList<Semester>()
|
||||||
|
|
||||||
private val loadedSemesterId = mutableMapOf<Int, String>()
|
private val loadedSemesterId = mutableMapOf<Int, Int>()
|
||||||
|
|
||||||
fun onAttachView(view: GradeView, savedIndex: Int?) {
|
fun onAttachView(view: GradeView, savedIndex: Int?) {
|
||||||
super.onAttachView(view)
|
super.onAttachView(view)
|
||||||
@ -55,7 +55,7 @@ class GradePresenter @Inject constructor(
|
|||||||
view?.let { loadChild(it.currentPageIndex(), forceRefresh = true) }
|
view?.let { loadChild(it.currentPageIndex(), forceRefresh = true) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onChildViewLoaded(semesterId: String) {
|
fun onChildViewLoaded(semesterId: Int) {
|
||||||
view?.apply {
|
view?.apply {
|
||||||
showContent(true)
|
showContent(true)
|
||||||
showProgress(false)
|
showProgress(false)
|
||||||
|
@ -14,7 +14,7 @@ interface GradeView : BaseView {
|
|||||||
|
|
||||||
fun showSemesterDialog(selectedIndex: Int)
|
fun showSemesterDialog(selectedIndex: Int)
|
||||||
|
|
||||||
fun notifyChildLoadData(index: Int, semesterId: String, forceRefresh: Boolean)
|
fun notifyChildLoadData(index: Int, semesterId: Int, forceRefresh: Boolean)
|
||||||
|
|
||||||
fun notifyChildParentReselected(index: Int)
|
fun notifyChildParentReselected(index: Int)
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ interface GradeView : BaseView {
|
|||||||
|
|
||||||
fun onParentChangeSemester()
|
fun onParentChangeSemester()
|
||||||
|
|
||||||
fun onParentLoadData(semesterId: String, forceRefresh: Boolean)
|
fun onParentLoadData(semesterId: Int, forceRefresh: Boolean)
|
||||||
|
|
||||||
fun onParentReselected()
|
fun onParentReselected()
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ class GradeDetailsFragment : BaseFragment(), GradeDetailsView, GradeView.GradeCh
|
|||||||
GradeDetailsDialog.newInstance(grade).show(fragmentManager, grade.toString())
|
GradeDetailsDialog.newInstance(grade).show(fragmentManager, grade.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onParentLoadData(semesterId: String, forceRefresh: Boolean) {
|
override fun onParentLoadData(semesterId: Int, forceRefresh: Boolean) {
|
||||||
presenter.onParentViewLoadData(semesterId, forceRefresh)
|
presenter.onParentViewLoadData(semesterId, forceRefresh)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ class GradeDetailsFragment : BaseFragment(), GradeDetailsView, GradeView.GradeCh
|
|||||||
presenter.onParentViewChangeSemester()
|
presenter.onParentViewChangeSemester()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun notifyParentDataLoaded(semesterId: String) {
|
override fun notifyParentDataLoaded(semesterId: Int) {
|
||||||
(parentFragment as? GradeFragment)?.onChildFragmentLoaded(semesterId)
|
(parentFragment as? GradeFragment)?.onChildFragmentLoaded(semesterId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class GradeDetailsPresenter @Inject constructor(
|
|||||||
view.initView()
|
view.initView()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onParentViewLoadData(semesterId: String, forceRefresh: Boolean) {
|
fun onParentViewLoadData(semesterId: Int, forceRefresh: Boolean) {
|
||||||
disposable.add(sessionRepository.getSemesters()
|
disposable.add(sessionRepository.getSemesters()
|
||||||
.flatMap { gradeRepository.getGrades(it.first { item -> item.semesterId == semesterId }, forceRefresh) }
|
.flatMap { gradeRepository.getGrades(it.first { item -> item.semesterId == semesterId }, forceRefresh) }
|
||||||
.map { createGradeItems(it.groupBy { grade -> grade.subject }.toSortedMap()) }
|
.map { createGradeItems(it.groupBy { grade -> grade.subject }.toSortedMap()) }
|
||||||
|
@ -40,7 +40,7 @@ interface GradeDetailsView : BaseView {
|
|||||||
|
|
||||||
fun weightString(): String
|
fun weightString(): String
|
||||||
|
|
||||||
fun notifyParentDataLoaded(semesterId: String)
|
fun notifyParentDataLoaded(semesterId: Int)
|
||||||
|
|
||||||
fun notifyParentRefresh()
|
fun notifyParentRefresh()
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ class GradeSummaryFragment : BaseFragment(), GradeSummaryView, GradeView.GradeCh
|
|||||||
gradeSummarySwipe.isRefreshing = show
|
gradeSummarySwipe.isRefreshing = show
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onParentLoadData(semesterId: String, forceRefresh: Boolean) {
|
override fun onParentLoadData(semesterId: Int, forceRefresh: Boolean) {
|
||||||
presenter.onParentViewLoadData(semesterId, forceRefresh)
|
presenter.onParentViewLoadData(semesterId, forceRefresh)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ class GradeSummaryFragment : BaseFragment(), GradeSummaryView, GradeView.GradeCh
|
|||||||
presenter.onParentViewChangeSemester()
|
presenter.onParentViewChangeSemester()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun notifyParentDataLoaded(semesterId: String) {
|
override fun notifyParentDataLoaded(semesterId: Int) {
|
||||||
(parentFragment as? GradeFragment)?.onChildFragmentLoaded(semesterId)
|
(parentFragment as? GradeFragment)?.onChildFragmentLoaded(semesterId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class GradeSummaryPresenter @Inject constructor(
|
|||||||
view.initView()
|
view.initView()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onParentViewLoadData(semesterId: String, forceRefresh: Boolean) {
|
fun onParentViewLoadData(semesterId: Int, forceRefresh: Boolean) {
|
||||||
disposable.add(sessionRepository.getSemesters()
|
disposable.add(sessionRepository.getSemesters()
|
||||||
.map { semester -> semester.first { it.semesterId == semesterId } }
|
.map { semester -> semester.first { it.semesterId == semesterId } }
|
||||||
.flatMap {
|
.flatMap {
|
||||||
|
@ -26,7 +26,7 @@ interface GradeSummaryView : BaseView {
|
|||||||
|
|
||||||
fun finalString(): String
|
fun finalString(): String
|
||||||
|
|
||||||
fun notifyParentDataLoaded(semesterId: String)
|
fun notifyParentDataLoaded(semesterId: Int)
|
||||||
|
|
||||||
fun notifyParentRefresh()
|
fun notifyParentRefresh()
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,9 @@ class AttendanceRemoteTest {
|
|||||||
getAttendance("2018-09-17")
|
getAttendance("2018-09-17")
|
||||||
))
|
))
|
||||||
|
|
||||||
every { mockApi.diaryId } returns "1"
|
every { mockApi.diaryId } returns 1
|
||||||
every { semesterMock.studentId } returns "1"
|
every { semesterMock.studentId } returns 1
|
||||||
every { semesterMock.diaryId } returns "1"
|
every { semesterMock.diaryId } returns 1
|
||||||
|
|
||||||
val attendance = AttendanceRemote(mockApi).getAttendance(semesterMock,
|
val attendance = AttendanceRemote(mockApi).getAttendance(semesterMock,
|
||||||
LocalDate.of(2018, 9, 10),
|
LocalDate.of(2018, 9, 10),
|
||||||
|
@ -36,9 +36,9 @@ class ExamRemoteTest {
|
|||||||
getExam("2018-09-17")
|
getExam("2018-09-17")
|
||||||
))
|
))
|
||||||
|
|
||||||
every { mockApi.diaryId } returns "1"
|
every { mockApi.diaryId } returns 1
|
||||||
every { semesterMock.studentId } returns "1"
|
every { semesterMock.studentId } returns 1
|
||||||
every { semesterMock.diaryId } returns "1"
|
every { semesterMock.diaryId } returns 1
|
||||||
|
|
||||||
val exams = ExamRemote(mockApi).getExams(semesterMock,
|
val exams = ExamRemote(mockApi).getExams(semesterMock,
|
||||||
LocalDate.of(2018, 9, 10),
|
LocalDate.of(2018, 9, 10),
|
||||||
|
@ -22,7 +22,7 @@ class SessionRemoteTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testRemoteAll() {
|
fun testRemoteAll() {
|
||||||
doReturn(Single.just(listOf(Pupil("", "", "", "test", "", "", Api.LoginType.AUTO))))
|
doReturn(Single.just(listOf(Pupil("", "", 1, "test", "", "", Api.LoginType.AUTO))))
|
||||||
.`when`(mockApi).getPupils()
|
.`when`(mockApi).getPupils()
|
||||||
|
|
||||||
val students = SessionRemote(mockApi).getConnectedStudents("", "", "", "http://fakelog.cf").blockingGet()
|
val students = SessionRemote(mockApi).getConnectedStudents("", "", "", "http://fakelog.cf").blockingGet()
|
||||||
|
@ -36,9 +36,9 @@ class TimetableRemoteTest {
|
|||||||
getTimetable("2018-09-17")
|
getTimetable("2018-09-17")
|
||||||
))
|
))
|
||||||
|
|
||||||
every { mockApi.diaryId } returns "1"
|
every { mockApi.diaryId } returns 1
|
||||||
every { semesterMock.studentId } returns "1"
|
every { semesterMock.studentId } returns 1
|
||||||
every { semesterMock.diaryId } returns "1"
|
every { semesterMock.diaryId } returns 1
|
||||||
|
|
||||||
val timetable = TimetableRemote(mockApi).getTimetable(semesterMock,
|
val timetable = TimetableRemote(mockApi).getTimetable(semesterMock,
|
||||||
LocalDate.of(2018, 9, 10),
|
LocalDate.of(2018, 9, 10),
|
||||||
|
@ -13,19 +13,19 @@ class GradeExtensionTest {
|
|||||||
fun calcWeightedAverage() {
|
fun calcWeightedAverage() {
|
||||||
val localDate = mock(LocalDate::class.java)
|
val localDate = mock(LocalDate::class.java)
|
||||||
assertEquals(3.47, listOf(
|
assertEquals(3.47, listOf(
|
||||||
Grade("", "", "", "", 5, 0.33
|
Grade(1, 1, "", "", 5, 0.33
|
||||||
, "", "", "", "", "",
|
, "", "", "", "", "",
|
||||||
6, localDate, ""),
|
6, localDate, ""),
|
||||||
Grade("", "", "", "", 5, -0.33
|
Grade(1, 1, "", "", 5, -0.33
|
||||||
, "", "", "", "", "",
|
, "", "", "", "", "",
|
||||||
5, localDate, ""),
|
5, localDate, ""),
|
||||||
Grade("", "", "", "", 4, 0.0
|
Grade(1, 1, "", "", 4, 0.0
|
||||||
, "", "", "", "", "",
|
, "", "", "", "", "",
|
||||||
1, localDate, ""),
|
1, localDate, ""),
|
||||||
Grade("", "", "", "", 1, 0.5
|
Grade(1, 1, "", "", 1, 0.5
|
||||||
, "", "", "", "", "",
|
, "", "", "", "", "",
|
||||||
9, localDate, ""),
|
9, localDate, ""),
|
||||||
Grade("", "", "", "", 0, 0.0
|
Grade(1, 1, "", "", 0, 0.0
|
||||||
, "", "", "", "", "",
|
, "", "", "", "", "",
|
||||||
0, localDate, "")
|
0, localDate, "")
|
||||||
).calcAverage(), 0.005)
|
).calcAverage(), 0.005)
|
||||||
@ -34,10 +34,10 @@ class GradeExtensionTest {
|
|||||||
@Test
|
@Test
|
||||||
fun calcSummaryAverage() {
|
fun calcSummaryAverage() {
|
||||||
assertEquals(2.5, listOf(
|
assertEquals(2.5, listOf(
|
||||||
GradeSummary("", "", "", "", "5"),
|
GradeSummary(1, 1, "", "", "5"),
|
||||||
GradeSummary("", "", "", "", "-5"),
|
GradeSummary(1, 1, "", "", "-5"),
|
||||||
GradeSummary("", "", "", "", "test"),
|
GradeSummary(1, 1, "", "", "test"),
|
||||||
GradeSummary("", "", "", "", "0")
|
GradeSummary(1, 1, "", "", "0")
|
||||||
).calcAverage(), 0.005)
|
).calcAverage(), 0.005)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user