From 40e95eac1e1d7f1ad7f2b47ae742445613f09a91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Pich?= Date: Wed, 6 Nov 2019 23:52:15 +0100 Subject: [PATCH] Add BaseDao interface (#581) --- .../wulkanowy/data/db/dao/AttendanceDao.kt | 10 +--------- .../data/db/dao/AttendanceSummaryDao.kt | 10 +--------- .../io/github/wulkanowy/data/db/dao/BaseDao.kt | 17 +++++++++++++++++ .../data/db/dao/CompletedLessonsDao.kt | 10 +--------- .../io/github/wulkanowy/data/db/dao/ExamDao.kt | 10 +--------- .../io/github/wulkanowy/data/db/dao/GradeDao.kt | 14 +------------- .../data/db/dao/GradePointsStatisticsDao.kt | 10 +--------- .../wulkanowy/data/db/dao/GradeStatisticsDao.kt | 10 +--------- .../wulkanowy/data/db/dao/GradeSummaryDao.kt | 10 +--------- .../github/wulkanowy/data/db/dao/HomeworkDao.kt | 10 +--------- .../wulkanowy/data/db/dao/LuckyNumberDao.kt | 15 +-------------- .../github/wulkanowy/data/db/dao/MessagesDao.kt | 14 +------------- .../wulkanowy/data/db/dao/MobileDeviceDao.kt | 10 +--------- .../io/github/wulkanowy/data/db/dao/NoteDao.kt | 15 +-------------- .../wulkanowy/data/db/dao/RecipientDao.kt | 10 +--------- .../wulkanowy/data/db/dao/ReportingUnitDao.kt | 10 +--------- .../github/wulkanowy/data/db/dao/SchoolDao.kt | 10 +--------- .../github/wulkanowy/data/db/dao/SemesterDao.kt | 10 +--------- .../github/wulkanowy/data/db/dao/SubjectDao.kt | 10 +--------- .../github/wulkanowy/data/db/dao/TeacherDao.kt | 10 +--------- .../wulkanowy/data/db/dao/TimetableDao.kt | 10 +--------- .../luckynumber/LuckyNumberLocal.kt | 6 +++--- .../data/repositories/message/MessageRemote.kt | 1 - .../mobiledevice/MobileDeviceLocal.kt | 1 - .../repositories/recipient/RecipientLocal.kt | 2 +- .../reportingunit/ReportingUnitLocal.kt | 2 +- .../data/repositories/school/SchoolLocal.kt | 4 ++-- .../data/repositories/student/StudentLocal.kt | 2 +- build.gradle | 2 +- 29 files changed, 46 insertions(+), 209 deletions(-) create mode 100644 app/src/main/java/io/github/wulkanowy/data/db/dao/BaseDao.kt diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/AttendanceDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/AttendanceDao.kt index d3c4f146f..3eb57473d 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/AttendanceDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/AttendanceDao.kt @@ -1,8 +1,6 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query import io.github.wulkanowy.data.db.entities.Attendance import io.reactivex.Maybe @@ -11,13 +9,7 @@ import javax.inject.Singleton @Singleton @Dao -interface AttendanceDao { - - @Insert - fun insertAll(exams: List): List - - @Delete - fun deleteAll(exams: List) +interface AttendanceDao : BaseDao { @Query("SELECT * FROM Attendance WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end") fun loadAll(diaryId: Int, studentId: Int, from: LocalDate, end: LocalDate): Maybe> diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/AttendanceSummaryDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/AttendanceSummaryDao.kt index a7413de56..fd58533f1 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/AttendanceSummaryDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/AttendanceSummaryDao.kt @@ -1,20 +1,12 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query import io.github.wulkanowy.data.db.entities.AttendanceSummary import io.reactivex.Maybe @Dao -interface AttendanceSummaryDao { - - @Insert - fun insertAll(exams: List): List - - @Delete - fun deleteAll(exams: List) +interface AttendanceSummaryDao : BaseDao { @Query("SELECT * FROM AttendanceSummary WHERE diary_id = :diaryId AND student_id = :studentId AND subject_id = :subjectId") fun loadAll(diaryId: Int, studentId: Int, subjectId: Int): Maybe> diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/BaseDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/BaseDao.kt new file mode 100644 index 000000000..32dbadb86 --- /dev/null +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/BaseDao.kt @@ -0,0 +1,17 @@ +package io.github.wulkanowy.data.db.dao + +import androidx.room.Delete +import androidx.room.Insert +import androidx.room.Update + +interface BaseDao { + + @Insert + fun insertAll(items: List): List + + @Update + fun updateAll(items: List) + + @Delete + fun deleteAll(items: List) +} diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/CompletedLessonsDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/CompletedLessonsDao.kt index 6816ceaaf..e13e569b6 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/CompletedLessonsDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/CompletedLessonsDao.kt @@ -1,8 +1,6 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query import io.github.wulkanowy.data.db.entities.CompletedLesson import io.reactivex.Maybe @@ -11,13 +9,7 @@ import javax.inject.Singleton @Singleton @Dao -interface CompletedLessonsDao { - - @Insert - fun insertAll(exams: List) - - @Delete - fun deleteAll(exams: List) +interface CompletedLessonsDao : BaseDao { @Query("SELECT * FROM CompletedLesson WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end") fun loadAll(diaryId: Int, studentId: Int, from: LocalDate, end: LocalDate): Maybe> diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/ExamDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/ExamDao.kt index 06cd56135..ca6b32dfc 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/ExamDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/ExamDao.kt @@ -1,8 +1,6 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query import io.github.wulkanowy.data.db.entities.Exam import io.reactivex.Maybe @@ -11,13 +9,7 @@ import javax.inject.Singleton @Singleton @Dao -interface ExamDao { - - @Insert - fun insertAll(exams: List): List - - @Delete - fun deleteAll(exams: List) +interface ExamDao : BaseDao { @Query("SELECT * FROM Exams WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end") fun loadAll(diaryId: Int, studentId: Int, from: LocalDate, end: LocalDate): Maybe> diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeDao.kt index 0bd210b02..c74d1937f 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeDao.kt @@ -1,26 +1,14 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query -import androidx.room.Update import io.github.wulkanowy.data.db.entities.Grade import io.reactivex.Maybe import javax.inject.Singleton @Singleton @Dao -interface GradeDao { - - @Insert - fun insertAll(grades: List) - - @Update - fun updateAll(grade: List) - - @Delete - fun deleteAll(grades: List) +interface GradeDao : BaseDao { @Query("SELECT * FROM Grades WHERE semester_id = :semesterId AND student_id = :studentId") fun loadAll(semesterId: Int, studentId: Int): Maybe> diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradePointsStatisticsDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradePointsStatisticsDao.kt index 99a1269bd..376092865 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradePointsStatisticsDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradePointsStatisticsDao.kt @@ -1,8 +1,6 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query import io.github.wulkanowy.data.db.entities.GradePointsStatistics import io.reactivex.Maybe @@ -10,13 +8,7 @@ import javax.inject.Singleton @Singleton @Dao -interface GradePointsStatisticsDao { - - @Insert - fun insertAll(gradesStatistics: List) - - @Delete - fun deleteAll(gradesStatistics: List) +interface GradePointsStatisticsDao : BaseDao { @Query("SELECT * FROM GradesPointsStatistics WHERE student_id = :studentId AND semester_id = :semesterId AND subject = :subjectName") fun loadSubject(semesterId: Int, studentId: Int, subjectName: String): Maybe diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeStatisticsDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeStatisticsDao.kt index 338c369fa..6faa35d0b 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeStatisticsDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeStatisticsDao.kt @@ -1,8 +1,6 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query import io.github.wulkanowy.data.db.entities.GradeStatistics import io.reactivex.Maybe @@ -10,13 +8,7 @@ import javax.inject.Singleton @Singleton @Dao -interface GradeStatisticsDao { - - @Insert - fun insertAll(gradesStatistics: List) - - @Delete - fun deleteAll(gradesStatistics: List) +interface GradeStatisticsDao : BaseDao { @Query("SELECT * FROM GradesStatistics WHERE student_id = :studentId AND semester_id = :semesterId AND subject = :subjectName AND is_semester = :isSemester") fun loadSubject(semesterId: Int, studentId: Int, subjectName: String, isSemester: Boolean): Maybe> diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeSummaryDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeSummaryDao.kt index 3f2e87bd0..1165ef07f 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeSummaryDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/GradeSummaryDao.kt @@ -1,8 +1,6 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query import io.github.wulkanowy.data.db.entities.GradeSummary import io.reactivex.Maybe @@ -10,13 +8,7 @@ import javax.inject.Singleton @Singleton @Dao -interface GradeSummaryDao { - - @Insert - fun insertAll(gradesSummary: List) - - @Delete - fun deleteAll(gradesSummary: List) +interface GradeSummaryDao : BaseDao { @Query("SELECT * FROM GradesSummary WHERE student_id = :studentId AND semester_id = :semesterId") fun loadAll(semesterId: Int, studentId: Int): Maybe> diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/HomeworkDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/HomeworkDao.kt index 253bdb11f..1947a0dfe 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/HomeworkDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/HomeworkDao.kt @@ -1,8 +1,6 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query import io.github.wulkanowy.data.db.entities.Homework import io.reactivex.Maybe @@ -11,13 +9,7 @@ import javax.inject.Singleton @Singleton @Dao -interface HomeworkDao { - - @Insert - fun insertAll(homework: List) - - @Delete - fun deleteAll(homework: List) +interface HomeworkDao : BaseDao { @Query("SELECT * FROM Homework WHERE semester_id = :semesterId AND student_id = :studentId AND date >= :from AND date <= :end") fun loadAll(semesterId: Int, studentId: Int, from: LocalDate, end: LocalDate): Maybe> diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/LuckyNumberDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/LuckyNumberDao.kt index afd7905c0..f16c28d9e 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/LuckyNumberDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/LuckyNumberDao.kt @@ -1,10 +1,7 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query -import androidx.room.Update import io.github.wulkanowy.data.db.entities.LuckyNumber import io.reactivex.Maybe import org.threeten.bp.LocalDate @@ -12,18 +9,8 @@ import javax.inject.Singleton @Singleton @Dao -interface LuckyNumberDao { - - @Insert - fun insert(luckyNumber: LuckyNumber) - - @Update - fun update(luckyNumber: LuckyNumber) - - @Delete - fun delete(luckyNumber: LuckyNumber) +interface LuckyNumberDao : BaseDao { @Query("SELECT * FROM LuckyNumbers WHERE student_id = :studentId AND date = :date") fun load(studentId: Int, date: LocalDate): Maybe - } diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/MessagesDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/MessagesDao.kt index 4f72c6c91..6d14ad016 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/MessagesDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/MessagesDao.kt @@ -1,24 +1,12 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query -import androidx.room.Update import io.github.wulkanowy.data.db.entities.Message import io.reactivex.Maybe @Dao -interface MessagesDao { - - @Insert - fun insertAll(messages: List) - - @Delete - fun deleteAll(messages: List) - - @Update - fun updateAll(messages: List) +interface MessagesDao : BaseDao { @Query("SELECT * FROM Messages WHERE student_id = :studentId AND folder_id = :folder AND removed = 0 ORDER BY date DESC") fun loadAll(studentId: Int, folder: Int): Maybe> diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/MobileDeviceDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/MobileDeviceDao.kt index d6b97f6ad..b05b2d9cc 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/MobileDeviceDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/MobileDeviceDao.kt @@ -1,20 +1,12 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query import io.github.wulkanowy.data.db.entities.MobileDevice import io.reactivex.Maybe @Dao -interface MobileDeviceDao { - - @Insert - fun insertAll(devices: List) - - @Delete - fun deleteAll(devices: List) +interface MobileDeviceDao : BaseDao { @Query("SELECT * FROM MobileDevices WHERE student_id = :studentId ORDER BY date DESC") fun loadAll(studentId: Int): Maybe> diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/NoteDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/NoteDao.kt index 867e06a25..ea2fc6eb2 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/NoteDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/NoteDao.kt @@ -1,28 +1,15 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query -import androidx.room.Update import io.github.wulkanowy.data.db.entities.Note import io.reactivex.Maybe import javax.inject.Singleton @Singleton @Dao -interface NoteDao { - - @Insert - fun insertAll(notes: List) - - @Update - fun updateAll(notes: List) - - @Delete - fun deleteAll(notes: List) +interface NoteDao : BaseDao { @Query("SELECT * FROM Notes WHERE student_id = :studentId") fun loadAll(studentId: Int): Maybe> - } diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/RecipientDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/RecipientDao.kt index 7c5fd6ca6..afb941b1a 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/RecipientDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/RecipientDao.kt @@ -1,8 +1,6 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query import io.github.wulkanowy.data.db.entities.Recipient import io.reactivex.Maybe @@ -10,13 +8,7 @@ import javax.inject.Singleton @Singleton @Dao -interface RecipientDao { - - @Insert - fun insertAll(messages: List) - - @Delete - fun deleteAll(messages: List) +interface RecipientDao : BaseDao { @Query("SELECT * FROM Recipients WHERE student_id = :studentId AND role = :role AND unit_id = :unitId") fun load(studentId: Int, role: Int, unitId: Int): Maybe> diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/ReportingUnitDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/ReportingUnitDao.kt index 1898390a9..6ddfd4941 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/ReportingUnitDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/ReportingUnitDao.kt @@ -1,8 +1,6 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query import io.github.wulkanowy.data.db.entities.ReportingUnit import io.reactivex.Maybe @@ -10,13 +8,7 @@ import javax.inject.Singleton @Singleton @Dao -interface ReportingUnitDao { - - @Insert - fun insertAll(reportingUnits: List) - - @Delete - fun deleteAll(reportingUnits: List) +interface ReportingUnitDao : BaseDao { @Query("SELECT * FROM ReportingUnits WHERE student_id = :studentId") fun load(studentId: Int): Maybe> diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/SchoolDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/SchoolDao.kt index c2b2e0bcb..e9bd67557 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/SchoolDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/SchoolDao.kt @@ -1,8 +1,6 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query import io.github.wulkanowy.data.db.entities.School import io.reactivex.Maybe @@ -10,13 +8,7 @@ import javax.inject.Singleton @Singleton @Dao -interface SchoolDao { - - @Insert - fun insert(school: School) - - @Delete - fun delete(school: School) +interface SchoolDao : BaseDao { @Query("SELECT * FROM School WHERE student_id = :studentId AND class_id = :classId") fun load(studentId: Int, classId: Int): Maybe diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/SemesterDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/SemesterDao.kt index 01841fb67..654b80f38 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/SemesterDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/SemesterDao.kt @@ -1,8 +1,6 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query import io.github.wulkanowy.data.db.entities.Semester import io.reactivex.Maybe @@ -10,13 +8,7 @@ import javax.inject.Singleton @Singleton @Dao -interface SemesterDao { - - @Insert - fun insertAll(semester: List) - - @Delete - fun deleteAll(semester: List) +interface SemesterDao : BaseDao { @Query("SELECT * FROM Semesters WHERE student_id = :studentId AND class_id = :classId") fun loadAll(studentId: Int, classId: Int): Maybe> diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/SubjectDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/SubjectDao.kt index 725a371ab..525a7129a 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/SubjectDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/SubjectDao.kt @@ -1,20 +1,12 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query import io.github.wulkanowy.data.db.entities.Subject import io.reactivex.Maybe @Dao -interface SubjectDao { - - @Insert - fun insertAll(subjects: List): List - - @Delete - fun deleteAll(subjects: List) +interface SubjectDao : BaseDao { @Query("SELECT * FROM Subjects WHERE diary_id = :diaryId AND student_id = :studentId") fun loadAll(diaryId: Int, studentId: Int): Maybe> diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/TeacherDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/TeacherDao.kt index e7794248a..5ea237a84 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/TeacherDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/TeacherDao.kt @@ -1,8 +1,6 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query import io.github.wulkanowy.data.db.entities.Teacher import io.reactivex.Maybe @@ -10,13 +8,7 @@ import javax.inject.Singleton @Singleton @Dao -interface TeacherDao { - - @Insert - fun insertAll(teachers: List) - - @Delete - fun deleteAll(teachers: List) +interface TeacherDao : BaseDao { @Query("SELECT * FROM Teachers WHERE student_id = :studentId AND class_id = :classId") fun loadAll(studentId: Int, classId: Int): Maybe> diff --git a/app/src/main/java/io/github/wulkanowy/data/db/dao/TimetableDao.kt b/app/src/main/java/io/github/wulkanowy/data/db/dao/TimetableDao.kt index abe213618..6b62cc82a 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/dao/TimetableDao.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/dao/TimetableDao.kt @@ -1,8 +1,6 @@ package io.github.wulkanowy.data.db.dao import androidx.room.Dao -import androidx.room.Delete -import androidx.room.Insert import androidx.room.Query import io.github.wulkanowy.data.db.entities.Timetable import io.reactivex.Maybe @@ -11,13 +9,7 @@ import javax.inject.Singleton @Singleton @Dao -interface TimetableDao { - - @Insert - fun insertAll(exams: List): List - - @Delete - fun deleteAll(exams: List) +interface TimetableDao : BaseDao { @Query("SELECT * FROM Timetable WHERE diary_id = :diaryId AND student_id = :studentId AND date >= :from AND date <= :end") fun loadAll(diaryId: Int, studentId: Int, from: LocalDate, end: LocalDate): Maybe> diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/luckynumber/LuckyNumberLocal.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/luckynumber/LuckyNumberLocal.kt index 115c89652..b461ca22a 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/luckynumber/LuckyNumberLocal.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/luckynumber/LuckyNumberLocal.kt @@ -12,15 +12,15 @@ import javax.inject.Singleton class LuckyNumberLocal @Inject constructor(private val luckyNumberDb: LuckyNumberDao) { fun saveLuckyNumber(luckyNumber: LuckyNumber) { - luckyNumberDb.insert(luckyNumber) + luckyNumberDb.insertAll(listOf(luckyNumber)) } fun updateLuckyNumber(luckyNumber: LuckyNumber) { - luckyNumberDb.update(luckyNumber) + luckyNumberDb.updateAll(listOf(luckyNumber)) } fun deleteLuckyNumber(luckyNumber: LuckyNumber) { - luckyNumberDb.delete(luckyNumber) + luckyNumberDb.deleteAll(listOf(luckyNumber)) } fun getLuckyNumber(semester: Semester, date: LocalDate): Maybe { diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/message/MessageRemote.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/message/MessageRemote.kt index b2bff1e77..90c510ef8 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/message/MessageRemote.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/message/MessageRemote.kt @@ -11,7 +11,6 @@ import io.reactivex.Single import org.threeten.bp.LocalDateTime.now import javax.inject.Inject import javax.inject.Singleton -import io.github.wulkanowy.api.messages.Message as ApiMessage import io.github.wulkanowy.api.messages.Recipient as ApiRecipient @Singleton diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/mobiledevice/MobileDeviceLocal.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/mobiledevice/MobileDeviceLocal.kt index 8f0efa5b6..473ffa7fe 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/mobiledevice/MobileDeviceLocal.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/mobiledevice/MobileDeviceLocal.kt @@ -3,7 +3,6 @@ package io.github.wulkanowy.data.repositories.mobiledevice import io.github.wulkanowy.data.db.dao.MobileDeviceDao import io.github.wulkanowy.data.db.entities.MobileDevice import io.github.wulkanowy.data.db.entities.Semester -import io.github.wulkanowy.data.db.entities.Student import io.reactivex.Maybe import javax.inject.Inject import javax.inject.Singleton diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/recipient/RecipientLocal.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/recipient/RecipientLocal.kt index 6b8328ec2..9b1d4ac2f 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/recipient/RecipientLocal.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/recipient/RecipientLocal.kt @@ -15,7 +15,7 @@ class RecipientLocal @Inject constructor(private val recipientDb: RecipientDao) return recipientDb.load(student.studentId, role, unit.realId).filter { !it.isEmpty() } } - fun saveRecipients(recipients: List) { + fun saveRecipients(recipients: List): List { return recipientDb.insertAll(recipients) } diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/reportingunit/ReportingUnitLocal.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/reportingunit/ReportingUnitLocal.kt index b4281cbfd..6f9eec3fc 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/reportingunit/ReportingUnitLocal.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/reportingunit/ReportingUnitLocal.kt @@ -18,7 +18,7 @@ class ReportingUnitLocal @Inject constructor(private val reportingUnitDb: Report return reportingUnitDb.loadOne(student.studentId, unitId) } - fun saveReportingUnits(reportingUnits: List) { + fun saveReportingUnits(reportingUnits: List): List { return reportingUnitDb.insertAll(reportingUnits) } diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/school/SchoolLocal.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/school/SchoolLocal.kt index 1692e39b4..d87272875 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/school/SchoolLocal.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/school/SchoolLocal.kt @@ -9,11 +9,11 @@ import javax.inject.Inject class SchoolLocal @Inject constructor(private val schoolDb: SchoolDao) { fun saveSchool(school: School) { - schoolDb.insert(school) + schoolDb.insertAll(listOf(school)) } fun deleteSchool(school: School) { - schoolDb.delete(school) + schoolDb.deleteAll(listOf(school)) } fun getSchool(semester: Semester): Maybe { diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/student/StudentLocal.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/student/StudentLocal.kt index e6d744213..f27199f28 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/student/StudentLocal.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/student/StudentLocal.kt @@ -24,7 +24,7 @@ class StudentLocal @Inject constructor( fun getStudents(decryptPass: Boolean): Maybe> { return studentDb.loadAll() .map { list -> list.map { it.apply { if (decryptPass) password = decrypt(password) } } } - .filter { !it.isEmpty() } + .filter { it.isNotEmpty() } } fun getCurrentStudent(decryptPass: Boolean): Maybe { diff --git a/build.gradle b/build.gradle index 6c004f6f4..87df255d0 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath 'com.android.tools.build:gradle:3.5.1' + classpath 'com.android.tools.build:gradle:3.5.2' classpath 'com.google.gms:google-services:4.3.2' classpath "io.fabric.tools:gradle:1.31.2" classpath "com.github.triplet.gradle:play-publisher:2.4.2"