Compare commits
61 Commits
Author | SHA1 | Date | |
---|---|---|---|
ff1e794820 | |||
ceba5f7fe8 | |||
f570acbed6 | |||
2a7a472d90 | |||
138fbe5bf5 | |||
ad99cc75eb | |||
f6606e7a4f | |||
3690deef1e | |||
cd1438587d | |||
8193a57227 | |||
8467f39ad9 | |||
0fc293f47a | |||
9b063edb0b | |||
5d852eee87 | |||
54ab408135 | |||
41aa326f42 | |||
24f605c71c | |||
5c52dcc74f | |||
667659fbe6 | |||
d467bf096f | |||
98d556bcd5 | |||
8c730be635 | |||
377d24fbb4 | |||
bde810e031 | |||
2f18d42c86 | |||
c708b0c20e | |||
ff8d55d4f8 | |||
49bf911c84 | |||
9e33ef419f | |||
40e95eac1e | |||
19e76a0b5d | |||
5feafe3907 | |||
b7206ed714 | |||
38370d647d | |||
323bc188b1 | |||
b17356591a | |||
a02c444cf5 | |||
87a133beb9 | |||
1f4a208857 | |||
a7c472989c | |||
747696e386 | |||
a71a183160 | |||
125a010f03 | |||
5c5993cc2a | |||
f234b71932 | |||
497a3391d4 | |||
a72c743c6f | |||
98fdfd001a | |||
994b162ae3 | |||
90c60f399b | |||
b16b225a1a | |||
7a4cf694ca | |||
1b492d50fe | |||
d9b5e000f8 | |||
7e30524876 | |||
ce9b12eb93 | |||
b602657d55 | |||
360dfbcdb5 | |||
f466497970 | |||
184a7ab200 | |||
2e5ef7dfa2 |
@ -14,7 +14,7 @@ cache:
|
||||
branches:
|
||||
only:
|
||||
- develop
|
||||
- 0.11.0
|
||||
- 0.13.0
|
||||
|
||||
android:
|
||||
licenses:
|
||||
|
@ -17,8 +17,8 @@ android {
|
||||
testApplicationId "io.github.tests.wulkanowy"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 29
|
||||
versionCode 46
|
||||
versionName "0.11.0"
|
||||
versionCode 48
|
||||
versionName "0.13.0"
|
||||
multiDexEnabled true
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
@ -110,37 +110,36 @@ play {
|
||||
}
|
||||
|
||||
ext {
|
||||
work_manager = "2.2.0"
|
||||
room = "2.2.0-rc01"
|
||||
dagger = "2.24"
|
||||
work_manager = "2.3.0-beta01"
|
||||
room = "2.2.2"
|
||||
dagger = "2.25.2"
|
||||
chucker = "2.0.4"
|
||||
mockk = "1.9.2"
|
||||
}
|
||||
|
||||
configurations.all {
|
||||
resolutionStrategy.force "androidx.constraintlayout:constraintlayout:1.1.3"
|
||||
resolutionStrategy.force "com.google.android.material:material:1.1.0-alpha07"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "io.github.wulkanowy:api:0.11.0"
|
||||
implementation "io.github.wulkanowy:api:0.13.0"
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
implementation "androidx.core:core-ktx:1.1.0"
|
||||
implementation "androidx.activity:activity-ktx:1.0.0"
|
||||
implementation "androidx.core:core-ktx:1.2.0-rc01"
|
||||
implementation "androidx.activity:activity-ktx:1.1.0-rc03"
|
||||
implementation "androidx.appcompat:appcompat:1.1.0"
|
||||
implementation "androidx.appcompat:appcompat-resources:1.1.0"
|
||||
implementation "androidx.fragment:fragment-ktx:1.1.0"
|
||||
implementation "androidx.fragment:fragment-ktx:1.2.0-rc03"
|
||||
implementation "androidx.annotation:annotation:1.1.0"
|
||||
implementation "androidx.multidex:multidex:2.0.1"
|
||||
|
||||
implementation "androidx.preference:preference-ktx:1.1.0"
|
||||
implementation "androidx.recyclerview:recyclerview:1.1.0-beta04"
|
||||
implementation "androidx.recyclerview:recyclerview:1.1.0"
|
||||
implementation "androidx.viewpager:viewpager:1.0.0"
|
||||
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
|
||||
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-alpha03"
|
||||
implementation "androidx.constraintlayout:constraintlayout:1.1.3"
|
||||
implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0-beta01"
|
||||
implementation "com.google.android.material:material:1.1.0-alpha07"
|
||||
implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0"
|
||||
implementation "com.google.android.material:material:1.1.0-beta02"
|
||||
implementation "com.github.wulkanowy:material-chips-input:2.0.1"
|
||||
implementation "com.github.PhilJay:MPAndroidChart:v3.1.0"
|
||||
implementation "me.zhanghai.android.materialprogressbar:library:1.6.1"
|
||||
@ -157,26 +156,28 @@ dependencies {
|
||||
implementation "com.google.dagger:dagger-android-support:$dagger"
|
||||
kapt "com.google.dagger:dagger-compiler:$dagger"
|
||||
kapt "com.google.dagger:dagger-android-processor:$dagger"
|
||||
implementation "com.squareup.inject:assisted-inject-annotations-dagger2:0.5.0"
|
||||
kapt "com.squareup.inject:assisted-inject-processor-dagger2:0.5.0"
|
||||
implementation "com.squareup.inject:assisted-inject-annotations-dagger2:0.5.2"
|
||||
kapt "com.squareup.inject:assisted-inject-processor-dagger2:0.5.2"
|
||||
|
||||
implementation "eu.davidea:flexible-adapter:5.1.0"
|
||||
implementation "eu.davidea:flexible-adapter-ui:1.0.0"
|
||||
implementation "com.aurelhubert:ahbottomnavigation:2.3.4"
|
||||
implementation "com.ncapdevi:frag-nav:3.3.0"
|
||||
implementation "com.github.YarikSOffice:lingver:1.1.0"
|
||||
|
||||
implementation "com.github.pwittchen:reactivenetwork-rx2:3.0.6"
|
||||
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
|
||||
implementation "io.reactivex.rxjava2:rxjava:2.2.13"
|
||||
implementation "io.reactivex.rxjava2:rxjava:2.2.15"
|
||||
|
||||
implementation "com.google.code.gson:gson:2.8.6"
|
||||
implementation "com.jakewharton.threetenabp:threetenabp:1.2.1"
|
||||
implementation "com.jakewharton.timber:timber:4.7.1"
|
||||
implementation "at.favre.lib:slf4j-timber:1.0.1"
|
||||
implementation "com.squareup.okhttp3:logging-interceptor:3.12.6"
|
||||
implementation "com.mikepenz:aboutlibraries:7.0.3"
|
||||
implementation "com.mikepenz:aboutlibraries:7.0.4"
|
||||
implementation 'com.wdullaer:materialdatetimepicker:4.2.3'
|
||||
|
||||
playImplementation "com.google.firebase:firebase-core:17.2.0"
|
||||
playImplementation "com.google.firebase:firebase-core:17.2.1"
|
||||
playImplementation "com.crashlytics.sdk.android:crashlytics:2.10.1"
|
||||
|
||||
releaseImplementation "fr.o80.chucker:library-no-op:$chucker"
|
||||
@ -187,7 +188,7 @@ dependencies {
|
||||
testImplementation "junit:junit:4.12"
|
||||
testImplementation "io.mockk:mockk:$mockk"
|
||||
testImplementation "org.threeten:threetenbp:1.4.0"
|
||||
testImplementation "org.mockito:mockito-inline:3.1.0"
|
||||
testImplementation "org.mockito:mockito-inline:3.2.0"
|
||||
|
||||
androidTestImplementation "androidx.test:core:1.2.0"
|
||||
androidTestImplementation "androidx.test:runner:1.2.0"
|
||||
@ -195,7 +196,7 @@ dependencies {
|
||||
androidTestImplementation "io.mockk:mockk-android:$mockk"
|
||||
androidTestImplementation "androidx.room:room-testing:$room"
|
||||
androidTestImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
|
||||
androidTestImplementation "org.mockito:mockito-android:3.1.0"
|
||||
androidTestImplementation "org.mockito:mockito-android:3.2.0"
|
||||
}
|
||||
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
|
1592
app/schemas/io.github.wulkanowy.data.db.AppDatabase/18.json
Normal file
1592
app/schemas/io.github.wulkanowy.data.db.AppDatabase/18.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,3 +0,0 @@
|
||||
<resources>
|
||||
<string name="app_name">Wulkanowy DEV</string>
|
||||
</resources>
|
@ -6,10 +6,13 @@ import android.util.Log.VERBOSE
|
||||
import androidx.multidex.MultiDex
|
||||
import androidx.work.Configuration
|
||||
import com.jakewharton.threetenabp.AndroidThreeTen
|
||||
import com.yariksoffice.lingver.Lingver
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.support.DaggerApplication
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.utils.Log
|
||||
import io.github.wulkanowy.data.db.SharedPrefProvider
|
||||
import io.github.wulkanowy.data.db.SharedPrefProvider.Companion.APP_VERSION_CODE_KEY
|
||||
import io.github.wulkanowy.di.DaggerAppComponent
|
||||
import io.github.wulkanowy.services.sync.SyncWorkerFactory
|
||||
import io.github.wulkanowy.ui.base.ThemeManager
|
||||
@ -32,6 +35,9 @@ class WulkanowyApp : DaggerApplication(), Configuration.Provider {
|
||||
@Inject
|
||||
lateinit var themeManager: ThemeManager
|
||||
|
||||
@Inject
|
||||
lateinit var sharedPrefProvider: SharedPrefProvider
|
||||
|
||||
@Inject
|
||||
lateinit var appInfo: AppInfo
|
||||
|
||||
@ -44,7 +50,9 @@ class WulkanowyApp : DaggerApplication(), Configuration.Provider {
|
||||
super.onCreate()
|
||||
AndroidThreeTen.init(this)
|
||||
RxJavaPlugins.setErrorHandler(::onError)
|
||||
Lingver.init(this)
|
||||
themeManager.applyDefaultTheme()
|
||||
migrateSharedPreferences()
|
||||
|
||||
initLogging()
|
||||
initCrashlytics(this, appInfo)
|
||||
@ -60,6 +68,13 @@ class WulkanowyApp : DaggerApplication(), Configuration.Provider {
|
||||
registerActivityLifecycleCallbacks(ActivityLifecycleLogger())
|
||||
}
|
||||
|
||||
private fun migrateSharedPreferences() {
|
||||
if (sharedPrefProvider.getLong(APP_VERSION_CODE_KEY, -1) < 48) { // #596
|
||||
sharedPrefProvider.delete(getString(R.string.pref_key_grade_modifier_plus))
|
||||
sharedPrefProvider.delete(getString(R.string.pref_key_grade_modifier_minus))
|
||||
}
|
||||
}
|
||||
|
||||
private fun onError(error: Throwable) {
|
||||
//RxJava's too deep stack traces may cause SOE on older android devices
|
||||
val cause = error.cause
|
||||
|
@ -144,4 +144,8 @@ internal class RepositoryModule {
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideTeacherDao(database: AppDatabase) = database.teacherDao
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideSchoolInfoDao(database: AppDatabase) = database.schoolDao
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ import io.github.wulkanowy.data.db.dao.MobileDeviceDao
|
||||
import io.github.wulkanowy.data.db.dao.NoteDao
|
||||
import io.github.wulkanowy.data.db.dao.RecipientDao
|
||||
import io.github.wulkanowy.data.db.dao.ReportingUnitDao
|
||||
import io.github.wulkanowy.data.db.dao.SchoolDao
|
||||
import io.github.wulkanowy.data.db.dao.SemesterDao
|
||||
import io.github.wulkanowy.data.db.dao.StudentDao
|
||||
import io.github.wulkanowy.data.db.dao.SubjectDao
|
||||
@ -42,6 +43,7 @@ import io.github.wulkanowy.data.db.entities.MobileDevice
|
||||
import io.github.wulkanowy.data.db.entities.Note
|
||||
import io.github.wulkanowy.data.db.entities.Recipient
|
||||
import io.github.wulkanowy.data.db.entities.ReportingUnit
|
||||
import io.github.wulkanowy.data.db.entities.School
|
||||
import io.github.wulkanowy.data.db.entities.Semester
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.data.db.entities.Subject
|
||||
@ -55,6 +57,7 @@ import io.github.wulkanowy.data.db.migrations.Migration14
|
||||
import io.github.wulkanowy.data.db.migrations.Migration15
|
||||
import io.github.wulkanowy.data.db.migrations.Migration16
|
||||
import io.github.wulkanowy.data.db.migrations.Migration17
|
||||
import io.github.wulkanowy.data.db.migrations.Migration18
|
||||
import io.github.wulkanowy.data.db.migrations.Migration2
|
||||
import io.github.wulkanowy.data.db.migrations.Migration3
|
||||
import io.github.wulkanowy.data.db.migrations.Migration4
|
||||
@ -87,7 +90,8 @@ import javax.inject.Singleton
|
||||
ReportingUnit::class,
|
||||
Recipient::class,
|
||||
MobileDevice::class,
|
||||
Teacher::class
|
||||
Teacher::class,
|
||||
School::class
|
||||
],
|
||||
version = AppDatabase.VERSION_SCHEMA,
|
||||
exportSchema = true
|
||||
@ -96,7 +100,7 @@ import javax.inject.Singleton
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
companion object {
|
||||
const val VERSION_SCHEMA = 17
|
||||
const val VERSION_SCHEMA = 18
|
||||
|
||||
fun getMigrations(): Array<Migration> {
|
||||
return arrayOf(
|
||||
@ -115,7 +119,8 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
Migration14(),
|
||||
Migration15(),
|
||||
Migration16(),
|
||||
Migration17()
|
||||
Migration17(),
|
||||
Migration18()
|
||||
)
|
||||
}
|
||||
|
||||
@ -168,4 +173,6 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
abstract val mobileDeviceDao: MobileDeviceDao
|
||||
|
||||
abstract val teacherDao: TeacherDao
|
||||
|
||||
abstract val schoolDao: SchoolDao
|
||||
}
|
||||
|
@ -8,6 +8,10 @@ import javax.inject.Singleton
|
||||
@Singleton
|
||||
class SharedPrefProvider @Inject constructor(private val sharedPref: SharedPreferences) {
|
||||
|
||||
companion object {
|
||||
const val APP_VERSION_CODE_KEY = "app_version_code"
|
||||
}
|
||||
|
||||
fun putLong(key: String, value: Long, sync: Boolean = false) {
|
||||
sharedPref.edit(sync) { putLong(key, value) }
|
||||
}
|
||||
|
@ -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<Attendance>): List<Long>
|
||||
|
||||
@Delete
|
||||
fun deleteAll(exams: List<Attendance>)
|
||||
interface AttendanceDao : BaseDao<Attendance> {
|
||||
|
||||
@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<List<Attendance>>
|
||||
|
@ -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<AttendanceSummary>): List<Long>
|
||||
|
||||
@Delete
|
||||
fun deleteAll(exams: List<AttendanceSummary>)
|
||||
interface AttendanceSummaryDao : BaseDao<AttendanceSummary> {
|
||||
|
||||
@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<List<AttendanceSummary>>
|
||||
|
17
app/src/main/java/io/github/wulkanowy/data/db/dao/BaseDao.kt
Normal file
17
app/src/main/java/io/github/wulkanowy/data/db/dao/BaseDao.kt
Normal file
@ -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<T> {
|
||||
|
||||
@Insert
|
||||
fun insertAll(items: List<T>): List<Long>
|
||||
|
||||
@Update
|
||||
fun updateAll(items: List<T>)
|
||||
|
||||
@Delete
|
||||
fun deleteAll(items: List<T>)
|
||||
}
|
@ -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<CompletedLesson>)
|
||||
|
||||
@Delete
|
||||
fun deleteAll(exams: List<CompletedLesson>)
|
||||
interface CompletedLessonsDao : BaseDao<CompletedLesson> {
|
||||
|
||||
@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<List<CompletedLesson>>
|
||||
|
@ -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<Exam>): List<Long>
|
||||
|
||||
@Delete
|
||||
fun deleteAll(exams: List<Exam>)
|
||||
interface ExamDao : BaseDao<Exam> {
|
||||
|
||||
@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<List<Exam>>
|
||||
|
@ -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<Grade>)
|
||||
|
||||
@Update
|
||||
fun updateAll(grade: List<Grade>)
|
||||
|
||||
@Delete
|
||||
fun deleteAll(grades: List<Grade>)
|
||||
interface GradeDao : BaseDao<Grade> {
|
||||
|
||||
@Query("SELECT * FROM Grades WHERE semester_id = :semesterId AND student_id = :studentId")
|
||||
fun loadAll(semesterId: Int, studentId: Int): Maybe<List<Grade>>
|
||||
|
@ -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<GradePointsStatistics>)
|
||||
|
||||
@Delete
|
||||
fun deleteAll(gradesStatistics: List<GradePointsStatistics>)
|
||||
interface GradePointsStatisticsDao : BaseDao<GradePointsStatistics> {
|
||||
|
||||
@Query("SELECT * FROM GradesPointsStatistics WHERE student_id = :studentId AND semester_id = :semesterId AND subject = :subjectName")
|
||||
fun loadSubject(semesterId: Int, studentId: Int, subjectName: String): Maybe<GradePointsStatistics>
|
||||
|
@ -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<GradeStatistics>)
|
||||
|
||||
@Delete
|
||||
fun deleteAll(gradesStatistics: List<GradeStatistics>)
|
||||
interface GradeStatisticsDao : BaseDao<GradeStatistics> {
|
||||
|
||||
@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<List<GradeStatistics>>
|
||||
|
@ -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<GradeSummary>)
|
||||
|
||||
@Delete
|
||||
fun deleteAll(gradesSummary: List<GradeSummary>)
|
||||
interface GradeSummaryDao : BaseDao<GradeSummary> {
|
||||
|
||||
@Query("SELECT * FROM GradesSummary WHERE student_id = :studentId AND semester_id = :semesterId")
|
||||
fun loadAll(semesterId: Int, studentId: Int): Maybe<List<GradeSummary>>
|
||||
|
@ -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<Homework>)
|
||||
|
||||
@Delete
|
||||
fun deleteAll(homework: List<Homework>)
|
||||
interface HomeworkDao : BaseDao<Homework> {
|
||||
|
||||
@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<List<Homework>>
|
||||
|
@ -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<LuckyNumber> {
|
||||
|
||||
@Query("SELECT * FROM LuckyNumbers WHERE student_id = :studentId AND date = :date")
|
||||
fun load(studentId: Int, date: LocalDate): Maybe<LuckyNumber>
|
||||
|
||||
}
|
||||
|
@ -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<Message>)
|
||||
|
||||
@Delete
|
||||
fun deleteAll(messages: List<Message>)
|
||||
|
||||
@Update
|
||||
fun updateAll(messages: List<Message>)
|
||||
interface MessagesDao : BaseDao<Message> {
|
||||
|
||||
@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<List<Message>>
|
||||
|
@ -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<MobileDevice>)
|
||||
|
||||
@Delete
|
||||
fun deleteAll(devices: List<MobileDevice>)
|
||||
interface MobileDeviceDao : BaseDao<MobileDevice> {
|
||||
|
||||
@Query("SELECT * FROM MobileDevices WHERE student_id = :studentId ORDER BY date DESC")
|
||||
fun loadAll(studentId: Int): Maybe<List<MobileDevice>>
|
||||
|
@ -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<Note>)
|
||||
|
||||
@Update
|
||||
fun updateAll(notes: List<Note>)
|
||||
|
||||
@Delete
|
||||
fun deleteAll(notes: List<Note>)
|
||||
interface NoteDao : BaseDao<Note> {
|
||||
|
||||
@Query("SELECT * FROM Notes WHERE student_id = :studentId")
|
||||
fun loadAll(studentId: Int): Maybe<List<Note>>
|
||||
|
||||
}
|
||||
|
@ -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<Recipient>)
|
||||
|
||||
@Delete
|
||||
fun deleteAll(messages: List<Recipient>)
|
||||
interface RecipientDao : BaseDao<Recipient> {
|
||||
|
||||
@Query("SELECT * FROM Recipients WHERE student_id = :studentId AND role = :role AND unit_id = :unitId")
|
||||
fun load(studentId: Int, role: Int, unitId: Int): Maybe<List<Recipient>>
|
||||
|
@ -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<ReportingUnit>)
|
||||
|
||||
@Delete
|
||||
fun deleteAll(reportingUnits: List<ReportingUnit>)
|
||||
interface ReportingUnitDao : BaseDao<ReportingUnit> {
|
||||
|
||||
@Query("SELECT * FROM ReportingUnits WHERE student_id = :studentId")
|
||||
fun load(studentId: Int): Maybe<List<ReportingUnit>>
|
||||
|
@ -0,0 +1,15 @@
|
||||
package io.github.wulkanowy.data.db.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
import io.github.wulkanowy.data.db.entities.School
|
||||
import io.reactivex.Maybe
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
@Dao
|
||||
interface SchoolDao : BaseDao<School> {
|
||||
|
||||
@Query("SELECT * FROM School WHERE student_id = :studentId AND class_id = :classId")
|
||||
fun load(studentId: Int, classId: Int): Maybe<School>
|
||||
}
|
@ -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<Semester>)
|
||||
|
||||
@Delete
|
||||
fun deleteAll(semester: List<Semester>)
|
||||
interface SemesterDao : BaseDao<Semester> {
|
||||
|
||||
@Query("SELECT * FROM Semesters WHERE student_id = :studentId AND class_id = :classId")
|
||||
fun loadAll(studentId: Int, classId: Int): Maybe<List<Semester>>
|
||||
|
@ -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<Subject>): List<Long>
|
||||
|
||||
@Delete
|
||||
fun deleteAll(subjects: List<Subject>)
|
||||
interface SubjectDao : BaseDao<Subject> {
|
||||
|
||||
@Query("SELECT * FROM Subjects WHERE diary_id = :diaryId AND student_id = :studentId")
|
||||
fun loadAll(diaryId: Int, studentId: Int): Maybe<List<Subject>>
|
||||
|
@ -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(devices: List<Teacher>)
|
||||
|
||||
@Delete
|
||||
fun deleteAll(devices: List<Teacher>)
|
||||
interface TeacherDao : BaseDao<Teacher> {
|
||||
|
||||
@Query("SELECT * FROM Teachers WHERE student_id = :studentId AND class_id = :classId")
|
||||
fun loadAll(studentId: Int, classId: Int): Maybe<List<Teacher>>
|
||||
|
@ -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<Timetable>): List<Long>
|
||||
|
||||
@Delete
|
||||
fun deleteAll(exams: List<Timetable>)
|
||||
interface TimetableDao : BaseDao<Timetable> {
|
||||
|
||||
@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<List<Timetable>>
|
||||
|
@ -0,0 +1,30 @@
|
||||
package io.github.wulkanowy.data.db.entities
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import java.io.Serializable
|
||||
|
||||
@Entity(tableName = "School")
|
||||
data class School(
|
||||
|
||||
@ColumnInfo(name = "student_id")
|
||||
val studentId: Int,
|
||||
|
||||
@ColumnInfo(name = "class_id")
|
||||
val classId: Int,
|
||||
|
||||
val name: String,
|
||||
|
||||
val address: String,
|
||||
|
||||
val contact: String,
|
||||
|
||||
val headmaster: String,
|
||||
|
||||
val pedagogue: String
|
||||
) : Serializable {
|
||||
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
var id: Long = 0
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package io.github.wulkanowy.data.db.migrations
|
||||
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
|
||||
class Migration18 : Migration(17, 18) {
|
||||
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("""
|
||||
CREATE TABLE IF NOT EXISTS School (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
student_id INTEGER NOT NULL,
|
||||
class_id INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
address TEXT NOT NULL,
|
||||
contact TEXT NOT NULL,
|
||||
headmaster TEXT NOT NULL,
|
||||
pedagogue TEXT NOT NULL
|
||||
)
|
||||
""")
|
||||
}
|
||||
}
|
@ -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<LuckyNumber> {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -12,52 +12,64 @@ class PreferencesRepository @Inject constructor(
|
||||
val context: Context
|
||||
) {
|
||||
val startMenuIndex: Int
|
||||
get() = sharedPref.getString(context.getString(R.string.pref_key_start_menu), "0")?.toIntOrNull() ?: 0
|
||||
get() = getString(R.string.pref_key_start_menu, R.string.pref_default_startup).toInt()
|
||||
|
||||
val isShowPresent: Boolean
|
||||
get() = sharedPref.getBoolean(context.getString(R.string.pref_key_attendance_present), true)
|
||||
get() = getBoolean(R.string.pref_key_attendance_present, R.bool.pref_default_attendance_present)
|
||||
|
||||
val gradeAverageMode: String
|
||||
get() = sharedPref.getString(context.getString(R.string.pref_key_grade_average_mode), "only_one_semester") ?: "only_one_semester"
|
||||
get() = getString(R.string.pref_key_grade_average_mode, R.string.pref_default_grade_average_mode)
|
||||
|
||||
val gradeAverageForceCalc: Boolean
|
||||
get() = sharedPref.getBoolean(context.getString(R.string.pref_key_grade_average_force_calc), false)
|
||||
get() = getBoolean(R.string.pref_key_grade_average_force_calc, R.bool.pref_default_grade_average_force_calc)
|
||||
|
||||
val isGradeExpandable: Boolean
|
||||
get() = !sharedPref.getBoolean(context.getString(R.string.pref_key_expand_grade), false)
|
||||
get() = !getBoolean(R.string.pref_key_expand_grade, R.bool.pref_default_expand_grade)
|
||||
|
||||
val appThemeKey: String = context.getString(R.string.pref_key_app_theme)
|
||||
val appThemeKey = context.getString(R.string.pref_key_app_theme)
|
||||
val appTheme: String
|
||||
get() = sharedPref.getString(appThemeKey, "light") ?: "light"
|
||||
get() = getString(appThemeKey, R.string.pref_default_app_theme)
|
||||
|
||||
val gradeColorTheme: String
|
||||
get() = sharedPref.getString(context.getString(R.string.pref_key_grade_color_scheme), "vulcan") ?: "vulcan"
|
||||
get() = getString(R.string.pref_key_grade_color_scheme, R.string.pref_default_grade_color_scheme)
|
||||
|
||||
val serviceEnableKey: String = context.getString(R.string.pref_key_services_enable)
|
||||
val appLanguageKey = context.getString(R.string.pref_key_app_language)
|
||||
val appLanguage
|
||||
get() = getString(appLanguageKey, R.string.pref_default_app_language)
|
||||
|
||||
val serviceEnableKey = context.getString(R.string.pref_key_services_enable)
|
||||
val isServiceEnabled: Boolean
|
||||
get() = sharedPref.getBoolean(serviceEnableKey, true)
|
||||
get() = getBoolean(serviceEnableKey, R.bool.pref_default_services_enable)
|
||||
|
||||
val servicesIntervalKey: String = context.getString(R.string.pref_key_services_interval)
|
||||
val servicesIntervalKey = context.getString(R.string.pref_key_services_interval)
|
||||
val servicesInterval: Long
|
||||
get() = sharedPref.getString(servicesIntervalKey, "60")?.toLongOrNull() ?: 60
|
||||
get() = getString(servicesIntervalKey, R.string.pref_default_services_interval).toLong()
|
||||
|
||||
val servicesOnlyWifiKey: String = context.getString(R.string.pref_key_services_wifi_only)
|
||||
val servicesOnlyWifiKey = context.getString(R.string.pref_key_services_wifi_only)
|
||||
val isServicesOnlyWifi: Boolean
|
||||
get() = sharedPref.getBoolean(servicesOnlyWifiKey, false)
|
||||
get() = getBoolean(servicesOnlyWifiKey, R.bool.pref_default_services_wifi_only)
|
||||
|
||||
val isNotificationsEnable: Boolean
|
||||
get() = sharedPref.getBoolean(context.getString(R.string.pref_key_notifications_enable), true)
|
||||
get() = getBoolean(R.string.pref_key_notifications_enable, R.bool.pref_default_notifications_enable)
|
||||
|
||||
val isDebugNotificationEnableKey: String = context.getString(R.string.pref_key_notification_debug)
|
||||
val isDebugNotificationEnableKey = context.getString(R.string.pref_key_notification_debug)
|
||||
val isDebugNotificationEnable: Boolean
|
||||
get() = sharedPref.getBoolean(isDebugNotificationEnableKey, false)
|
||||
get() = getBoolean(isDebugNotificationEnableKey, R.bool.pref_default_notification_debug)
|
||||
|
||||
val gradePlusModifier: Double
|
||||
get() = sharedPref.getString(context.getString(R.string.pref_key_grade_modifier_plus), "0.0")?.toDouble() ?: 0.0
|
||||
get() = getString(R.string.pref_key_grade_modifier_plus, R.string.pref_default_grade_modifier_plus).toDouble()
|
||||
|
||||
val gradeMinusModifier: Double
|
||||
get() = sharedPref.getString(context.getString(R.string.pref_key_grade_modifier_minus), "0.0")?.toDouble() ?: 0.0
|
||||
get() = getString(R.string.pref_key_grade_modifier_minus, R.string.pref_default_grade_modifier_minus).toDouble()
|
||||
|
||||
val fillMessageContent: Boolean
|
||||
get() = sharedPref.getBoolean(context.getString(R.string.pref_key_fill_message_content), true)
|
||||
get() = getBoolean(R.string.pref_key_fill_message_content, R.bool.pref_default_fill_message_content)
|
||||
|
||||
private fun getString(id: Int, default: Int) = getString(context.getString(id), default)
|
||||
|
||||
private fun getString(id: String, default: Int) = sharedPref.getString(id, context.getString(default)) ?: context.getString(default)
|
||||
|
||||
private fun getBoolean(id: Int, default: Int) = getBoolean(context.getString(id), default)
|
||||
|
||||
private fun getBoolean(id: String, default: Int) = sharedPref.getBoolean(id, context.resources.getBoolean(default))
|
||||
}
|
||||
|
@ -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<Recipient>) {
|
||||
fun saveRecipients(recipients: List<Recipient>): List<Long> {
|
||||
return recipientDb.insertAll(recipients)
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ class ReportingUnitLocal @Inject constructor(private val reportingUnitDb: Report
|
||||
return reportingUnitDb.loadOne(student.studentId, unitId)
|
||||
}
|
||||
|
||||
fun saveReportingUnits(reportingUnits: List<ReportingUnit>) {
|
||||
fun saveReportingUnits(reportingUnits: List<ReportingUnit>): List<Long> {
|
||||
return reportingUnitDb.insertAll(reportingUnits)
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
package io.github.wulkanowy.data.repositories.school
|
||||
|
||||
import io.github.wulkanowy.data.db.dao.SchoolDao
|
||||
import io.github.wulkanowy.data.db.entities.School
|
||||
import io.github.wulkanowy.data.db.entities.Semester
|
||||
import io.reactivex.Maybe
|
||||
import javax.inject.Inject
|
||||
|
||||
class SchoolLocal @Inject constructor(private val schoolDb: SchoolDao) {
|
||||
|
||||
fun saveSchool(school: School) {
|
||||
schoolDb.insertAll(listOf(school))
|
||||
}
|
||||
|
||||
fun deleteSchool(school: School) {
|
||||
schoolDb.deleteAll(listOf(school))
|
||||
}
|
||||
|
||||
fun getSchool(semester: Semester): Maybe<School> {
|
||||
return schoolDb.load(semester.studentId, semester.classId)
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package io.github.wulkanowy.data.repositories.school
|
||||
|
||||
import io.github.wulkanowy.api.Api
|
||||
import io.github.wulkanowy.data.db.entities.School
|
||||
import io.github.wulkanowy.data.db.entities.Semester
|
||||
import io.reactivex.Single
|
||||
import javax.inject.Inject
|
||||
|
||||
class SchoolRemote @Inject constructor(private val api: Api) {
|
||||
|
||||
fun getSchoolInfo(semester: Semester): Single<School> {
|
||||
return Single.just(api.apply { diaryId = semester.diaryId })
|
||||
.flatMap { it.getSchool() }
|
||||
.map {
|
||||
School(
|
||||
studentId = semester.studentId,
|
||||
classId = semester.classId,
|
||||
name = it.name,
|
||||
address = it.address,
|
||||
contact = it.contact,
|
||||
headmaster = it.headmaster,
|
||||
pedagogue = it.pedagogue
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package io.github.wulkanowy.data.repositories.school
|
||||
|
||||
import com.github.pwittchen.reactivenetwork.library.rx2.ReactiveNetwork
|
||||
import com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.InternetObservingSettings
|
||||
import io.github.wulkanowy.data.db.entities.School
|
||||
import io.github.wulkanowy.data.db.entities.Semester
|
||||
import io.reactivex.Maybe
|
||||
import io.reactivex.Single
|
||||
import java.net.UnknownHostException
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class SchoolRepository @Inject constructor(
|
||||
private val settings: InternetObservingSettings,
|
||||
private val local: SchoolLocal,
|
||||
private val remote: SchoolRemote
|
||||
) {
|
||||
|
||||
fun getSchoolInfo(semester: Semester, forceRefresh: Boolean = false): Maybe<School> {
|
||||
return local.getSchool(semester).filter { !forceRefresh }
|
||||
.switchIfEmpty(ReactiveNetwork.checkInternetConnectivity(settings)
|
||||
.flatMap {
|
||||
if (it) remote.getSchoolInfo(semester)
|
||||
else Single.error(UnknownHostException())
|
||||
}.flatMapMaybe { new ->
|
||||
local.getSchool(semester)
|
||||
.doOnSuccess { old ->
|
||||
if (new != old) {
|
||||
local.deleteSchool(old)
|
||||
local.saveSchool(new)
|
||||
}
|
||||
}
|
||||
.doOnComplete {
|
||||
local.saveSchool(new)
|
||||
}
|
||||
}.flatMap({ local.getSchool(semester) }, { Maybe.error(it) },
|
||||
{ local.getSchool(semester) })
|
||||
)
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ class StudentLocal @Inject constructor(
|
||||
fun getStudents(decryptPass: Boolean): Maybe<List<Student>> {
|
||||
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<Student> {
|
||||
|
@ -6,7 +6,8 @@ import io.github.wulkanowy.data.db.entities.Teacher
|
||||
import io.reactivex.Maybe
|
||||
import javax.inject.Inject
|
||||
|
||||
class TeacherLocal @Inject constructor(private val teacherDb: TeacherDao) {
|
||||
class TeacherLocal @Inject constructor(private val teacherDb: TeacherDao) {
|
||||
|
||||
fun saveTeachers(teachers: List<Teacher>) {
|
||||
teacherDb.insertAll(teachers)
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ class TeacherRepository @Inject constructor(
|
||||
private val local: TeacherLocal,
|
||||
private val remote: TeacherRemote
|
||||
) {
|
||||
|
||||
fun getTeachers(semester: Semester, forceRefresh: Boolean = false): Single<List<Teacher>> {
|
||||
return local.getTeachers(semester).filter { !forceRefresh }
|
||||
.switchIfEmpty(ReactiveNetwork.checkInternetConnectivity(settings)
|
||||
|
@ -2,6 +2,7 @@ package io.github.wulkanowy.di
|
||||
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.content.Context
|
||||
import com.yariksoffice.lingver.Lingver
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
@ -32,4 +33,8 @@ internal class AppModule {
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideAppInfo() = AppInfo()
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideLingver() = Lingver.getInstance()
|
||||
}
|
||||
|
@ -29,17 +29,15 @@ import javax.inject.Singleton
|
||||
|
||||
@Suppress("unused")
|
||||
@AssistedModule
|
||||
@Module(includes = [AssistedInject_ServicesModule::class])
|
||||
@Module(includes = [AssistedInject_ServicesModule::class, ServicesModule.Static::class])
|
||||
abstract class ServicesModule {
|
||||
|
||||
@Module
|
||||
companion object {
|
||||
object Static {
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
fun provideWorkManager(context: Context) = WorkManager.getInstance(context)
|
||||
|
||||
@JvmStatic
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideNotificationManager(context: Context) = NotificationManagerCompat.from(context)
|
||||
|
@ -11,6 +11,7 @@ import androidx.work.NetworkType.UNMETERED
|
||||
import androidx.work.PeriodicWorkRequestBuilder
|
||||
import androidx.work.WorkManager
|
||||
import io.github.wulkanowy.data.db.SharedPrefProvider
|
||||
import io.github.wulkanowy.data.db.SharedPrefProvider.Companion.APP_VERSION_CODE_KEY
|
||||
import io.github.wulkanowy.data.repositories.preferences.PreferencesRepository
|
||||
import io.github.wulkanowy.services.sync.channels.DebugChannel
|
||||
import io.github.wulkanowy.services.sync.channels.NewEntriesChannel
|
||||
@ -32,10 +33,6 @@ class SyncManager @Inject constructor(
|
||||
appInfo: AppInfo
|
||||
) {
|
||||
|
||||
companion object {
|
||||
private const val APP_VERSION_CODE_KEY = "app_version_code"
|
||||
}
|
||||
|
||||
init {
|
||||
if (now().isHolidays) stopSyncWorker()
|
||||
|
||||
|
@ -22,7 +22,8 @@ import io.github.wulkanowy.utils.FragmentLifecycleLogger
|
||||
import io.github.wulkanowy.utils.getThemeAttrColor
|
||||
import javax.inject.Inject
|
||||
|
||||
abstract class BaseActivity<T : BasePresenter<out BaseView>> : AppCompatActivity(), BaseView, HasAndroidInjector {
|
||||
abstract class BaseActivity<T : BasePresenter<out BaseView>> : AppCompatActivity(), BaseView,
|
||||
HasAndroidInjector {
|
||||
|
||||
@Inject
|
||||
lateinit var androidInjector: DispatchingAndroidInjector<Any>
|
||||
@ -53,13 +54,15 @@ abstract class BaseActivity<T : BasePresenter<out BaseView>> : AppCompatActivity
|
||||
override fun showError(text: String, error: Throwable) {
|
||||
if (messageContainer != null) {
|
||||
Snackbar.make(messageContainer!!, text, LENGTH_LONG)
|
||||
.setAction(R.string.all_details) {
|
||||
ErrorDialog.newInstance(error).show(supportFragmentManager, error.toString())
|
||||
}
|
||||
.setAction(R.string.all_details) { showErrorDetailsDialog(error) }
|
||||
.show()
|
||||
} else showMessage(text)
|
||||
}
|
||||
|
||||
override fun showErrorDetailsDialog(error: Throwable) {
|
||||
ErrorDialog.newInstance(error).show(supportFragmentManager, error.toString())
|
||||
}
|
||||
|
||||
override fun showMessage(text: String) {
|
||||
if (messageContainer != null) Snackbar.make(messageContainer!!, text, LENGTH_LONG).show()
|
||||
else Toast.makeText(this, text, Toast.LENGTH_LONG).show()
|
||||
|
@ -0,0 +1,27 @@
|
||||
package io.github.wulkanowy.ui.base
|
||||
|
||||
import android.widget.Toast
|
||||
import dagger.android.support.DaggerAppCompatDialogFragment
|
||||
|
||||
abstract class BaseDialogFragment : DaggerAppCompatDialogFragment(), BaseView {
|
||||
|
||||
override fun showError(text: String, error: Throwable) {
|
||||
showMessage(text)
|
||||
}
|
||||
|
||||
override fun showMessage(text: String) {
|
||||
Toast.makeText(context, text, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
override fun showExpiredDialog() {
|
||||
(activity as? BaseActivity<*>)?.showExpiredDialog()
|
||||
}
|
||||
|
||||
override fun openClearLoginView() {
|
||||
(activity as? BaseActivity<*>)?.openClearLoginView()
|
||||
}
|
||||
|
||||
override fun showErrorDetailsDialog(error: Throwable) {
|
||||
ErrorDialog.newInstance(error).show(childFragmentManager, error.toString())
|
||||
}
|
||||
}
|
@ -13,15 +13,17 @@ abstract class BaseFragment : DaggerFragment(), BaseView {
|
||||
override fun showError(text: String, error: Throwable) {
|
||||
if (messageContainer != null) {
|
||||
Snackbar.make(messageContainer!!, text, LENGTH_LONG)
|
||||
.setAction(R.string.all_details) {
|
||||
if (isAdded) ErrorDialog.newInstance(error).show(childFragmentManager, error.toString())
|
||||
}
|
||||
.setAction(R.string.all_details) { if (isAdded) showErrorDetailsDialog(error) }
|
||||
.show()
|
||||
} else {
|
||||
(activity as? BaseActivity<*>)?.showError(text, error)
|
||||
}
|
||||
}
|
||||
|
||||
override fun showErrorDetailsDialog(error: Throwable) {
|
||||
ErrorDialog.newInstance(error).show(childFragmentManager, error.toString())
|
||||
}
|
||||
|
||||
override fun showMessage(text: String) {
|
||||
if (messageContainer != null) {
|
||||
Snackbar.make(messageContainer!!, text, LENGTH_LONG).show()
|
||||
|
@ -9,4 +9,6 @@ interface BaseView {
|
||||
fun showExpiredDialog()
|
||||
|
||||
fun openClearLoginView()
|
||||
|
||||
fun showErrorDetailsDialog(error: Throwable)
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package io.github.wulkanowy.ui.base
|
||||
import android.content.pm.PackageManager.GET_ACTIVITIES
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO
|
||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
|
||||
import io.github.wulkanowy.R
|
||||
@ -22,8 +23,12 @@ class ThemeManager @Inject constructor(private val preferencesRepository: Prefer
|
||||
|
||||
fun applyDefaultTheme() {
|
||||
AppCompatDelegate.setDefaultNightMode(
|
||||
if (preferencesRepository.appTheme == "light") MODE_NIGHT_NO
|
||||
else MODE_NIGHT_YES
|
||||
when (val theme = preferencesRepository.appTheme) {
|
||||
"light" -> MODE_NIGHT_NO
|
||||
"dark", "black" -> MODE_NIGHT_YES
|
||||
"system" -> MODE_NIGHT_FOLLOW_SYSTEM
|
||||
else -> throw IllegalArgumentException("Wrong theme: $theme")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,11 @@ class AboutFragment : BaseFragment(), AboutView, MainView.TitledView {
|
||||
Triple(getString(R.string.about_feedback), getString(R.string.about_feedback_summary), getCompatDrawable(R.drawable.ic_about_feedback))
|
||||
}
|
||||
|
||||
override val faqRes: Triple<String, String, Drawable?>?
|
||||
get() = context?.run {
|
||||
Triple(getString(R.string.about_faq), getString(R.string.about_faq_summary), getCompatDrawable(R.drawable.ic_about_faq))
|
||||
}
|
||||
|
||||
override val discordRes: Triple<String, String, Drawable?>?
|
||||
get() = context?.run {
|
||||
Triple(getString(R.string.about_discord), getString(R.string.about_discord_summary), getCompatDrawable(R.drawable.ic_about_discord))
|
||||
@ -130,6 +135,10 @@ class AboutFragment : BaseFragment(), AboutView, MainView.TitledView {
|
||||
}
|
||||
}
|
||||
|
||||
override fun openFaqPage() {
|
||||
context?.openInternetBrowser("https://wulkanowy.github.io/czesto-zadawane-pytania", ::showMessage)
|
||||
}
|
||||
|
||||
override fun openLicenses() {
|
||||
(activity as? MainActivity)?.pushView(LicenseFragment.newInstance())
|
||||
}
|
||||
|
@ -28,10 +28,15 @@ class AboutPresenter @Inject constructor(
|
||||
view?.run {
|
||||
when (item.title) {
|
||||
feedbackRes?.first -> {
|
||||
Timber.i("Opening email client ")
|
||||
Timber.i("Opening email client")
|
||||
openEmailClient()
|
||||
analytics.logEvent("about_open", "name" to "feedback")
|
||||
}
|
||||
faqRes?.first -> {
|
||||
Timber.i("Opening faq page")
|
||||
openFaqPage()
|
||||
analytics.logEvent("about_open", "name" to "faq")
|
||||
}
|
||||
discordRes?.first -> {
|
||||
Timber.i("Opening discord")
|
||||
openDiscordInvite()
|
||||
@ -61,6 +66,7 @@ class AboutPresenter @Inject constructor(
|
||||
updateData(AboutScrollableHeader(), listOfNotNull(
|
||||
versionRes?.let { (title, summary, image) -> AboutItem(title, summary, image) },
|
||||
feedbackRes?.let { (title, summary, image) -> AboutItem(title, summary, image) },
|
||||
faqRes?.let { (title, summary, image) -> AboutItem(title, summary, image) },
|
||||
discordRes?.let { (title, summary, image) -> AboutItem(title, summary, image) },
|
||||
homepageRes?.let { (title, summary, image) -> AboutItem(title, summary, image) },
|
||||
licensesRes?.let { (title, summary, image) -> AboutItem(title, summary, image) },
|
||||
|
@ -9,6 +9,8 @@ interface AboutView : BaseView {
|
||||
|
||||
val feedbackRes: Triple<String, String, Drawable?>?
|
||||
|
||||
val faqRes: Triple<String, String, Drawable?>?
|
||||
|
||||
val discordRes: Triple<String, String, Drawable?>?
|
||||
|
||||
val homepageRes: Triple<String, String, Drawable?>?
|
||||
@ -25,6 +27,8 @@ interface AboutView : BaseView {
|
||||
|
||||
fun openEmailClient()
|
||||
|
||||
fun openFaqPage()
|
||||
|
||||
fun openHomepage()
|
||||
|
||||
fun openLicenses()
|
||||
|
@ -7,18 +7,17 @@ import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import android.widget.Toast.LENGTH_LONG
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import dagger.android.support.DaggerAppCompatDialogFragment
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.ui.base.BaseActivity
|
||||
import io.github.wulkanowy.ui.base.BaseDialogFragment
|
||||
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||
import io.github.wulkanowy.utils.setOnItemClickListener
|
||||
import kotlinx.android.synthetic.main.dialog_account.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class AccountDialog : DaggerAppCompatDialogFragment(), AccountView {
|
||||
class AccountDialog : BaseDialogFragment(), AccountView {
|
||||
|
||||
@Inject
|
||||
lateinit var presenter: AccountPresenter
|
||||
@ -77,14 +76,6 @@ class AccountDialog : DaggerAppCompatDialogFragment(), AccountView {
|
||||
}
|
||||
}
|
||||
|
||||
override fun showExpiredDialog() {
|
||||
(activity as? BaseActivity<*>)?.showExpiredDialog()
|
||||
}
|
||||
|
||||
override fun openClearLoginView() {
|
||||
(activity as? BaseActivity<*>)?.openClearLoginView()
|
||||
}
|
||||
|
||||
override fun showConfirmDialog() {
|
||||
context?.let {
|
||||
AlertDialog.Builder(it)
|
||||
@ -105,4 +96,3 @@ class AccountDialog : DaggerAppCompatDialogFragment(), AccountView {
|
||||
super.onDestroy()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,11 @@ import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.View.GONE
|
||||
import android.view.View.INVISIBLE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.ViewGroup
|
||||
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.common.FlexibleItemDecoration
|
||||
import eu.davidea.flexibleadapter.common.SmoothScrollLinearLayoutManager
|
||||
@ -17,9 +21,11 @@ import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.modules.attendance.summary.AttendanceSummaryFragment
|
||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||
import io.github.wulkanowy.ui.modules.main.MainView
|
||||
import io.github.wulkanowy.utils.SchooldaysRangeLimiter
|
||||
import io.github.wulkanowy.utils.dpToPx
|
||||
import io.github.wulkanowy.utils.setOnItemClickListener
|
||||
import kotlinx.android.synthetic.main.fragment_attendance.*
|
||||
import org.threeten.bp.LocalDate
|
||||
import javax.inject.Inject
|
||||
|
||||
class AttendanceFragment : BaseFragment(), AttendanceView, MainView.MainChildView,
|
||||
@ -70,7 +76,11 @@ class AttendanceFragment : BaseFragment(), AttendanceView, MainView.MainChildVie
|
||||
}
|
||||
|
||||
attendanceSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||
attendanceErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||
attendanceErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||
|
||||
attendancePreviousButton.setOnClickListener { presenter.onPreviousDay() }
|
||||
attendanceNavDate.setOnClickListener { presenter.onPickDate() }
|
||||
attendanceNextButton.setOnClickListener { presenter.onNextDay() }
|
||||
|
||||
attendanceNavContainer.setElevationCompat(requireContext().dpToPx(8f))
|
||||
@ -110,11 +120,19 @@ class AttendanceFragment : BaseFragment(), AttendanceView, MainView.MainChildVie
|
||||
}
|
||||
|
||||
override fun showEmpty(show: Boolean) {
|
||||
attendanceEmpty.visibility = if (show) View.VISIBLE else View.GONE
|
||||
attendanceEmpty.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun showErrorView(show: Boolean) {
|
||||
attendanceError.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun setErrorDetails(message: String) {
|
||||
attendanceErrorMessage.text = message
|
||||
}
|
||||
|
||||
override fun showProgress(show: Boolean) {
|
||||
attendanceProgress.visibility = if (show) View.VISIBLE else View.GONE
|
||||
attendanceProgress.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun enableSwipe(enable: Boolean) {
|
||||
@ -122,7 +140,7 @@ class AttendanceFragment : BaseFragment(), AttendanceView, MainView.MainChildVie
|
||||
}
|
||||
|
||||
override fun showContent(show: Boolean) {
|
||||
attendanceRecycler.visibility = if (show) View.VISIBLE else View.GONE
|
||||
attendanceRecycler.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun hideRefresh() {
|
||||
@ -130,17 +148,32 @@ class AttendanceFragment : BaseFragment(), AttendanceView, MainView.MainChildVie
|
||||
}
|
||||
|
||||
override fun showPreButton(show: Boolean) {
|
||||
attendancePreviousButton.visibility = if (show) View.VISIBLE else View.INVISIBLE
|
||||
attendancePreviousButton.visibility = if (show) VISIBLE else INVISIBLE
|
||||
}
|
||||
|
||||
override fun showNextButton(show: Boolean) {
|
||||
attendanceNextButton.visibility = if (show) View.VISIBLE else View.INVISIBLE
|
||||
attendanceNextButton.visibility = if (show) VISIBLE else INVISIBLE
|
||||
}
|
||||
|
||||
override fun showAttendanceDialog(lesson: Attendance) {
|
||||
(activity as? MainActivity)?.showDialogFragment(AttendanceDialog.newInstance(lesson))
|
||||
}
|
||||
|
||||
override fun showDatePickerDialog(currentDate: LocalDate) {
|
||||
val dateSetListener = DatePickerDialog.OnDateSetListener { _, year, month, dayOfMonth ->
|
||||
presenter.onDateSet(year, month + 1, dayOfMonth)
|
||||
}
|
||||
val datePickerDialog = DatePickerDialog.newInstance(dateSetListener,
|
||||
currentDate.year, currentDate.monthValue - 1, currentDate.dayOfMonth)
|
||||
|
||||
with(datePickerDialog) {
|
||||
setDateRangeLimiter(SchooldaysRangeLimiter())
|
||||
version = DatePickerDialog.Version.VERSION_2
|
||||
scrollOrientation = DatePickerDialog.ScrollOrientation.VERTICAL
|
||||
show(this@AttendanceFragment.parentFragmentManager, null)
|
||||
}
|
||||
}
|
||||
|
||||
override fun openSummaryView() {
|
||||
(activity as? MainActivity)?.pushView(AttendanceSummaryFragment.newInstance())
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.github.wulkanowy.ui.modules.attendance
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||
import io.github.wulkanowy.data.repositories.attendance.AttendanceRepository
|
||||
import io.github.wulkanowy.data.repositories.preferences.PreferencesRepository
|
||||
@ -37,10 +38,13 @@ class AttendancePresenter @Inject constructor(
|
||||
lateinit var currentDate: LocalDate
|
||||
private set
|
||||
|
||||
private lateinit var lastError: Throwable
|
||||
|
||||
fun onAttachView(view: AttendanceView, date: Long?) {
|
||||
super.onAttachView(view)
|
||||
view.initView()
|
||||
Timber.i("Attendance view was initialized")
|
||||
errorHandler.showErrorMessage = ::showErrorViewOnError
|
||||
loadData(ofEpochDay(date ?: baseDate.toEpochDay()))
|
||||
if (currentDate.isHolidays) setBaseDateOnHolidays()
|
||||
reloadView()
|
||||
@ -56,11 +60,32 @@ class AttendancePresenter @Inject constructor(
|
||||
reloadView()
|
||||
}
|
||||
|
||||
fun onPickDate() {
|
||||
view?.showDatePickerDialog(currentDate)
|
||||
}
|
||||
|
||||
fun onDateSet(year: Int, month: Int, day: Int) {
|
||||
loadData(LocalDate.of(year, month, day))
|
||||
reloadView()
|
||||
}
|
||||
|
||||
fun onSwipeRefresh() {
|
||||
Timber.i("Force refreshing the attendance")
|
||||
loadData(currentDate, true)
|
||||
}
|
||||
|
||||
fun onRetry() {
|
||||
view?.run {
|
||||
showErrorView(false)
|
||||
showProgress(true)
|
||||
}
|
||||
loadData(currentDate, true)
|
||||
}
|
||||
|
||||
fun onDetailsClick() {
|
||||
view?.showErrorDetailsDialog(lastError)
|
||||
}
|
||||
|
||||
fun onViewReselected() {
|
||||
Timber.i("Attendance view is reselected")
|
||||
view?.also { view ->
|
||||
@ -130,18 +155,29 @@ class AttendancePresenter @Inject constructor(
|
||||
view?.apply {
|
||||
updateData(it)
|
||||
showEmpty(it.isEmpty())
|
||||
showErrorView(false)
|
||||
showContent(it.isNotEmpty())
|
||||
}
|
||||
analytics.logEvent("load_attendance", "items" to it.size, "force_refresh" to forceRefresh)
|
||||
}) {
|
||||
Timber.i("Loading attendance result: An exception occurred")
|
||||
view?.run { showEmpty(isViewEmpty) }
|
||||
errorHandler.dispatch(it)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showErrorViewOnError(message: String, error: Throwable) {
|
||||
view?.run {
|
||||
if (isViewEmpty) {
|
||||
lastError = error
|
||||
setErrorDetails(message)
|
||||
showErrorView(true)
|
||||
showEmpty(false)
|
||||
} else showError(message, error)
|
||||
}
|
||||
}
|
||||
|
||||
private fun reloadView() {
|
||||
Timber.i("Reload attendance view with the date ${currentDate.toFormattedString()}")
|
||||
view?.apply {
|
||||
@ -149,11 +185,13 @@ class AttendancePresenter @Inject constructor(
|
||||
enableSwipe(false)
|
||||
showContent(false)
|
||||
showEmpty(false)
|
||||
showErrorView(false)
|
||||
clearData()
|
||||
reloadNavigation()
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("DefaultLocale")
|
||||
private fun reloadNavigation() {
|
||||
view?.apply {
|
||||
showPreButton(!currentDate.minusDays(1).isHolidays)
|
||||
|
@ -2,6 +2,7 @@ package io.github.wulkanowy.ui.modules.attendance
|
||||
|
||||
import io.github.wulkanowy.data.db.entities.Attendance
|
||||
import io.github.wulkanowy.ui.base.BaseView
|
||||
import org.threeten.bp.LocalDate
|
||||
|
||||
interface AttendanceView : BaseView {
|
||||
|
||||
@ -23,6 +24,10 @@ interface AttendanceView : BaseView {
|
||||
|
||||
fun showEmpty(show: Boolean)
|
||||
|
||||
fun showErrorView(show: Boolean)
|
||||
|
||||
fun setErrorDetails(message: String)
|
||||
|
||||
fun showProgress(show: Boolean)
|
||||
|
||||
fun enableSwipe(enable: Boolean)
|
||||
@ -35,6 +40,8 @@ interface AttendanceView : BaseView {
|
||||
|
||||
fun showAttendanceDialog(lesson: Attendance)
|
||||
|
||||
fun showDatePickerDialog(currentDate: LocalDate)
|
||||
|
||||
fun openSummaryView()
|
||||
|
||||
fun popView()
|
||||
|
@ -57,6 +57,8 @@ class AttendanceSummaryFragment : BaseFragment(), AttendanceSummaryView, MainVie
|
||||
}
|
||||
|
||||
attendanceSummarySwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||
attendanceSummaryErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||
attendanceSummaryErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||
|
||||
subjectsAdapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, mutableListOf())
|
||||
subjectsAdapter.setDropDownViewResource(R.layout.item_attendance_summary_subject)
|
||||
@ -93,6 +95,14 @@ class AttendanceSummaryFragment : BaseFragment(), AttendanceSummaryView, MainVie
|
||||
attendanceSummaryEmpty.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun showErrorView(show: Boolean) {
|
||||
attendanceSummaryError.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun setErrorDetails(message: String) {
|
||||
attendanceSummaryErrorMessage.text = message
|
||||
}
|
||||
|
||||
override fun showProgress(show: Boolean) {
|
||||
attendanceSummaryProgress.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
@ -33,10 +33,13 @@ class AttendanceSummaryPresenter @Inject constructor(
|
||||
var currentSubjectId = -1
|
||||
private set
|
||||
|
||||
private lateinit var lastError: Throwable
|
||||
|
||||
fun onAttachView(view: AttendanceSummaryView, subjectId: Int?) {
|
||||
super.onAttachView(view)
|
||||
view.initView()
|
||||
Timber.i("Attendance summary view was initialized with subject id ${subjectId ?: -1}")
|
||||
errorHandler.showErrorMessage = ::showErrorViewOnError
|
||||
loadData(subjectId ?: -1)
|
||||
loadSubjects()
|
||||
}
|
||||
@ -46,12 +49,26 @@ class AttendanceSummaryPresenter @Inject constructor(
|
||||
loadData(currentSubjectId, true)
|
||||
}
|
||||
|
||||
fun onRetry() {
|
||||
view?.run {
|
||||
showErrorView(false)
|
||||
showProgress(true)
|
||||
}
|
||||
loadData(currentSubjectId, true)
|
||||
}
|
||||
|
||||
fun onDetailsClick() {
|
||||
view?.showErrorDetailsDialog(lastError)
|
||||
}
|
||||
|
||||
fun onSubjectSelected(name: String?) {
|
||||
Timber.i("Select attendance summary subject $name")
|
||||
view?.run {
|
||||
showContent(false)
|
||||
showProgress(true)
|
||||
enableSwipe(false)
|
||||
showEmpty(false)
|
||||
showErrorView(false)
|
||||
clearView()
|
||||
}
|
||||
(subjects.singleOrNull { it.name == name }?.realId ?: -1).let {
|
||||
@ -88,13 +105,23 @@ class AttendanceSummaryPresenter @Inject constructor(
|
||||
analytics.logEvent("load_attendance_summary", "items" to it.first.size, "force_refresh" to forceRefresh, "item_id" to subjectId)
|
||||
}) {
|
||||
Timber.i("Loading attendance summary result: An exception occurred")
|
||||
view?.run { showEmpty(isViewEmpty) }
|
||||
errorHandler.dispatch(it)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showErrorViewOnError(message: String, error: Throwable) {
|
||||
view?.run {
|
||||
if (isViewEmpty) {
|
||||
lastError = error
|
||||
setErrorDetails(message)
|
||||
showErrorView(true)
|
||||
showEmpty(false)
|
||||
} else showError(message, error)
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadSubjects() {
|
||||
Timber.i("Loading attendance summary subjects started")
|
||||
disposable.add(studentRepository.getCurrentStudent()
|
||||
|
@ -18,6 +18,10 @@ interface AttendanceSummaryView : BaseView {
|
||||
|
||||
fun showEmpty(show: Boolean)
|
||||
|
||||
fun showErrorView(show: Boolean)
|
||||
|
||||
fun setErrorDetails(message: String)
|
||||
|
||||
fun updateDataSet(data: List<AttendanceSummaryItem>, header: AttendanceSummaryScrollableHeader)
|
||||
|
||||
fun updateSubjects(data: ArrayList<String>)
|
||||
|
@ -61,6 +61,9 @@ class ExamFragment : BaseFragment(), ExamView, MainView.MainChildView, MainView.
|
||||
}
|
||||
|
||||
examSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||
examErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||
examErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||
|
||||
examPreviousButton.setOnClickListener { presenter.onPreviousWeek() }
|
||||
examNextButton.setOnClickListener { presenter.onNextWeek() }
|
||||
|
||||
@ -95,6 +98,14 @@ class ExamFragment : BaseFragment(), ExamView, MainView.MainChildView, MainView.
|
||||
examEmpty.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun showErrorView(show: Boolean) {
|
||||
examError.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun setErrorDetails(message: String) {
|
||||
examErrorMessage.text = message
|
||||
}
|
||||
|
||||
override fun showProgress(show: Boolean) {
|
||||
examProgress.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
@ -36,10 +36,13 @@ class ExamPresenter @Inject constructor(
|
||||
lateinit var currentDate: LocalDate
|
||||
private set
|
||||
|
||||
private lateinit var lastError: Throwable
|
||||
|
||||
fun onAttachView(view: ExamView, date: Long?) {
|
||||
super.onAttachView(view)
|
||||
view.initView()
|
||||
Timber.i("Exam view was initialized")
|
||||
errorHandler.showErrorMessage = ::showErrorViewOnError
|
||||
loadData(ofEpochDay(date ?: baseDate.toEpochDay()))
|
||||
if (currentDate.isHolidays) setBaseDateOnHolidays()
|
||||
reloadView()
|
||||
@ -60,6 +63,18 @@ class ExamPresenter @Inject constructor(
|
||||
loadData(currentDate, true)
|
||||
}
|
||||
|
||||
fun onRetry() {
|
||||
view?.run {
|
||||
showErrorView(false)
|
||||
showProgress(true)
|
||||
}
|
||||
loadData(currentDate, true)
|
||||
}
|
||||
|
||||
fun onDetailsClick() {
|
||||
view?.showErrorDetailsDialog(lastError)
|
||||
}
|
||||
|
||||
fun onExamItemSelected(item: AbstractFlexibleItem<*>?) {
|
||||
if (item is ExamItem) {
|
||||
Timber.i("Select exam item ${item.exam.id}")
|
||||
@ -116,17 +131,28 @@ class ExamPresenter @Inject constructor(
|
||||
view?.apply {
|
||||
updateData(it)
|
||||
showEmpty(it.isEmpty())
|
||||
showErrorView(false)
|
||||
showContent(it.isNotEmpty())
|
||||
}
|
||||
analytics.logEvent("load_exam", "items" to it.size, "force_refresh" to forceRefresh)
|
||||
}) {
|
||||
Timber.i("Loading exam result: An exception occurred")
|
||||
view?.run { showEmpty(isViewEmpty) }
|
||||
errorHandler.dispatch(it)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private fun showErrorViewOnError(message: String, error: Throwable) {
|
||||
view?.run {
|
||||
if (isViewEmpty) {
|
||||
lastError = error
|
||||
setErrorDetails(message)
|
||||
showErrorView(true)
|
||||
showEmpty(false)
|
||||
} else showError(message, error)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createExamItems(items: Map<LocalDate, List<Exam>>): List<ExamItem> {
|
||||
return items.flatMap {
|
||||
ExamHeader(it.key).let { header ->
|
||||
@ -142,6 +168,7 @@ class ExamPresenter @Inject constructor(
|
||||
enableSwipe(false)
|
||||
showContent(false)
|
||||
showEmpty(false)
|
||||
showErrorView(false)
|
||||
clearData()
|
||||
reloadNavigation()
|
||||
}
|
||||
|
@ -21,6 +21,10 @@ interface ExamView : BaseView {
|
||||
|
||||
fun showEmpty(show: Boolean)
|
||||
|
||||
fun showErrorView(show: Boolean)
|
||||
|
||||
fun setErrorDetails(message: String)
|
||||
|
||||
fun showProgress(show: Boolean)
|
||||
|
||||
fun enableSwipe(enable: Boolean)
|
||||
|
@ -13,6 +13,7 @@ import androidx.appcompat.app.AlertDialog
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter
|
||||
import io.github.wulkanowy.ui.base.ErrorDialog
|
||||
import io.github.wulkanowy.ui.modules.grade.details.GradeDetailsFragment
|
||||
import io.github.wulkanowy.ui.modules.grade.statistics.GradeStatisticsFragment
|
||||
import io.github.wulkanowy.ui.modules.grade.summary.GradeSummaryFragment
|
||||
@ -83,7 +84,8 @@ class GradeFragment : BaseFragment(), GradeView, MainView.MainChildView, MainVie
|
||||
setElevationCompat(context.dpToPx(4f))
|
||||
}
|
||||
|
||||
gradeSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||
gradeErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||
gradeErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
@ -104,22 +106,18 @@ class GradeFragment : BaseFragment(), GradeView, MainView.MainChildView, MainVie
|
||||
gradeProgress.visibility = if (show) VISIBLE else INVISIBLE
|
||||
}
|
||||
|
||||
override fun showEmpty(show: Boolean) {
|
||||
gradeEmpty.visibility = if (show) VISIBLE else INVISIBLE
|
||||
override fun showErrorView(show: Boolean) {
|
||||
gradeError.visibility = if (show) VISIBLE else INVISIBLE
|
||||
}
|
||||
|
||||
override fun showRefresh(show: Boolean) {
|
||||
gradeSwipe.isRefreshing = show
|
||||
override fun setErrorDetails(message: String) {
|
||||
gradeErrorMessage.text = message
|
||||
}
|
||||
|
||||
override fun showSemesterSwitch(show: Boolean) {
|
||||
semesterSwitchMenu?.isVisible = show
|
||||
}
|
||||
|
||||
override fun enableSwipe(enable: Boolean) {
|
||||
gradeSwipe.isEnabled = enable
|
||||
}
|
||||
|
||||
override fun showSemesterDialog(selectedIndex: Int) {
|
||||
val choices = arrayOf(
|
||||
getString(R.string.grade_semester, 1),
|
||||
|
@ -11,13 +11,12 @@ import io.github.wulkanowy.ui.modules.grade.statistics.GradeStatisticsFragment
|
||||
import io.github.wulkanowy.ui.modules.grade.summary.GradeSummaryFragment
|
||||
|
||||
@Suppress("unused")
|
||||
@Module
|
||||
@Module(includes = [GradeModule.Static::class])
|
||||
abstract class GradeModule {
|
||||
|
||||
@Module
|
||||
companion object {
|
||||
object Static {
|
||||
|
||||
@JvmStatic
|
||||
@PerFragment
|
||||
@Provides
|
||||
fun provideGradeAdapter(fragment: GradeFragment) = BaseFragmentPagerAdapter(fragment.childFragmentManager)
|
||||
|
@ -25,14 +25,14 @@ class GradePresenter @Inject constructor(
|
||||
|
||||
private val loadedSemesterId = mutableMapOf<Int, Int>()
|
||||
|
||||
private lateinit var lastError: Throwable
|
||||
|
||||
fun onAttachView(view: GradeView, savedIndex: Int?) {
|
||||
super.onAttachView(view)
|
||||
selectedIndex = savedIndex ?: 0
|
||||
view.run {
|
||||
initView()
|
||||
enableSwipe(false)
|
||||
}
|
||||
view.initView()
|
||||
Timber.i("Grade view was initialized with $selectedIndex index")
|
||||
errorHandler.showErrorMessage = ::showErrorViewOnError
|
||||
loadData()
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ class GradePresenter @Inject constructor(
|
||||
view?.apply {
|
||||
showContent(true)
|
||||
showProgress(false)
|
||||
showEmpty(false)
|
||||
showErrorView(false)
|
||||
loadedSemesterId[currentPageIndex] = semesterId
|
||||
}
|
||||
}
|
||||
@ -80,10 +80,18 @@ class GradePresenter @Inject constructor(
|
||||
if (semesters.isNotEmpty()) loadChild(index)
|
||||
}
|
||||
|
||||
fun onSwipeRefresh() {
|
||||
fun onRetry() {
|
||||
view?.run {
|
||||
showErrorView(false)
|
||||
showProgress(true)
|
||||
}
|
||||
loadData()
|
||||
}
|
||||
|
||||
fun onDetailsClick() {
|
||||
view?.showErrorDetailsDialog(lastError)
|
||||
}
|
||||
|
||||
private fun loadData() {
|
||||
Timber.i("Loading grade data started")
|
||||
disposable.add(studentRepository.getCurrentStudent()
|
||||
@ -96,25 +104,28 @@ class GradePresenter @Inject constructor(
|
||||
}
|
||||
.subscribeOn(schedulers.backgroundThread)
|
||||
.observeOn(schedulers.mainThread)
|
||||
.doFinally { view?.showRefresh(false) }
|
||||
.doFinally { view?.showProgress(false) }
|
||||
.subscribe({
|
||||
view?.run {
|
||||
Timber.i("Loading grade result: Attempt load index $currentPageIndex")
|
||||
loadChild(currentPageIndex)
|
||||
enableSwipe(false)
|
||||
showErrorView(false)
|
||||
showSemesterSwitch(true)
|
||||
}
|
||||
}) {
|
||||
Timber.i("Loading grade result: An exception occurred")
|
||||
errorHandler.dispatch(it)
|
||||
view?.run {
|
||||
showProgress(false)
|
||||
showEmpty(true)
|
||||
enableSwipe(true)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun showErrorViewOnError(message: String, error: Throwable) {
|
||||
lastError = error
|
||||
view?.run {
|
||||
showErrorView(true)
|
||||
setErrorDetails(message)
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadChild(index: Int, forceRefresh: Boolean = false) {
|
||||
semesters.first { it.semesterName == selectedIndex }.semesterId.also {
|
||||
if (forceRefresh || loadedSemesterId[index] != it) {
|
||||
|
@ -12,16 +12,14 @@ interface GradeView : BaseView {
|
||||
|
||||
fun showProgress(show: Boolean)
|
||||
|
||||
fun showEmpty(show: Boolean)
|
||||
fun showErrorView(show: Boolean)
|
||||
|
||||
fun showRefresh(show: Boolean)
|
||||
fun setErrorDetails(message: String)
|
||||
|
||||
fun showSemesterSwitch(show: Boolean)
|
||||
|
||||
fun showSemesterDialog(selectedIndex: Int)
|
||||
|
||||
fun enableSwipe(enable: Boolean)
|
||||
|
||||
fun notifyChildLoadData(index: Int, semesterId: Int, forceRefresh: Boolean)
|
||||
|
||||
fun notifyChildParentReselected(index: Int)
|
||||
|
@ -18,6 +18,7 @@ import eu.davidea.flexibleadapter.items.IFlexible
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.Grade
|
||||
import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.base.ErrorDialog
|
||||
import io.github.wulkanowy.ui.modules.grade.GradeFragment
|
||||
import io.github.wulkanowy.ui.modules.grade.GradeView
|
||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||
@ -90,6 +91,8 @@ class GradeDetailsFragment : BaseFragment(), GradeDetailsView, GradeView.GradeCh
|
||||
)
|
||||
}
|
||||
gradeDetailsSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||
gradeDetailsErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||
gradeDetailsErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
@ -141,6 +144,14 @@ class GradeDetailsFragment : BaseFragment(), GradeDetailsView, GradeView.GradeCh
|
||||
gradeDetailsEmpty.visibility = if (show) VISIBLE else INVISIBLE
|
||||
}
|
||||
|
||||
override fun showErrorView(show: Boolean) {
|
||||
gradeDetailsError.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun setErrorDetails(message: String) {
|
||||
gradeDetailsErrorMessage.text = message
|
||||
}
|
||||
|
||||
override fun showRefresh(show: Boolean) {
|
||||
gradeDetailsSwipe.isRefreshing = show
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.github.wulkanowy.ui.modules.grade.details
|
||||
|
||||
import android.widget.Toast
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||
import io.github.wulkanowy.data.db.entities.Grade
|
||||
import io.github.wulkanowy.data.repositories.grade.GradeRepository
|
||||
@ -31,9 +30,12 @@ class GradeDetailsPresenter @Inject constructor(
|
||||
|
||||
private var currentSemesterId = 0
|
||||
|
||||
private lateinit var lastError: Throwable
|
||||
|
||||
override fun onAttachView(view: GradeDetailsView) {
|
||||
super.onAttachView(view)
|
||||
view.initView()
|
||||
errorHandler.showErrorMessage = ::showErrorViewOnError
|
||||
}
|
||||
|
||||
fun onParentViewLoadData(semesterId: Int, forceRefresh: Boolean) {
|
||||
@ -90,6 +92,18 @@ class GradeDetailsPresenter @Inject constructor(
|
||||
view?.notifyParentRefresh()
|
||||
}
|
||||
|
||||
fun onRetry() {
|
||||
view?.run {
|
||||
showErrorView(false)
|
||||
showProgress(true)
|
||||
}
|
||||
view?.notifyParentRefresh()
|
||||
}
|
||||
|
||||
fun onDetailsClick() {
|
||||
view?.showErrorDetailsDialog(lastError)
|
||||
}
|
||||
|
||||
fun onParentViewReselected() {
|
||||
view?.run {
|
||||
if (!isViewEmpty) {
|
||||
@ -140,21 +154,32 @@ class GradeDetailsPresenter @Inject constructor(
|
||||
}
|
||||
.subscribe({
|
||||
Timber.i("Loading grade details result: Success")
|
||||
newGradesAmount = it.sumBy { gradeDetailsHeader -> gradeDetailsHeader.newGrades }
|
||||
newGradesAmount = it.sumBy { gradeDetailsHeader -> gradeDetailsHeader.newGrades }
|
||||
updateMarkAsDoneButton()
|
||||
view?.run {
|
||||
showEmpty(it.isEmpty())
|
||||
showErrorView(false)
|
||||
showContent(it.isNotEmpty())
|
||||
updateData(it)
|
||||
}
|
||||
analytics.logEvent("load_grade_details", "items" to it.size, "force_refresh" to forceRefresh)
|
||||
}) {
|
||||
Timber.i("Loading grade details result: An exception occurred")
|
||||
view?.run { showEmpty(isViewEmpty) }
|
||||
errorHandler.dispatch(it)
|
||||
})
|
||||
}
|
||||
|
||||
private fun showErrorViewOnError(message: String, error: Throwable) {
|
||||
view?.run {
|
||||
if (isViewEmpty) {
|
||||
lastError = error
|
||||
setErrorDetails(message)
|
||||
showErrorView(true)
|
||||
showEmpty(false)
|
||||
} else showError(message, error)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createGradeItems(items: Map<String, List<Grade>>, averages: Map<String, Double>): List<GradeDetailsHeader> {
|
||||
val isGradeExpandable = preferencesRepository.isGradeExpandable
|
||||
val gradeColorTheme = preferencesRepository.gradeColorTheme
|
||||
|
@ -38,6 +38,10 @@ interface GradeDetailsView : BaseView {
|
||||
|
||||
fun showProgress(show: Boolean)
|
||||
|
||||
fun showErrorView(show: Boolean)
|
||||
|
||||
fun setErrorDetails(message: String)
|
||||
|
||||
fun enableSwipe(enable: Boolean)
|
||||
|
||||
fun showRefresh(show: Boolean)
|
||||
|
@ -111,9 +111,11 @@ class GradeStatisticsFragment : BaseFragment(), GradeStatisticsView, GradeView.G
|
||||
setOnItemSelectedListener<TextView> { presenter.onSubjectSelected(it?.text?.toString()) }
|
||||
}
|
||||
|
||||
gradeStatisticsSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||
|
||||
gradeStatisticsSubjectsContainer.setElevationCompat(requireContext().dpToPx(1f))
|
||||
|
||||
gradeStatisticsSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||
gradeStatisticsErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||
gradeStatisticsErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||
}
|
||||
|
||||
override fun updateSubjects(data: ArrayList<String>) {
|
||||
@ -228,6 +230,14 @@ class GradeStatisticsFragment : BaseFragment(), GradeStatisticsView, GradeView.G
|
||||
gradeStatisticsEmpty.visibility = if (show) View.VISIBLE else View.INVISIBLE
|
||||
}
|
||||
|
||||
override fun showErrorView(show: Boolean) {
|
||||
gradeStatisticsError.visibility = if (show) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
override fun setErrorDetails(message: String) {
|
||||
gradeStatisticsErrorMessage.text = message
|
||||
}
|
||||
|
||||
override fun showProgress(show: Boolean) {
|
||||
gradeStatisticsProgress.visibility = if (show) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ class GradeStatisticsPresenter @Inject constructor(
|
||||
|
||||
private var currentSubjectName: String = "Wszystkie"
|
||||
|
||||
private lateinit var lastError: Throwable
|
||||
|
||||
var currentType: ViewType = ViewType.PARTIAL
|
||||
private set
|
||||
|
||||
@ -37,6 +39,7 @@ class GradeStatisticsPresenter @Inject constructor(
|
||||
super.onAttachView(view)
|
||||
currentType = type ?: ViewType.PARTIAL
|
||||
view.initView()
|
||||
errorHandler.showErrorMessage = ::showErrorViewOnError
|
||||
}
|
||||
|
||||
fun onParentViewLoadData(semesterId: Int, forceRefresh: Boolean) {
|
||||
@ -51,6 +54,7 @@ class GradeStatisticsPresenter @Inject constructor(
|
||||
enableSwipe(false)
|
||||
showRefresh(false)
|
||||
showBarContent(false)
|
||||
showErrorView(false)
|
||||
showEmpty(false)
|
||||
clearView()
|
||||
}
|
||||
@ -62,6 +66,18 @@ class GradeStatisticsPresenter @Inject constructor(
|
||||
view?.notifyParentRefresh()
|
||||
}
|
||||
|
||||
fun onRetry() {
|
||||
view?.run {
|
||||
showErrorView(false)
|
||||
showProgress(true)
|
||||
}
|
||||
view?.notifyParentRefresh()
|
||||
}
|
||||
|
||||
fun onDetailsClick() {
|
||||
view?.showErrorDetailsDialog(lastError)
|
||||
}
|
||||
|
||||
fun onSubjectSelected(name: String?) {
|
||||
Timber.i("Select grade stats subject $name")
|
||||
view?.run {
|
||||
@ -70,6 +86,7 @@ class GradeStatisticsPresenter @Inject constructor(
|
||||
showProgress(true)
|
||||
enableSwipe(false)
|
||||
showEmpty(false)
|
||||
showErrorView(false)
|
||||
clearView()
|
||||
}
|
||||
(subjects.singleOrNull { it.name == name }?.name)?.let {
|
||||
@ -86,6 +103,7 @@ class GradeStatisticsPresenter @Inject constructor(
|
||||
showProgress(true)
|
||||
enableSwipe(false)
|
||||
showEmpty(false)
|
||||
showErrorView(false)
|
||||
clearView()
|
||||
}
|
||||
loadDataByType(currentSemesterId, currentSubjectName, type)
|
||||
@ -146,12 +164,12 @@ class GradeStatisticsPresenter @Inject constructor(
|
||||
showEmpty(it.isEmpty())
|
||||
showBarContent(false)
|
||||
showPieContent(it.isNotEmpty())
|
||||
showErrorView(false)
|
||||
updatePieData(it, preferencesRepository.gradeColorTheme)
|
||||
}
|
||||
analytics.logEvent("load_grade_statistics", "items" to it.size, "force_refresh" to forceRefresh)
|
||||
}) {
|
||||
Timber.e("Loading grade stats result: An exception occurred")
|
||||
view?.run { showEmpty(isPieViewEmpty) }
|
||||
errorHandler.dispatch(it)
|
||||
})
|
||||
}
|
||||
@ -177,12 +195,12 @@ class GradeStatisticsPresenter @Inject constructor(
|
||||
showEmpty(false)
|
||||
showPieContent(false)
|
||||
showBarContent(true)
|
||||
showErrorView(false)
|
||||
updateBarData(it)
|
||||
}
|
||||
analytics.logEvent("load_grade_points_statistics", "force_refresh" to forceRefresh)
|
||||
}, {
|
||||
Timber.e("Loading grade points stats result: An exception occurred")
|
||||
view?.run { showEmpty(isBarViewEmpty) }
|
||||
errorHandler.dispatch(it)
|
||||
}, {
|
||||
Timber.d("Loading grade points stats result: No point stats found")
|
||||
@ -193,4 +211,15 @@ class GradeStatisticsPresenter @Inject constructor(
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
private fun showErrorViewOnError(message: String, error: Throwable) {
|
||||
view?.run {
|
||||
if (isBarViewEmpty || isPieViewEmpty) {
|
||||
lastError = error
|
||||
setErrorDetails(message)
|
||||
showErrorView(true)
|
||||
showEmpty(false)
|
||||
} else showError(message, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,10 @@ interface GradeStatisticsView : BaseView {
|
||||
|
||||
fun showEmpty(show: Boolean)
|
||||
|
||||
fun showErrorView(show: Boolean)
|
||||
|
||||
fun setErrorDetails(message: String)
|
||||
|
||||
fun showProgress(show: Boolean)
|
||||
|
||||
fun enableSwipe(enable: Boolean)
|
||||
|
@ -56,6 +56,8 @@ class GradeSummaryFragment : BaseFragment(), GradeSummaryView, GradeView.GradeCh
|
||||
adapter = gradeSummaryAdapter
|
||||
}
|
||||
gradeSummarySwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||
gradeSummaryErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||
gradeSummaryErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||
}
|
||||
|
||||
override fun updateData(data: List<GradeSummaryItem>, header: GradeSummaryScrollableHeader) {
|
||||
@ -82,6 +84,14 @@ class GradeSummaryFragment : BaseFragment(), GradeSummaryView, GradeView.GradeCh
|
||||
gradeSummaryEmpty.visibility = if (show) VISIBLE else INVISIBLE
|
||||
}
|
||||
|
||||
override fun showErrorView(show: Boolean) {
|
||||
gradeSummaryError.visibility = if (show) VISIBLE else INVISIBLE
|
||||
}
|
||||
|
||||
override fun setErrorDetails(message: String) {
|
||||
gradeSummaryErrorMessage.text = message
|
||||
}
|
||||
|
||||
override fun showProgress(show: Boolean) {
|
||||
gradeSummaryProgress.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
@ -25,9 +25,12 @@ class GradeSummaryPresenter @Inject constructor(
|
||||
private val analytics: FirebaseAnalyticsHelper
|
||||
) : BasePresenter<GradeSummaryView>(errorHandler, studentRepository, schedulers) {
|
||||
|
||||
private lateinit var lastError: Throwable
|
||||
|
||||
override fun onAttachView(view: GradeSummaryView) {
|
||||
super.onAttachView(view)
|
||||
view.initView()
|
||||
errorHandler.showErrorMessage = ::showErrorViewOnError
|
||||
}
|
||||
|
||||
fun onParentViewLoadData(semesterId: Int, forceRefresh: Boolean) {
|
||||
@ -56,21 +59,44 @@ class GradeSummaryPresenter @Inject constructor(
|
||||
view?.run {
|
||||
showEmpty(gradeSummaryItems.isEmpty())
|
||||
showContent(gradeSummaryItems.isNotEmpty())
|
||||
showErrorView(false)
|
||||
updateData(gradeSummaryItems, gradeSummaryHeader)
|
||||
}
|
||||
analytics.logEvent("load_grade_summary", "items" to gradeSummaryItems.size, "force_refresh" to forceRefresh)
|
||||
}) {
|
||||
Timber.i("Loading grade summary result: An exception occurred")
|
||||
view?.run { showEmpty(isViewEmpty) }
|
||||
errorHandler.dispatch(it)
|
||||
})
|
||||
}
|
||||
|
||||
private fun showErrorViewOnError(message: String, error: Throwable) {
|
||||
view?.run {
|
||||
if (isViewEmpty) {
|
||||
lastError = error
|
||||
setErrorDetails(message)
|
||||
showErrorView(true)
|
||||
showEmpty(false)
|
||||
} else showError(message, error)
|
||||
}
|
||||
}
|
||||
|
||||
fun onSwipeRefresh() {
|
||||
Timber.i("Force refreshing the grade summary")
|
||||
view?.notifyParentRefresh()
|
||||
}
|
||||
|
||||
fun onRetry() {
|
||||
view?.run {
|
||||
showErrorView(false)
|
||||
showProgress(true)
|
||||
}
|
||||
view?.notifyParentRefresh()
|
||||
}
|
||||
|
||||
fun onDetailsClick() {
|
||||
view?.showErrorDetailsDialog(lastError)
|
||||
}
|
||||
|
||||
fun onParentViewReselected() {
|
||||
view?.run {
|
||||
if (!isViewEmpty) resetView()
|
||||
|
@ -26,6 +26,10 @@ interface GradeSummaryView : BaseView {
|
||||
|
||||
fun showContent(show: Boolean)
|
||||
|
||||
fun showErrorView(show: Boolean)
|
||||
|
||||
fun setErrorDetails(message: String)
|
||||
|
||||
fun showEmpty(show: Boolean)
|
||||
|
||||
fun notifyParentDataLoaded(semesterId: Int)
|
||||
|
@ -3,6 +3,8 @@ package io.github.wulkanowy.ui.modules.homework
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.View.GONE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.ViewGroup
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.common.FlexibleItemDecoration
|
||||
@ -34,6 +36,8 @@ class HomeworkFragment : BaseFragment(), HomeworkView, MainView.TitledView {
|
||||
|
||||
override val titleStringId get() = R.string.homework_title
|
||||
|
||||
override val isViewEmpty get() = homeworkAdapter.isEmpty
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_homework, container, false)
|
||||
}
|
||||
@ -41,7 +45,7 @@ class HomeworkFragment : BaseFragment(), HomeworkView, MainView.TitledView {
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
messageContainer = homeworkRecycler
|
||||
presenter.onAttachView(this, savedInstanceState?.getLong(HomeworkFragment.SAVED_DATE_KEY))
|
||||
presenter.onAttachView(this, savedInstanceState?.getLong(SAVED_DATE_KEY))
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
@ -56,6 +60,9 @@ class HomeworkFragment : BaseFragment(), HomeworkView, MainView.TitledView {
|
||||
}
|
||||
|
||||
homeworkSwipe.setOnRefreshListener(presenter::onSwipeRefresh)
|
||||
homeworkErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||
homeworkErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||
|
||||
homeworkPreviousButton.setOnClickListener { presenter.onPreviousDay() }
|
||||
homeworkNextButton.setOnClickListener { presenter.onNextDay() }
|
||||
|
||||
@ -74,18 +81,24 @@ class HomeworkFragment : BaseFragment(), HomeworkView, MainView.TitledView {
|
||||
homeworkNavDate.text = date
|
||||
}
|
||||
|
||||
override fun isViewEmpty() = homeworkAdapter.isEmpty
|
||||
|
||||
override fun hideRefresh() {
|
||||
homeworkSwipe.isRefreshing = false
|
||||
}
|
||||
|
||||
override fun showEmpty(show: Boolean) {
|
||||
homeworkEmpty.visibility = if (show) View.VISIBLE else View.GONE
|
||||
homeworkEmpty.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun showErrorView(show: Boolean) {
|
||||
homeworkError.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun setErrorDetails(message: String) {
|
||||
homeworkErrorMessage.text = message
|
||||
}
|
||||
|
||||
override fun showProgress(show: Boolean) {
|
||||
homeworkProgress.visibility = if (show) View.VISIBLE else View.GONE
|
||||
homeworkProgress.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun enableSwipe(enable: Boolean) {
|
||||
@ -93,15 +106,15 @@ class HomeworkFragment : BaseFragment(), HomeworkView, MainView.TitledView {
|
||||
}
|
||||
|
||||
override fun showContent(show: Boolean) {
|
||||
homeworkRecycler.visibility = if (show) View.VISIBLE else View.GONE
|
||||
homeworkRecycler.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun showPreButton(show: Boolean) {
|
||||
homeworkPreviousButton.visibility = if (show) View.VISIBLE else View.INVISIBLE
|
||||
homeworkPreviousButton.visibility = if (show) VISIBLE else View.INVISIBLE
|
||||
}
|
||||
|
||||
override fun showNextButton(show: Boolean) {
|
||||
homeworkNextButton.visibility = if (show) View.VISIBLE else View.INVISIBLE
|
||||
homeworkNextButton.visibility = if (show) VISIBLE else View.INVISIBLE
|
||||
}
|
||||
|
||||
override fun showTimetableDialog(homework: Homework) {
|
||||
|
@ -35,10 +35,13 @@ class HomeworkPresenter @Inject constructor(
|
||||
lateinit var currentDate: LocalDate
|
||||
private set
|
||||
|
||||
private lateinit var lastError: Throwable
|
||||
|
||||
fun onAttachView(view: HomeworkView, date: Long?) {
|
||||
super.onAttachView(view)
|
||||
view.initView()
|
||||
Timber.i("Homework view was initialized")
|
||||
errorHandler.showErrorMessage = ::showErrorViewOnError
|
||||
loadData(ofEpochDay(date ?: baseDate.toEpochDay()))
|
||||
if (currentDate.isHolidays) setBaseDateOnHolidays()
|
||||
reloadView()
|
||||
@ -59,6 +62,18 @@ class HomeworkPresenter @Inject constructor(
|
||||
loadData(currentDate, true)
|
||||
}
|
||||
|
||||
fun onRetry() {
|
||||
view?.run {
|
||||
showErrorView(false)
|
||||
showProgress(true)
|
||||
}
|
||||
loadData(currentDate, true)
|
||||
}
|
||||
|
||||
fun onDetailsClick() {
|
||||
view?.showErrorDetailsDialog(lastError)
|
||||
}
|
||||
|
||||
fun onHomeworkItemSelected(item: AbstractFlexibleItem<*>?) {
|
||||
if (item is HomeworkItem) {
|
||||
Timber.i("Select homework item ${item.homework.id}")
|
||||
@ -105,17 +120,29 @@ class HomeworkPresenter @Inject constructor(
|
||||
view?.apply {
|
||||
updateData(it)
|
||||
showEmpty(it.isEmpty())
|
||||
showErrorView(false)
|
||||
showContent(it.isNotEmpty())
|
||||
}
|
||||
analytics.logEvent("load_homework", "items" to it.size, "force_refresh" to forceRefresh)
|
||||
}) {
|
||||
Timber.i("Loading homework result: An exception occurred")
|
||||
view?.run { showEmpty(isViewEmpty()) }
|
||||
|
||||
errorHandler.dispatch(it)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
private fun showErrorViewOnError(message: String, error: Throwable) {
|
||||
view?.run {
|
||||
if (isViewEmpty) {
|
||||
lastError = error
|
||||
setErrorDetails(message)
|
||||
showErrorView(true)
|
||||
showEmpty(false)
|
||||
} else showError(message, error)
|
||||
}
|
||||
}
|
||||
|
||||
private fun createHomeworkItem(items: Map<LocalDate, List<Homework>>): List<HomeworkItem> {
|
||||
return items.flatMap {
|
||||
HomeworkHeader(it.key).let { header ->
|
||||
@ -131,6 +158,7 @@ class HomeworkPresenter @Inject constructor(
|
||||
enableSwipe(false)
|
||||
showContent(false)
|
||||
showEmpty(false)
|
||||
showErrorView(false)
|
||||
clearData()
|
||||
reloadNavigation()
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import io.github.wulkanowy.ui.base.BaseView
|
||||
|
||||
interface HomeworkView : BaseView {
|
||||
|
||||
val isViewEmpty: Boolean
|
||||
|
||||
fun initView()
|
||||
|
||||
fun updateData(data: List<HomeworkItem>)
|
||||
@ -13,12 +15,14 @@ interface HomeworkView : BaseView {
|
||||
|
||||
fun updateNavigationWeek(date: String)
|
||||
|
||||
fun isViewEmpty(): Boolean
|
||||
|
||||
fun hideRefresh()
|
||||
|
||||
fun showEmpty(show: Boolean)
|
||||
|
||||
fun showErrorView(show: Boolean)
|
||||
|
||||
fun setErrorDetails(message: String)
|
||||
|
||||
fun showProgress(show: Boolean)
|
||||
|
||||
fun enableSwipe(enable: Boolean)
|
||||
|
@ -11,13 +11,12 @@ import io.github.wulkanowy.ui.modules.login.studentselect.LoginStudentSelectFrag
|
||||
import io.github.wulkanowy.ui.modules.login.symbol.LoginSymbolFragment
|
||||
|
||||
@Suppress("unused")
|
||||
@Module
|
||||
@Module(includes = [LoginModule.Static::class])
|
||||
internal abstract class LoginModule {
|
||||
|
||||
@Module
|
||||
companion object {
|
||||
object Static {
|
||||
|
||||
@JvmStatic
|
||||
@PerActivity
|
||||
@Provides
|
||||
fun provideLoginAdapter(activity: LoginActivity) = BaseFragmentPagerAdapter(activity.supportFragmentManager)
|
||||
|
@ -9,7 +9,6 @@ import android.view.View.VISIBLE
|
||||
import android.view.ViewGroup
|
||||
import android.view.inputmethod.EditorInfo.IME_ACTION_DONE
|
||||
import android.view.inputmethod.EditorInfo.IME_NULL
|
||||
import android.widget.ArrayAdapter
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
@ -17,6 +16,7 @@ import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||
import io.github.wulkanowy.utils.AppInfo
|
||||
import io.github.wulkanowy.utils.hideSoftInput
|
||||
import io.github.wulkanowy.utils.openEmailClient
|
||||
import io.github.wulkanowy.utils.openInternetBrowser
|
||||
import io.github.wulkanowy.utils.showSoftInput
|
||||
import kotlinx.android.synthetic.main.fragment_login_form.*
|
||||
@ -54,26 +54,24 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
hostKeys = resources.getStringArray(R.array.endpoints_keys)
|
||||
hostValues = resources.getStringArray(R.array.endpoints_values)
|
||||
hostKeys = resources.getStringArray(R.array.hosts_keys)
|
||||
hostValues = resources.getStringArray(R.array.hosts_values)
|
||||
|
||||
loginFormName.doOnTextChanged { _, _, _, _ -> presenter.onNameTextChanged() }
|
||||
loginFormPass.doOnTextChanged { _, _, _, _ -> presenter.onPassTextChanged() }
|
||||
loginFormHost.setOnItemClickListener { _, _, _, _ -> presenter.onHostSelected() }
|
||||
loginFormSignIn.setOnClickListener { presenter.onSignInClick() }
|
||||
loginFormPrivacyLink.setOnClickListener { presenter.onPrivacyLinkClick() }
|
||||
loginFormFaq.setOnClickListener { presenter.onFaqClick() }
|
||||
loginFormContactEmail.setOnClickListener { presenter.onEmailClick() }
|
||||
|
||||
loginFormPass.setOnEditorActionListener { _, id, _ ->
|
||||
if (id == IME_ACTION_DONE || id == IME_NULL) loginFormSignIn.callOnClick() else false
|
||||
}
|
||||
|
||||
with(loginFormHost) {
|
||||
//Bug with filter in ExposedDropdownMenu on restoring state
|
||||
isSaveEnabled = false
|
||||
|
||||
setText(hostKeys.getOrElse(0) { "" })
|
||||
setAdapter(ArrayAdapter(context, R.layout.support_simple_spinner_dropdown_item, hostKeys))
|
||||
keyListener = null
|
||||
setAdapter(LoginSymbolAdapter(context, R.layout.support_simple_spinner_dropdown_item, hostKeys))
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,8 +152,25 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
|
||||
context?.openInternetBrowser("https://wulkanowy.github.io/polityka-prywatnosci.html", ::showMessage)
|
||||
}
|
||||
|
||||
override fun showContact(show: Boolean) {
|
||||
loginFormContact.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
presenter.onDetachView()
|
||||
}
|
||||
|
||||
override fun openFaqPage() {
|
||||
context?.openInternetBrowser("https://wulkanowy.github.io/czesto-zadawane-pytania/dlaczego-nie-moge-sie-zalogowac", ::showMessage)
|
||||
}
|
||||
|
||||
override fun openEmail() {
|
||||
context?.openEmailClient(
|
||||
requireContext().getString(R.string.login_email_intent_title),
|
||||
"wulkanowyinc@gmail.com",
|
||||
requireContext().getString(R.string.login_email_subject),
|
||||
requireContext().getString(R.string.login_email_text, appInfo.systemModel, appInfo.systemVersion.toString(), appInfo.versionName)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ class LoginFormPresenter @Inject constructor(
|
||||
super.onAttachView(view)
|
||||
view.run {
|
||||
initView()
|
||||
showContact(false)
|
||||
if (appInfo.isDebug) showVersion() else showPrivacyPolicy()
|
||||
|
||||
loginErrorHandler.onBadCredentials = {
|
||||
@ -86,9 +87,18 @@ class LoginFormPresenter @Inject constructor(
|
||||
Timber.i("Login result: An exception occurred")
|
||||
analytics.logEvent("registration_form", "success" to false, "students" to -1, "endpoint" to endpoint, "error" to it.message.ifNullOrBlank { "No message" })
|
||||
loginErrorHandler.dispatch(it)
|
||||
view?.showContact(true)
|
||||
}))
|
||||
}
|
||||
|
||||
fun onFaqClick() {
|
||||
view?.openFaqPage()
|
||||
}
|
||||
|
||||
fun onEmailClick() {
|
||||
view?.openEmail()
|
||||
}
|
||||
|
||||
private fun validateCredentials(login: String, password: String): Boolean {
|
||||
var isCorrect = true
|
||||
|
||||
|
@ -42,4 +42,10 @@ interface LoginFormView : BaseView {
|
||||
fun notifyParentAccountLogged(students: List<Student>, loginData: Triple<String, String, String>)
|
||||
|
||||
fun openPrivacyPolicyPage()
|
||||
|
||||
fun showContact(show: Boolean)
|
||||
|
||||
fun openFaqPage()
|
||||
|
||||
fun openEmail()
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
package io.github.wulkanowy.ui.modules.login.form
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.Filter
|
||||
|
||||
class LoginSymbolAdapter(context: Context, resource: Int, objects: Array<out String>) :
|
||||
ArrayAdapter<String>(context, resource, objects) {
|
||||
|
||||
override fun getFilter() = object : Filter() {
|
||||
|
||||
override fun performFiltering(constraint: CharSequence?) = null
|
||||
|
||||
override fun publishResults(constraint: CharSequence?, results: FilterResults?) {}
|
||||
}
|
||||
}
|
@ -13,6 +13,9 @@ import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.modules.main.MainActivity
|
||||
import io.github.wulkanowy.utils.AppInfo
|
||||
import io.github.wulkanowy.utils.openEmailClient
|
||||
import io.github.wulkanowy.utils.openInternetBrowser
|
||||
import io.github.wulkanowy.utils.setOnItemClickListener
|
||||
import kotlinx.android.synthetic.main.fragment_login_student_select.*
|
||||
import java.io.Serializable
|
||||
@ -26,6 +29,9 @@ class LoginStudentSelectFragment : BaseFragment(), LoginStudentSelectView {
|
||||
@Inject
|
||||
lateinit var loginAdapter: FlexibleAdapter<AbstractFlexibleItem<*>>
|
||||
|
||||
@Inject
|
||||
lateinit var appInfo: AppInfo
|
||||
|
||||
companion object {
|
||||
const val SAVED_STUDENTS = "STUDENTS"
|
||||
|
||||
@ -44,6 +50,8 @@ class LoginStudentSelectFragment : BaseFragment(), LoginStudentSelectView {
|
||||
override fun initView() {
|
||||
loginStudentSelectSignIn.setOnClickListener { presenter.onSignIn() }
|
||||
loginAdapter.apply { setOnItemClickListener { presenter.onItemSelected(it) } }
|
||||
loginStudentSelectContactDiscord.setOnClickListener { presenter.onDiscordClick() }
|
||||
loginStudentSelectContactEmail.setOnClickListener { presenter.onEmailClick() }
|
||||
|
||||
loginStudentSelectRecycler.apply {
|
||||
adapter = loginAdapter
|
||||
@ -80,8 +88,25 @@ class LoginStudentSelectFragment : BaseFragment(), LoginStudentSelectView {
|
||||
outState.putSerializable(SAVED_STUDENTS, presenter.students as Serializable)
|
||||
}
|
||||
|
||||
override fun showContact(show: Boolean) {
|
||||
loginStudentSelectContact.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
presenter.onDetachView()
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
override fun openDiscordInvite() {
|
||||
context?.openInternetBrowser("https://discord.gg/vccAQBr", ::showMessage)
|
||||
}
|
||||
|
||||
override fun openEmail() {
|
||||
context?.openEmailClient(
|
||||
requireContext().getString(R.string.login_email_intent_title),
|
||||
"wulkanowyinc@gmail.com",
|
||||
requireContext().getString(R.string.login_email_subject),
|
||||
requireContext().getString(R.string.login_email_text, appInfo.systemModel, appInfo.systemVersion.toString(), appInfo.versionName)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ class LoginStudentSelectPresenter @Inject constructor(
|
||||
super.onAttachView(view)
|
||||
view.run {
|
||||
initView()
|
||||
showContact(false)
|
||||
enableSignIn(false)
|
||||
loginErrorHandler.onStudentDuplicate = {
|
||||
showMessage(it)
|
||||
@ -88,7 +89,16 @@ class LoginStudentSelectPresenter @Inject constructor(
|
||||
view?.apply {
|
||||
showProgress(false)
|
||||
showContent(true)
|
||||
showContact(true)
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
fun onDiscordClick() {
|
||||
view?.openDiscordInvite()
|
||||
}
|
||||
|
||||
fun onEmailClick() {
|
||||
view?.openEmail()
|
||||
}
|
||||
}
|
||||
|
@ -15,4 +15,10 @@ interface LoginStudentSelectView : BaseView {
|
||||
fun showContent(show: Boolean)
|
||||
|
||||
fun enableSignIn(enable: Boolean)
|
||||
|
||||
fun showContact(show: Boolean)
|
||||
|
||||
fun openDiscordInvite()
|
||||
|
||||
fun openEmail()
|
||||
}
|
||||
|
@ -14,7 +14,10 @@ import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.Student
|
||||
import io.github.wulkanowy.ui.base.BaseFragment
|
||||
import io.github.wulkanowy.ui.modules.login.LoginActivity
|
||||
import io.github.wulkanowy.utils.AppInfo
|
||||
import io.github.wulkanowy.utils.hideSoftInput
|
||||
import io.github.wulkanowy.utils.openEmailClient
|
||||
import io.github.wulkanowy.utils.openInternetBrowser
|
||||
import io.github.wulkanowy.utils.showSoftInput
|
||||
import kotlinx.android.synthetic.main.fragment_login_symbol.*
|
||||
import javax.inject.Inject
|
||||
@ -24,6 +27,9 @@ class LoginSymbolFragment : BaseFragment(), LoginSymbolView {
|
||||
@Inject
|
||||
lateinit var presenter: LoginSymbolPresenter
|
||||
|
||||
@Inject
|
||||
lateinit var appInfo: AppInfo
|
||||
|
||||
companion object {
|
||||
private const val SAVED_LOGIN_DATA = "LOGIN_DATA"
|
||||
|
||||
@ -44,6 +50,8 @@ class LoginSymbolFragment : BaseFragment(), LoginSymbolView {
|
||||
|
||||
override fun initView() {
|
||||
loginSymbolSignIn.setOnClickListener { presenter.attemptLogin(loginSymbolName.text.toString()) }
|
||||
loginSymbolFaq.setOnClickListener { presenter.onFaqClick() }
|
||||
loginSymbolContactEmail.setOnClickListener { presenter.onEmailClick() }
|
||||
|
||||
loginSymbolName.doOnTextChanged { _, _, _, _ -> presenter.onSymbolTextChanged() }
|
||||
|
||||
@ -109,8 +117,25 @@ class LoginSymbolFragment : BaseFragment(), LoginSymbolView {
|
||||
outState.putSerializable(SAVED_LOGIN_DATA, presenter.loginData)
|
||||
}
|
||||
|
||||
override fun showContact(show: Boolean) {
|
||||
loginSymbolContact.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
presenter.onDetachView()
|
||||
}
|
||||
|
||||
override fun openFaqPage() {
|
||||
context?.openInternetBrowser("https://wulkanowy.github.io/czesto-zadawane-pytania/co-to-jest-symbol", ::showMessage)
|
||||
}
|
||||
|
||||
override fun openEmail() {
|
||||
context?.openEmailClient(
|
||||
requireContext().getString(R.string.login_email_intent_title),
|
||||
"wulkanowyinc@gmail.com",
|
||||
requireContext().getString(R.string.login_email_subject),
|
||||
requireContext().getString(R.string.login_email_text, appInfo.systemModel, appInfo.systemVersion.toString(), appInfo.versionName)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,10 @@ class LoginSymbolPresenter @Inject constructor(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun onAttachView(view: LoginSymbolView, savedLoginData: Serializable?) {
|
||||
super.onAttachView(view)
|
||||
view.initView()
|
||||
view.run {
|
||||
initView()
|
||||
showContact(false)
|
||||
}
|
||||
if (savedLoginData is Triple<*, *, *>) {
|
||||
loginData = savedLoginData as Triple<String, String, String>
|
||||
}
|
||||
@ -64,6 +67,7 @@ class LoginSymbolPresenter @Inject constructor(
|
||||
if (it.isEmpty()) {
|
||||
Timber.i("Login with symbol result: Empty student list")
|
||||
setErrorSymbolIncorrect()
|
||||
view?.showContact(true)
|
||||
} else {
|
||||
Timber.i("Login with symbol result: Success")
|
||||
notifyParentAccountLogged(it)
|
||||
@ -73,6 +77,7 @@ class LoginSymbolPresenter @Inject constructor(
|
||||
Timber.i("Login with symbol result: An exception occurred")
|
||||
analytics.logEvent("registration_symbol", "success" to false, "students" to -1, "endpoint" to loginData?.third, "symbol" to symbol, "error" to it.message.ifNullOrBlank { "No message" })
|
||||
loginErrorHandler.dispatch(it)
|
||||
view?.showContact(true)
|
||||
}))
|
||||
}
|
||||
|
||||
@ -83,4 +88,12 @@ class LoginSymbolPresenter @Inject constructor(
|
||||
showSoftKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
fun onFaqClick() {
|
||||
view?.openFaqPage()
|
||||
}
|
||||
|
||||
fun onEmailClick() {
|
||||
view?.openEmail()
|
||||
}
|
||||
}
|
||||
|
@ -26,4 +26,10 @@ interface LoginSymbolView : BaseView {
|
||||
fun showContent(show: Boolean)
|
||||
|
||||
fun notifyParentAccountLogged(students: List<Student>)
|
||||
|
||||
fun showContact(show: Boolean)
|
||||
|
||||
fun openFaqPage()
|
||||
|
||||
fun openEmail()
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package io.github.wulkanowy.ui.modules.luckynumber
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.View.GONE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.ViewGroup
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.LuckyNumber
|
||||
@ -23,17 +25,22 @@ class LuckyNumberFragment : BaseFragment(), LuckyNumberView, MainView.TitledView
|
||||
override val titleStringId: Int
|
||||
get() = R.string.lucky_number_title
|
||||
|
||||
override val isViewEmpty get() = luckyNumberText.text.isBlank()
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.fragment_lucky_number, container, false)
|
||||
}
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
messageContainer = luckyNumberSwipe
|
||||
presenter.onAttachView(this)
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
luckyNumberSwipe.setOnRefreshListener { presenter.onSwipeRefresh() }
|
||||
luckyNumberErrorRetry.setOnClickListener { presenter.onRetry() }
|
||||
luckyNumberErrorDetails.setOnClickListener { presenter.onDetailsClick() }
|
||||
}
|
||||
|
||||
override fun updateData(data: LuckyNumber) {
|
||||
@ -45,11 +52,19 @@ class LuckyNumberFragment : BaseFragment(), LuckyNumberView, MainView.TitledView
|
||||
}
|
||||
|
||||
override fun showEmpty(show: Boolean) {
|
||||
luckyNumberEmpty.visibility = if (show) View.VISIBLE else View.GONE
|
||||
luckyNumberEmpty.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun showErrorView(show: Boolean) {
|
||||
luckyNumberError.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun setErrorDetails(message: String) {
|
||||
luckyNumberErrorMessage.text = message
|
||||
}
|
||||
|
||||
override fun showProgress(show: Boolean) {
|
||||
luckyNumberProgress.visibility = if (show) View.VISIBLE else View.GONE
|
||||
luckyNumberProgress.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun enableSwipe(enable: Boolean) {
|
||||
@ -57,11 +72,7 @@ class LuckyNumberFragment : BaseFragment(), LuckyNumberView, MainView.TitledView
|
||||
}
|
||||
|
||||
override fun showContent(show: Boolean) {
|
||||
luckyNumberContent.visibility = if (show) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
override fun isViewEmpty(): Boolean {
|
||||
return luckyNumberText.text.isBlank()
|
||||
luckyNumberContent.visibility = if (show) VISIBLE else GONE
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
@ -19,6 +19,8 @@ class LuckyNumberPresenter @Inject constructor(
|
||||
private val analytics: FirebaseAnalyticsHelper
|
||||
) : BasePresenter<LuckyNumberView>(errorHandler, studentRepository, schedulers) {
|
||||
|
||||
private lateinit var lastError: Throwable
|
||||
|
||||
override fun onAttachView(view: LuckyNumberView) {
|
||||
super.onAttachView(view)
|
||||
view.run {
|
||||
@ -27,6 +29,7 @@ class LuckyNumberPresenter @Inject constructor(
|
||||
enableSwipe(false)
|
||||
}
|
||||
Timber.i("Lucky number view was initialized")
|
||||
errorHandler.showErrorMessage = ::showErrorViewOnError
|
||||
loadData()
|
||||
}
|
||||
|
||||
@ -52,25 +55,49 @@ class LuckyNumberPresenter @Inject constructor(
|
||||
updateData(it)
|
||||
showContent(true)
|
||||
showEmpty(false)
|
||||
showErrorView(false)
|
||||
}
|
||||
analytics.logEvent("load_lucky_number", "lucky_number" to it.luckyNumber, "force_refresh" to forceRefresh)
|
||||
}, {
|
||||
Timber.i("Loading lucky number result: An exception occurred")
|
||||
view?.run { showEmpty(isViewEmpty()) }
|
||||
errorHandler.dispatch(it)
|
||||
}, {
|
||||
Timber.i("Loading lucky number result: No lucky number found")
|
||||
view?.run {
|
||||
showContent(false)
|
||||
showEmpty(true)
|
||||
showEmpty(false)
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun showErrorViewOnError(message: String, error: Throwable) {
|
||||
view?.run {
|
||||
if (isViewEmpty) {
|
||||
lastError = error
|
||||
setErrorDetails(message)
|
||||
showErrorView(true)
|
||||
showEmpty(false)
|
||||
} else showError(message, error)
|
||||
}
|
||||
}
|
||||
|
||||
fun onSwipeRefresh() {
|
||||
Timber.i("Force refreshing the lucky number")
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
fun onRetry() {
|
||||
view?.run {
|
||||
showErrorView(false)
|
||||
showProgress(true)
|
||||
}
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
fun onDetailsClick() {
|
||||
view?.showErrorDetailsDialog(lastError)
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import io.github.wulkanowy.ui.base.BaseView
|
||||
|
||||
interface LuckyNumberView : BaseView {
|
||||
|
||||
val isViewEmpty: Boolean
|
||||
|
||||
fun initView()
|
||||
|
||||
fun updateData(data: LuckyNumber)
|
||||
@ -13,11 +15,13 @@ interface LuckyNumberView : BaseView {
|
||||
|
||||
fun showEmpty(show: Boolean)
|
||||
|
||||
fun showErrorView(show: Boolean)
|
||||
|
||||
fun setErrorDetails(message: String)
|
||||
|
||||
fun showProgress(show: Boolean)
|
||||
|
||||
fun enableSwipe(enable: Boolean)
|
||||
|
||||
fun showContent(show: Boolean)
|
||||
|
||||
fun isViewEmpty(): Boolean
|
||||
}
|
||||
|
@ -58,7 +58,10 @@ class LuckyNumberWidgetConfigurePresenter @Inject constructor(
|
||||
.subscribe({
|
||||
when {
|
||||
it.isEmpty() -> view?.openLoginView()
|
||||
it.size == 1 -> registerStudent(it.single().student)
|
||||
it.size == 1 -> {
|
||||
selectedStudent = it.single().student
|
||||
view?.showThemeDialog()
|
||||
}
|
||||
else -> view?.updateData(it)
|
||||
}
|
||||
}, { errorHandler.dispatch(it) }))
|
||||
|
@ -100,7 +100,7 @@ class MainActivity : BaseActivity<MainPresenter>(), MainView {
|
||||
override fun initView() {
|
||||
with(mainToolbar) {
|
||||
if (SDK_INT >= LOLLIPOP) stateListAnimator = null
|
||||
setBackgroundColor(overlayProvider.get().getSurfaceColorWithOverlayIfNeeded(dpToPx(4f)))
|
||||
setBackgroundColor(overlayProvider.get().compositeOverlayWithThemeSurfaceColorIfNeeded(dpToPx(4f)))
|
||||
}
|
||||
|
||||
with(mainBottomNav) {
|
||||
@ -113,7 +113,7 @@ class MainActivity : BaseActivity<MainPresenter>(), MainView {
|
||||
))
|
||||
accentColor = getThemeAttrColor(R.attr.colorPrimary)
|
||||
inactiveColor = ColorUtils.setAlphaComponent(getThemeAttrColor(R.attr.colorOnSurface), 153)
|
||||
defaultBackgroundColor = overlayProvider.get().getSurfaceColorWithOverlayIfNeeded(dpToPx(8f))
|
||||
defaultBackgroundColor = overlayProvider.get().compositeOverlayWithThemeSurfaceColorIfNeeded(dpToPx(8f))
|
||||
titleState = ALWAYS_SHOW
|
||||
currentItem = startMenuIndex
|
||||
isBehaviorTranslationEnabled = false
|
||||
|
@ -26,26 +26,25 @@ import io.github.wulkanowy.ui.modules.mobiledevice.MobileDeviceModule
|
||||
import io.github.wulkanowy.ui.modules.mobiledevice.token.MobileDeviceTokenDialog
|
||||
import io.github.wulkanowy.ui.modules.more.MoreFragment
|
||||
import io.github.wulkanowy.ui.modules.note.NoteFragment
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersFragment
|
||||
import io.github.wulkanowy.ui.modules.schoolandteachers.SchoolAndTeachersModule
|
||||
import io.github.wulkanowy.ui.modules.settings.SettingsFragment
|
||||
import io.github.wulkanowy.ui.modules.teacher.TeacherFragment
|
||||
import io.github.wulkanowy.ui.modules.timetable.TimetableFragment
|
||||
import io.github.wulkanowy.ui.modules.timetable.completed.CompletedLessonsFragment
|
||||
|
||||
@Suppress("unused")
|
||||
@Module
|
||||
@Module(includes = [MainModule.Static::class])
|
||||
abstract class MainModule {
|
||||
|
||||
@Module
|
||||
companion object {
|
||||
object Static {
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
fun provideFragNavController(activity: MainActivity): FragNavController {
|
||||
return FragNavController(activity.supportFragmentManager, R.id.mainFragmentContainer)
|
||||
}
|
||||
|
||||
//In activities must be injected as Lazy
|
||||
@JvmStatic
|
||||
@Provides
|
||||
fun provideElevationOverlayProvider(activity: MainActivity) = ElevationOverlayProvider(activity)
|
||||
}
|
||||
@ -123,6 +122,6 @@ abstract class MainModule {
|
||||
abstract fun bindLicenseFragment(): LicenseFragment
|
||||
|
||||
@PerFragment
|
||||
@ContributesAndroidInjector
|
||||
abstract fun bindTeacherFragment(): TeacherFragment
|
||||
@ContributesAndroidInjector(modules = [SchoolAndTeachersModule::class])
|
||||
abstract fun bindSchoolAndTeachersFragment(): SchoolAndTeachersFragment
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import io.github.wulkanowy.ui.base.BasePresenter
|
||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import io.github.wulkanowy.ui.modules.main.MainView.Section.GRADE
|
||||
import io.github.wulkanowy.ui.modules.main.MainView.Section.MESSAGE
|
||||
import io.github.wulkanowy.ui.modules.main.MainView.Section.SCHOOL
|
||||
import io.github.wulkanowy.utils.FirebaseAnalyticsHelper
|
||||
import io.github.wulkanowy.utils.SchedulersProvider
|
||||
import timber.log.Timber
|
||||
@ -38,7 +39,7 @@ class MainPresenter @Inject constructor(
|
||||
|
||||
fun onViewChange(section: MainView.Section?) {
|
||||
view?.apply {
|
||||
showActionBarElevation(section != GRADE && section != MESSAGE)
|
||||
showActionBarElevation(section != GRADE && section != MESSAGE && section != SCHOOL)
|
||||
currentViewTitle?.let { setViewTitle(it) }
|
||||
currentStackSize?.let {
|
||||
if (it > 1) showHomeArrow(true)
|
||||
|
@ -51,6 +51,7 @@ interface MainView : BaseView {
|
||||
NOTE(7),
|
||||
LUCKY_NUMBER(8),
|
||||
SETTINGS(9),
|
||||
ABOUT(10)
|
||||
ABOUT(10),
|
||||
SCHOOL(11)
|
||||
}
|
||||
}
|
||||
|
@ -9,13 +9,12 @@ import io.github.wulkanowy.ui.base.BaseFragmentPagerAdapter
|
||||
import io.github.wulkanowy.ui.modules.message.tab.MessageTabFragment
|
||||
|
||||
@Suppress("unused")
|
||||
@Module
|
||||
@Module(includes = [MessageModule.Static::class])
|
||||
abstract class MessageModule {
|
||||
|
||||
@Module
|
||||
companion object {
|
||||
object Static {
|
||||
|
||||
@JvmStatic
|
||||
@PerFragment
|
||||
@Provides
|
||||
fun provideMessageAdapter(fragment: MessageFragment) = BaseFragmentPagerAdapter(fragment.childFragmentManager)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user