diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/attendance/AttendanceRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/attendance/AttendanceRepository.kt index 22fe7fa5..68e7c5f1 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/attendance/AttendanceRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/attendance/AttendanceRepository.kt @@ -5,7 +5,7 @@ import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.Inter import io.github.wulkanowy.data.db.entities.Attendance import io.github.wulkanowy.data.db.entities.Semester import io.github.wulkanowy.data.db.entities.Student -import io.github.wulkanowy.utils.friday +import io.github.wulkanowy.utils.sunday import io.github.wulkanowy.utils.monday import io.github.wulkanowy.utils.uniqueSubtract import io.reactivex.Single @@ -22,19 +22,19 @@ class AttendanceRepository @Inject constructor( ) { fun getAttendance(student: Student, semester: Semester, start: LocalDate, end: LocalDate, forceRefresh: Boolean): Single> { - return local.getAttendance(semester, start.monday, end.friday).filter { !forceRefresh } + return local.getAttendance(semester, start.monday, end.sunday).filter { !forceRefresh } .switchIfEmpty(ReactiveNetwork.checkInternetConnectivity(settings).flatMap { - if (it) remote.getAttendance(student, semester, start.monday, end.friday) + if (it) remote.getAttendance(student, semester, start.monday, end.sunday) else Single.error(UnknownHostException()) }.flatMap { newAttendance -> - local.getAttendance(semester, start.monday, end.friday) + local.getAttendance(semester, start.monday, end.sunday) .toSingle(emptyList()) .doOnSuccess { oldAttendance -> local.deleteAttendance(oldAttendance.uniqueSubtract(newAttendance)) local.saveAttendance(newAttendance.uniqueSubtract(oldAttendance)) } }.flatMap { - local.getAttendance(semester, start.monday, end.friday) + local.getAttendance(semester, start.monday, end.sunday) .toSingle(emptyList()) }).map { list -> list.filter { it.date in start..end } } } diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/completedlessons/CompletedLessonsRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/completedlessons/CompletedLessonsRepository.kt index f31e3055..72cc93eb 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/completedlessons/CompletedLessonsRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/completedlessons/CompletedLessonsRepository.kt @@ -5,7 +5,7 @@ import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.Inter import io.github.wulkanowy.data.db.entities.CompletedLesson import io.github.wulkanowy.data.db.entities.Semester import io.github.wulkanowy.data.db.entities.Student -import io.github.wulkanowy.utils.friday +import io.github.wulkanowy.utils.sunday import io.github.wulkanowy.utils.monday import io.github.wulkanowy.utils.uniqueSubtract import io.reactivex.Single @@ -22,20 +22,20 @@ class CompletedLessonsRepository @Inject constructor( ) { fun getCompletedLessons(student: Student, semester: Semester, start: LocalDate, end: LocalDate, forceRefresh: Boolean = false): Single> { - return local.getCompletedLessons(semester, start.monday, end.friday).filter { !forceRefresh } + return local.getCompletedLessons(semester, start.monday, end.sunday).filter { !forceRefresh } .switchIfEmpty(ReactiveNetwork.checkInternetConnectivity(settings) .flatMap { - if (it) remote.getCompletedLessons(student, semester, start.monday, end.friday) + if (it) remote.getCompletedLessons(student, semester, start.monday, end.sunday) else Single.error(UnknownHostException()) }.flatMap { new -> - local.getCompletedLessons(semester, start.monday, end.friday) + local.getCompletedLessons(semester, start.monday, end.sunday) .toSingle(emptyList()) .doOnSuccess { old -> local.deleteCompleteLessons(old.uniqueSubtract(new)) local.saveCompletedLessons(new.uniqueSubtract(old)) } }.flatMap { - local.getCompletedLessons(semester, start.monday, end.friday) + local.getCompletedLessons(semester, start.monday, end.sunday) .toSingle(emptyList()) }).map { list -> list.filter { it.date in start..end } } } diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/exam/ExamRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/exam/ExamRepository.kt index 452a1551..f29e4fdf 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/exam/ExamRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/exam/ExamRepository.kt @@ -5,7 +5,7 @@ import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.Inter import io.github.wulkanowy.data.db.entities.Exam import io.github.wulkanowy.data.db.entities.Semester import io.github.wulkanowy.data.db.entities.Student -import io.github.wulkanowy.utils.friday +import io.github.wulkanowy.utils.sunday import io.github.wulkanowy.utils.monday import io.github.wulkanowy.utils.uniqueSubtract import io.reactivex.Single @@ -22,20 +22,20 @@ class ExamRepository @Inject constructor( ) { fun getExams(student: Student, semester: Semester, start: LocalDate, end: LocalDate, forceRefresh: Boolean = false): Single> { - return local.getExams(semester, start.monday, end.friday).filter { !forceRefresh } + return local.getExams(semester, start.monday, end.sunday).filter { !forceRefresh } .switchIfEmpty(ReactiveNetwork.checkInternetConnectivity(settings) .flatMap { - if (it) remote.getExams(student, semester, start.monday, end.friday) + if (it) remote.getExams(student, semester, start.monday, end.sunday) else Single.error(UnknownHostException()) }.flatMap { new -> - local.getExams(semester, start.monday, end.friday) + local.getExams(semester, start.monday, end.sunday) .toSingle(emptyList()) .doOnSuccess { old -> local.deleteExams(old.uniqueSubtract(new)) local.saveExams(new.uniqueSubtract(old)) } }.flatMap { - local.getExams(semester, start.monday, end.friday) + local.getExams(semester, start.monday, end.sunday) .toSingle(emptyList()) }).map { list -> list.filter { it.date in start..end } } } diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/homework/HomeworkRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/homework/HomeworkRepository.kt index 4454fd88..7e8fd5c3 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/homework/HomeworkRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/homework/HomeworkRepository.kt @@ -5,7 +5,7 @@ import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.Inter import io.github.wulkanowy.data.db.entities.Homework import io.github.wulkanowy.data.db.entities.Semester import io.github.wulkanowy.data.db.entities.Student -import io.github.wulkanowy.utils.friday +import io.github.wulkanowy.utils.sunday import io.github.wulkanowy.utils.monday import io.github.wulkanowy.utils.uniqueSubtract import io.reactivex.Completable @@ -23,7 +23,7 @@ class HomeworkRepository @Inject constructor( ) { fun getHomework(student: Student, semester: Semester, start: LocalDate, end: LocalDate, forceRefresh: Boolean = false): Single> { - return Single.fromCallable { start.monday to end.friday }.flatMap { (monday, friday) -> + return Single.fromCallable { start.monday to end.sunday }.flatMap { (monday, friday) -> local.getHomework(semester, monday, friday).filter { !forceRefresh } .switchIfEmpty(ReactiveNetwork.checkInternetConnectivity(settings) .flatMap { diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/timetable/TimetableRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/timetable/TimetableRepository.kt index 082b03cf..4a7a0eb2 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/timetable/TimetableRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/timetable/TimetableRepository.kt @@ -6,7 +6,7 @@ import io.github.wulkanowy.data.db.entities.Semester import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.data.db.entities.Timetable import io.github.wulkanowy.services.alarm.TimetableNotificationSchedulerHelper -import io.github.wulkanowy.utils.friday +import io.github.wulkanowy.utils.sunday import io.github.wulkanowy.utils.monday import io.github.wulkanowy.utils.uniqueSubtract import io.reactivex.Single @@ -24,13 +24,13 @@ class TimetableRepository @Inject constructor( ) { fun getTimetable(student: Student, semester: Semester, start: LocalDate, end: LocalDate, forceRefresh: Boolean = false): Single> { - return Single.fromCallable { start.monday to end.friday }.flatMap { (monday, friday) -> - local.getTimetable(semester, monday, friday).filter { !forceRefresh } + return Single.fromCallable { start.monday to end.sunday }.flatMap { (monday, sunday) -> + local.getTimetable(semester, monday, sunday).filter { !forceRefresh } .switchIfEmpty(ReactiveNetwork.checkInternetConnectivity(settings).flatMap { - if (it) remote.getTimetable(student, semester, monday, friday) + if (it) remote.getTimetable(student, semester, monday, sunday) else Single.error(UnknownHostException()) }.flatMap { new -> - local.getTimetable(semester, monday, friday) + local.getTimetable(semester, monday, sunday) .toSingle(emptyList()) .doOnSuccess { old -> local.deleteTimetable(old.uniqueSubtract(new).also { schedulerHelper.cancelScheduled(it) }) @@ -46,7 +46,7 @@ class TimetableRepository @Inject constructor( }) } }.flatMap { - local.getTimetable(semester, monday, friday).toSingle(emptyList()) + local.getTimetable(semester, monday, sunday).toSingle(emptyList()) }).map { list -> list.filter { it.date in start..end }.also { schedulerHelper.scheduleNotifications(it, student) } } } } diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/works/AttendanceWork.kt b/app/src/main/java/io/github/wulkanowy/services/sync/works/AttendanceWork.kt index e8579ddb..063b7482 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/works/AttendanceWork.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/works/AttendanceWork.kt @@ -3,7 +3,7 @@ package io.github.wulkanowy.services.sync.works import io.github.wulkanowy.data.db.entities.Semester import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.data.repositories.attendance.AttendanceRepository -import io.github.wulkanowy.utils.friday +import io.github.wulkanowy.utils.sunday import io.github.wulkanowy.utils.monday import io.reactivex.Completable import org.threeten.bp.LocalDate.now @@ -12,7 +12,7 @@ import javax.inject.Inject class AttendanceWork @Inject constructor(private val attendanceRepository: AttendanceRepository) : Work { override fun create(student: Student, semester: Semester): Completable { - return attendanceRepository.getAttendance(student, semester, now().monday, now().friday, true) + return attendanceRepository.getAttendance(student, semester, now().monday, now().sunday, true) .ignoreElement() } } diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/works/CompletedLessonWork.kt b/app/src/main/java/io/github/wulkanowy/services/sync/works/CompletedLessonWork.kt index 0da597e0..26f79a0d 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/works/CompletedLessonWork.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/works/CompletedLessonWork.kt @@ -3,7 +3,7 @@ package io.github.wulkanowy.services.sync.works import io.github.wulkanowy.data.db.entities.Semester import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.data.repositories.completedlessons.CompletedLessonsRepository -import io.github.wulkanowy.utils.friday +import io.github.wulkanowy.utils.sunday import io.github.wulkanowy.utils.monday import io.reactivex.Completable import org.threeten.bp.LocalDate.now @@ -14,7 +14,7 @@ class CompletedLessonWork @Inject constructor( ) : Work { override fun create(student: Student, semester: Semester): Completable { - return completedLessonsRepository.getCompletedLessons(student, semester, now().monday, now().friday, true) + return completedLessonsRepository.getCompletedLessons(student, semester, now().monday, now().sunday, true) .ignoreElement() } } diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/works/ExamWork.kt b/app/src/main/java/io/github/wulkanowy/services/sync/works/ExamWork.kt index c6110bbb..1ef97f59 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/works/ExamWork.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/works/ExamWork.kt @@ -3,7 +3,7 @@ package io.github.wulkanowy.services.sync.works import io.github.wulkanowy.data.db.entities.Semester import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.data.repositories.exam.ExamRepository -import io.github.wulkanowy.utils.friday +import io.github.wulkanowy.utils.sunday import io.github.wulkanowy.utils.monday import io.reactivex.Completable import org.threeten.bp.LocalDate.now @@ -12,6 +12,6 @@ import javax.inject.Inject class ExamWork @Inject constructor(private val examRepository: ExamRepository) : Work { override fun create(student: Student, semester: Semester): Completable { - return examRepository.getExams(student, semester, now().monday, now().friday, true).ignoreElement() + return examRepository.getExams(student, semester, now().monday, now().sunday, true).ignoreElement() } } diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/works/HomeworkWork.kt b/app/src/main/java/io/github/wulkanowy/services/sync/works/HomeworkWork.kt index cf348439..186d57b0 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/works/HomeworkWork.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/works/HomeworkWork.kt @@ -3,7 +3,7 @@ package io.github.wulkanowy.services.sync.works import io.github.wulkanowy.data.db.entities.Semester import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.data.repositories.homework.HomeworkRepository -import io.github.wulkanowy.utils.friday +import io.github.wulkanowy.utils.sunday import io.github.wulkanowy.utils.monday import io.reactivex.Completable import org.threeten.bp.LocalDate.now @@ -12,6 +12,6 @@ import javax.inject.Inject class HomeworkWork @Inject constructor(private val homeworkRepository: HomeworkRepository) : Work { override fun create(student: Student, semester: Semester): Completable { - return homeworkRepository.getHomework(student, semester, now().monday, now().friday, true).ignoreElement() + return homeworkRepository.getHomework(student, semester, now().monday, now().sunday, true).ignoreElement() } } diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/works/TimetableWork.kt b/app/src/main/java/io/github/wulkanowy/services/sync/works/TimetableWork.kt index 0990ed67..d79d2403 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/works/TimetableWork.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/works/TimetableWork.kt @@ -3,7 +3,7 @@ package io.github.wulkanowy.services.sync.works import io.github.wulkanowy.data.db.entities.Semester import io.github.wulkanowy.data.db.entities.Student import io.github.wulkanowy.data.repositories.timetable.TimetableRepository -import io.github.wulkanowy.utils.friday +import io.github.wulkanowy.utils.sunday import io.github.wulkanowy.utils.monday import io.reactivex.Completable import org.threeten.bp.LocalDate.now @@ -12,7 +12,7 @@ import javax.inject.Inject class TimetableWork @Inject constructor(private val timetableRepository: TimetableRepository) : Work { override fun create(student: Student, semester: Semester): Completable { - return timetableRepository.getTimetable(student, semester, now().monday, now().friday, true) + return timetableRepository.getTimetable(student, semester, now().monday, now().sunday, true) .ignoreElement() } } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/exam/ExamPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/exam/ExamPresenter.kt index 1c47cc7d..1140cb02 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/exam/ExamPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/exam/ExamPresenter.kt @@ -8,7 +8,7 @@ import io.github.wulkanowy.ui.base.BasePresenter import io.github.wulkanowy.ui.base.ErrorHandler import io.github.wulkanowy.utils.FirebaseAnalyticsHelper import io.github.wulkanowy.utils.SchedulersProvider -import io.github.wulkanowy.utils.friday +import io.github.wulkanowy.utils.sunday import io.github.wulkanowy.utils.getLastSchoolDayIfHoliday import io.github.wulkanowy.utils.isHolidays import io.github.wulkanowy.utils.monday @@ -110,7 +110,7 @@ class ExamPresenter @Inject constructor( add(studentRepository.getCurrentStudent() .flatMap { student -> semesterRepository.getCurrentSemester(student).flatMap { semester -> - examRepository.getExams(student, semester, currentDate.monday, currentDate.friday, forceRefresh) + examRepository.getExams(student, semester, currentDate.monday, currentDate.sunday, forceRefresh) } } .map { createExamItems(it) } @@ -181,7 +181,7 @@ class ExamPresenter @Inject constructor( showPreButton(!currentDate.minusDays(7).isHolidays) showNextButton(!currentDate.plusDays(7).isHolidays) updateNavigationWeek("${currentDate.monday.toFormattedString("dd.MM")} - " + - currentDate.friday.toFormattedString("dd.MM")) + currentDate.sunday.toFormattedString("dd.MM")) } } } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/homework/HomeworkPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/homework/HomeworkPresenter.kt index fafc3319..41735a23 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/homework/HomeworkPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/homework/HomeworkPresenter.kt @@ -8,7 +8,7 @@ import io.github.wulkanowy.ui.base.BasePresenter import io.github.wulkanowy.ui.base.ErrorHandler import io.github.wulkanowy.utils.FirebaseAnalyticsHelper import io.github.wulkanowy.utils.SchedulersProvider -import io.github.wulkanowy.utils.friday +import io.github.wulkanowy.utils.sunday import io.github.wulkanowy.utils.getLastSchoolDayIfHoliday import io.github.wulkanowy.utils.isHolidays import io.github.wulkanowy.utils.monday @@ -175,7 +175,7 @@ class HomeworkPresenter @Inject constructor( showPreButton(!currentDate.minusDays(7).isHolidays) showNextButton(!currentDate.plusDays(7).isHolidays) updateNavigationWeek("${currentDate.monday.toFormattedString("dd.MM")} - " + - currentDate.friday.toFormattedString("dd.MM")) + currentDate.sunday.toFormattedString("dd.MM")) } } } diff --git a/app/src/main/java/io/github/wulkanowy/utils/SchooldaysRangeLimiter.kt b/app/src/main/java/io/github/wulkanowy/utils/SchooldaysRangeLimiter.kt index 922aafbd..46a707ab 100644 --- a/app/src/main/java/io/github/wulkanowy/utils/SchooldaysRangeLimiter.kt +++ b/app/src/main/java/io/github/wulkanowy/utils/SchooldaysRangeLimiter.kt @@ -17,7 +17,7 @@ class SchooldaysRangeLimiter : DateRangeLimiter { override fun isOutOfRange(year: Int, month: Int, day: Int): Boolean { val date = LocalDate.of(year, month + 1, day) val dayOfWeek = date.dayOfWeek - return dayOfWeek == DayOfWeek.SUNDAY || dayOfWeek == DayOfWeek.SATURDAY || date.isHolidays + return dayOfWeek == DayOfWeek.SUNDAY || date.isHolidays } override fun getStartDate(): Calendar { diff --git a/app/src/main/java/io/github/wulkanowy/utils/TimeExtension.kt b/app/src/main/java/io/github/wulkanowy/utils/TimeExtension.kt index 8d022fc5..802b2ee0 100644 --- a/app/src/main/java/io/github/wulkanowy/utils/TimeExtension.kt +++ b/app/src/main/java/io/github/wulkanowy/utils/TimeExtension.kt @@ -92,8 +92,8 @@ inline val LocalDate.weekDayName: String inline val LocalDate.monday: LocalDate get() = with(MONDAY) -inline val LocalDate.friday: LocalDate - get() = with(FRIDAY) +inline val LocalDate.sunday: LocalDate + get() = with(SUNDAY) /** * [Dz.U. 2016 poz. 1335](http://prawo.sejm.gov.pl/isap.nsf/DocDetails.xsp?id=WDU20160001335) diff --git a/app/src/test/java/io/github/wulkanowy/utils/TimeExtensionTest.kt b/app/src/test/java/io/github/wulkanowy/utils/TimeExtensionTest.kt index 024b4727..72d08c41 100644 --- a/app/src/test/java/io/github/wulkanowy/utils/TimeExtensionTest.kt +++ b/app/src/test/java/io/github/wulkanowy/utils/TimeExtensionTest.kt @@ -38,12 +38,12 @@ class TimeExtensionTest { } @Test - fun fridayTest() { - assertEquals(of(2018, 10, 5), of(2018, 10, 2).friday) - assertEquals(of(2018, 10, 5), of(2018, 10, 5).friday) - assertEquals(of(2018, 10, 5), of(2018, 10, 6).friday) - assertEquals(of(2018, 10, 5), of(2018, 10, 7).friday) - assertEquals(of(2018, 10, 12), of(2018, 10, 8).friday) + fun sundayTestTest() { + assertEquals(of(2018, 10, 7), of(2018, 10, 2).sunday) + assertEquals(of(2018, 10, 7), of(2018, 10, 5).sunday) + assertEquals(of(2018, 10, 7), of(2018, 10, 6).sunday) + assertEquals(of(2018, 10, 7), of(2018, 10, 7).sunday) + assertEquals(of(2018, 10, 14), of(2018, 10, 8).sunday) } @Test