forked from github/wulkanowy-mirror
Add more logging (#219)
This commit is contained in:
parent
e6d60e670e
commit
c5bab52fa2
@ -15,6 +15,11 @@ class AboutPresenter @Inject constructor(
|
||||
private val analytics: FirebaseAnalyticsHelper
|
||||
) : BasePresenter<AboutView>(errorHandler) {
|
||||
|
||||
override fun onAttachView(view: AboutView) {
|
||||
super.onAttachView(view)
|
||||
Timber.i("About view is attached")
|
||||
}
|
||||
|
||||
fun onExtraSelect(type: Libs.SpecialButton?) {
|
||||
view?.run {
|
||||
when (type) {
|
||||
|
@ -6,6 +6,7 @@ import io.github.wulkanowy.ui.base.BasePresenter
|
||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import io.github.wulkanowy.utils.SchedulersProvider
|
||||
import io.reactivex.Single
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class AccountPresenter @Inject constructor(
|
||||
@ -16,19 +17,23 @@ class AccountPresenter @Inject constructor(
|
||||
|
||||
override fun onAttachView(view: AccountView) {
|
||||
super.onAttachView(view)
|
||||
Timber.i("Account dialog is attached")
|
||||
view.initView()
|
||||
loadData()
|
||||
}
|
||||
|
||||
fun onAddSelected() {
|
||||
Timber.i("Select add account")
|
||||
view?.openLoginView()
|
||||
}
|
||||
|
||||
fun onRemoveSelected() {
|
||||
Timber.i("Select remove account")
|
||||
view?.showConfirmDialog()
|
||||
}
|
||||
|
||||
fun onLogoutConfirm() {
|
||||
Timber.i("Attempt to logout current user ")
|
||||
disposable.add(studentRepository.getCurrentStudent()
|
||||
.flatMapCompletable { studentRepository.logoutStudent(it) }
|
||||
.andThen(studentRepository.getSavedStudents(false))
|
||||
@ -41,31 +46,54 @@ class AccountPresenter @Inject constructor(
|
||||
.doFinally { view?.dismissView() }
|
||||
.subscribe({
|
||||
view?.apply {
|
||||
if (it.isEmpty()) openClearLoginView()
|
||||
else recreateView()
|
||||
if (it.isEmpty()) {
|
||||
Timber.i("Logout result: Open login view")
|
||||
openClearLoginView()
|
||||
} else {
|
||||
Timber.i("Logout result: Switch to another student")
|
||||
recreateView()
|
||||
}
|
||||
}
|
||||
}, { errorHandler.dispatch(it) }))
|
||||
}, {
|
||||
Timber.i("Logout result: An exception occurred")
|
||||
errorHandler.dispatch(it)
|
||||
}))
|
||||
}
|
||||
|
||||
fun onItemSelected(item: AbstractFlexibleItem<*>) {
|
||||
if (item is AccountItem) {
|
||||
Timber.i("Select student item ${item.student.id}")
|
||||
if (item.student.isCurrent) {
|
||||
view?.dismissView()
|
||||
} else {
|
||||
Timber.i("Attempt to change a student")
|
||||
disposable.add(studentRepository.switchStudent(item.student)
|
||||
.subscribeOn(schedulers.backgroundThread)
|
||||
.observeOn(schedulers.mainThread)
|
||||
.subscribe({ view?.recreateView() }, { errorHandler.dispatch(it) }))
|
||||
.subscribe({
|
||||
Timber.i("Change a student result: Success")
|
||||
view?.recreateView()
|
||||
}, {
|
||||
Timber.i("Change a student result: An exception occurred")
|
||||
errorHandler.dispatch(it)
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadData() {
|
||||
Timber.i("Loading account data started")
|
||||
disposable.add(studentRepository.getSavedStudents(false)
|
||||
.map { it.map { item -> AccountItem(item) } }
|
||||
.subscribeOn(schedulers.backgroundThread)
|
||||
.observeOn(schedulers.mainThread)
|
||||
.subscribe({ view?.updateData(it) }, { errorHandler.dispatch(it) }))
|
||||
.subscribe({
|
||||
Timber.i("Loading account result: Success")
|
||||
view?.updateData(it)
|
||||
}, {
|
||||
Timber.i("Loading account result: An exception occurred")
|
||||
errorHandler.dispatch(it)
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ import io.github.wulkanowy.utils.toFormattedString
|
||||
import org.threeten.bp.LocalDate
|
||||
import org.threeten.bp.LocalDate.now
|
||||
import org.threeten.bp.LocalDate.ofEpochDay
|
||||
import timber.log.Timber
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -36,6 +37,7 @@ class AttendancePresenter @Inject constructor(
|
||||
|
||||
fun onAttachView(view: AttendanceView, date: Long?) {
|
||||
super.onAttachView(view)
|
||||
Timber.i("Attendance view is attached")
|
||||
view.initView()
|
||||
loadData(ofEpochDay(date ?: now().previousOrSameSchoolDay.toEpochDay()))
|
||||
reloadView()
|
||||
@ -52,10 +54,12 @@ class AttendancePresenter @Inject constructor(
|
||||
}
|
||||
|
||||
fun onSwipeRefresh() {
|
||||
Timber.i("Force refreshing the attendance")
|
||||
loadData(currentDate, true)
|
||||
}
|
||||
|
||||
fun onViewReselected() {
|
||||
Timber.i("Attendance view is reselected")
|
||||
view?.also { view ->
|
||||
if (view.currentStackSize == 1) {
|
||||
now().previousOrSameSchoolDay.also {
|
||||
@ -69,7 +73,10 @@ class AttendancePresenter @Inject constructor(
|
||||
}
|
||||
|
||||
fun onAttendanceItemSelected(item: AbstractFlexibleItem<*>?) {
|
||||
if (item is AttendanceItem) view?.showAttendanceDialog(item.attendance)
|
||||
if (item is AttendanceItem) {
|
||||
Timber.i("Select attendance item ${item.attendance.id}")
|
||||
view?.showAttendanceDialog(item.attendance)
|
||||
}
|
||||
}
|
||||
|
||||
fun onSummarySwitchSelected(): Boolean {
|
||||
@ -78,6 +85,7 @@ class AttendancePresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun loadData(date: LocalDate, forceRefresh: Boolean = false) {
|
||||
Timber.i("Loading attendance data started")
|
||||
currentDate = date
|
||||
disposable.apply {
|
||||
clear()
|
||||
@ -100,6 +108,7 @@ class AttendancePresenter @Inject constructor(
|
||||
}
|
||||
}
|
||||
.subscribe({
|
||||
Timber.i("Loading attendance result: Success")
|
||||
view?.apply {
|
||||
updateData(it)
|
||||
showEmpty(it.isEmpty())
|
||||
@ -107,6 +116,7 @@ class AttendancePresenter @Inject constructor(
|
||||
}
|
||||
analytics.logEvent("load_attendance", mapOf("items" to it.size, "force_refresh" to forceRefresh, START_DATE to currentDate.toFormattedString("yyyy-MM-dd")))
|
||||
}) {
|
||||
Timber.i("Loading attendance result: An exception occurred")
|
||||
view?.run { showEmpty(isViewEmpty) }
|
||||
errorHandler.dispatch(it)
|
||||
}
|
||||
@ -115,6 +125,7 @@ class AttendancePresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun reloadView() {
|
||||
Timber.i("Reload attendance view with the date ${currentDate.toFormattedString()}")
|
||||
view?.apply {
|
||||
showProgress(true)
|
||||
showContent(false)
|
||||
|
@ -12,6 +12,7 @@ import io.github.wulkanowy.utils.FirebaseAnalyticsHelper
|
||||
import io.github.wulkanowy.utils.SchedulersProvider
|
||||
import io.github.wulkanowy.utils.calculatePercentage
|
||||
import io.github.wulkanowy.utils.getFormattedName
|
||||
import timber.log.Timber
|
||||
import java.lang.String.format
|
||||
import java.util.Locale.FRANCE
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
@ -34,25 +35,31 @@ class AttendanceSummaryPresenter @Inject constructor(
|
||||
|
||||
fun onAttachView(view: AttendanceSummaryView, subjectId: Int?) {
|
||||
super.onAttachView(view)
|
||||
Timber.i("Attendance summary view is attached with subject id ${subjectId ?: -1}")
|
||||
view.initView()
|
||||
loadData(subjectId ?: -1)
|
||||
loadSubjects()
|
||||
}
|
||||
|
||||
fun onSwipeRefresh() {
|
||||
Timber.i("Force refreshing the attendance summary")
|
||||
loadData(currentSubjectId, true)
|
||||
}
|
||||
|
||||
fun onSubjectSelected(name: String) {
|
||||
Timber.i("Select attendance summary subject $name")
|
||||
view?.run {
|
||||
showContent(false)
|
||||
showProgress(true)
|
||||
clearView()
|
||||
}
|
||||
loadData(subjects.singleOrNull { it.name == name }?.realId ?: -1)
|
||||
(subjects.singleOrNull { it.name == name }?.realId ?: -1).let {
|
||||
if (it != currentSubjectId) loadData(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadData(subjectId: Int, forceRefresh: Boolean = false) {
|
||||
Timber.i("Loading attendance summary data started")
|
||||
currentSubjectId = subjectId
|
||||
disposable.apply {
|
||||
clear()
|
||||
@ -70,6 +77,7 @@ class AttendanceSummaryPresenter @Inject constructor(
|
||||
}
|
||||
}
|
||||
.subscribe({
|
||||
Timber.i("Loading attendance summary result: Success")
|
||||
view?.apply {
|
||||
showEmpty(it.first.isEmpty())
|
||||
showContent(it.first.isNotEmpty())
|
||||
@ -77,6 +85,7 @@ class AttendanceSummaryPresenter @Inject constructor(
|
||||
}
|
||||
analytics.logEvent("load_attendance_summary", mapOf("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)
|
||||
}
|
||||
@ -85,6 +94,7 @@ class AttendanceSummaryPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun loadSubjects() {
|
||||
Timber.i("Loading attendance summary subjects started")
|
||||
disposable.add(studentRepository.getCurrentStudent()
|
||||
.flatMap { semesterRepository.getCurrentSemester(it) }
|
||||
.flatMap { subjectRepository.getSubjects(it) }
|
||||
@ -93,11 +103,15 @@ class AttendanceSummaryPresenter @Inject constructor(
|
||||
.subscribeOn(schedulers.backgroundThread)
|
||||
.observeOn(schedulers.mainThread)
|
||||
.subscribe({
|
||||
Timber.i("Loading attendance summary subjects result: Success")
|
||||
view?.run {
|
||||
view?.updateSubjects(it)
|
||||
showSubjects(true)
|
||||
}
|
||||
}, { errorHandler.dispatch(it) })
|
||||
}, {
|
||||
Timber.i("Loading attendance summary subjects result: An exception occurred")
|
||||
errorHandler.dispatch(it)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ import io.github.wulkanowy.utils.toFormattedString
|
||||
import org.threeten.bp.LocalDate
|
||||
import org.threeten.bp.LocalDate.now
|
||||
import org.threeten.bp.LocalDate.ofEpochDay
|
||||
import timber.log.Timber
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -35,6 +36,7 @@ class ExamPresenter @Inject constructor(
|
||||
|
||||
fun onAttachView(view: ExamView, date: Long?) {
|
||||
super.onAttachView(view)
|
||||
Timber.i("Exam view is attached")
|
||||
view.initView()
|
||||
loadData(ofEpochDay(date ?: now().nextOrSameSchoolDay.toEpochDay()))
|
||||
reloadView()
|
||||
@ -51,14 +53,19 @@ class ExamPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
fun onSwipeRefresh() {
|
||||
Timber.i("Force refreshing the exam")
|
||||
loadData(currentDate, true)
|
||||
}
|
||||
|
||||
fun onExamItemSelected(item: AbstractFlexibleItem<*>?) {
|
||||
if (item is ExamItem) view?.showExamDialog(item.exam)
|
||||
if (item is ExamItem) {
|
||||
Timber.i("Select exam item ${item.exam.id}")
|
||||
view?.showExamDialog(item.exam)
|
||||
}
|
||||
}
|
||||
|
||||
fun onViewReselected() {
|
||||
Timber.i("Exam view is reselected")
|
||||
now().nextOrSameSchoolDay.also {
|
||||
if (currentDate != it) {
|
||||
loadData(it)
|
||||
@ -68,6 +75,7 @@ class ExamPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun loadData(date: LocalDate, forceRefresh: Boolean = false) {
|
||||
Timber.i("Loading exam data started")
|
||||
currentDate = date
|
||||
disposable.apply {
|
||||
clear()
|
||||
@ -87,6 +95,7 @@ class ExamPresenter @Inject constructor(
|
||||
}
|
||||
}
|
||||
.subscribe({
|
||||
Timber.i("Loading exam result: Success")
|
||||
view?.apply {
|
||||
updateData(it)
|
||||
showEmpty(it.isEmpty())
|
||||
@ -94,6 +103,7 @@ class ExamPresenter @Inject constructor(
|
||||
}
|
||||
analytics.logEvent("load_exam", mapOf("items" to it.size, "force_refresh" to forceRefresh, START_DATE to currentDate.toFormattedString("yyyy-MM-dd")))
|
||||
}) {
|
||||
Timber.i("Loading exam result: An exception occurred")
|
||||
view?.run { showEmpty(isViewEmpty) }
|
||||
errorHandler.dispatch(it)
|
||||
})
|
||||
@ -109,6 +119,7 @@ class ExamPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun reloadView() {
|
||||
Timber.i("Reload exam view with the date ${currentDate.toFormattedString()}")
|
||||
view?.apply {
|
||||
showProgress(true)
|
||||
showContent(false)
|
||||
|
@ -8,6 +8,7 @@ import io.github.wulkanowy.ui.base.session.SessionErrorHandler
|
||||
import io.github.wulkanowy.utils.FirebaseAnalyticsHelper
|
||||
import io.github.wulkanowy.utils.SchedulersProvider
|
||||
import io.reactivex.Completable
|
||||
import timber.log.Timber
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -28,6 +29,7 @@ class GradePresenter @Inject constructor(
|
||||
|
||||
fun onAttachView(view: GradeView, savedIndex: Int?) {
|
||||
super.onAttachView(view)
|
||||
Timber.i("Grade view is attached")
|
||||
disposable.add(Completable.timer(150, MILLISECONDS, schedulers.mainThread)
|
||||
.subscribe {
|
||||
selectedIndex = savedIndex ?: 0
|
||||
@ -37,6 +39,7 @@ class GradePresenter @Inject constructor(
|
||||
}
|
||||
|
||||
fun onViewReselected() {
|
||||
Timber.i("Grade view is reselected")
|
||||
view?.run { notifyChildParentReselected(currentPageIndex) }
|
||||
}
|
||||
|
||||
@ -47,6 +50,7 @@ class GradePresenter @Inject constructor(
|
||||
|
||||
fun onSemesterSelected(index: Int) {
|
||||
if (selectedIndex != index - 1) {
|
||||
Timber.i("Change semester in grade view to ${index + 1}")
|
||||
selectedIndex = index + 1
|
||||
loadedSemesterId.clear()
|
||||
view?.let {
|
||||
@ -74,6 +78,7 @@ class GradePresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun loadData() {
|
||||
Timber.i("Loading grade data started")
|
||||
disposable.add(studentRepository.getCurrentStudent()
|
||||
.flatMap { semesterRepository.getSemesters(it) }
|
||||
.doOnSuccess {
|
||||
@ -84,7 +89,13 @@ class GradePresenter @Inject constructor(
|
||||
}
|
||||
.subscribeOn(schedulers.backgroundThread)
|
||||
.observeOn(schedulers.mainThread)
|
||||
.subscribe({ view?.run { loadChild(currentPageIndex) } }) {
|
||||
.subscribe({
|
||||
view?.run {
|
||||
Timber.i("Loading grade result: Attempt load index $currentPageIndex")
|
||||
loadChild(currentPageIndex)
|
||||
}
|
||||
}) {
|
||||
Timber.i("Loading grade result: An exception occurred")
|
||||
errorHandler.dispatch(it)
|
||||
view?.run {
|
||||
showProgress(false)
|
||||
@ -96,6 +107,7 @@ class GradePresenter @Inject constructor(
|
||||
private fun loadChild(index: Int, forceRefresh: Boolean = false) {
|
||||
semesters.first { it.semesterName == selectedIndex }.semesterId.also {
|
||||
if (forceRefresh || loadedSemesterId[index] != it) {
|
||||
Timber.i("Load grade child view index: $index")
|
||||
view?.notifyChildLoadData(index, it, forceRefresh)
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ class GradeDetailsPresenter @Inject constructor(
|
||||
|
||||
fun onGradeItemSelected(item: AbstractFlexibleItem<*>?) {
|
||||
if (item is GradeDetailsItem) {
|
||||
Timber.i("Select grade item ${item.grade.id}")
|
||||
view?.apply {
|
||||
showGradeDialog(item.grade)
|
||||
if (!item.grade.isRead) {
|
||||
@ -58,18 +59,29 @@ class GradeDetailsPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
fun onMarkAsReadSelected(): Boolean {
|
||||
Timber.i("Select mark grades as read")
|
||||
disposable.add(studentRepository.getCurrentStudent()
|
||||
.flatMap { semesterRepository.getSemesters(it) }
|
||||
.flatMap { gradeRepository.getNewGrades(it.first { item -> item.semesterId == currentSemesterId }) }
|
||||
.map { it.map { grade -> grade.apply { isRead = true } } }
|
||||
.flatMapCompletable { gradeRepository.updateGrades(it) }
|
||||
.flatMapCompletable {
|
||||
Timber.i("Mark as read ${it.size} grades")
|
||||
gradeRepository.updateGrades(it)
|
||||
}
|
||||
.subscribeOn(schedulers.backgroundThread)
|
||||
.observeOn(schedulers.mainThread)
|
||||
.subscribe({ loadData(currentSemesterId, false) }, { errorHandler.dispatch(it) }))
|
||||
.subscribe({
|
||||
Timber.i("Mark as read result: Success")
|
||||
loadData(currentSemesterId, false)
|
||||
}, {
|
||||
Timber.i("Mark as read result: An exception occurred")
|
||||
errorHandler.dispatch(it)
|
||||
}))
|
||||
return true
|
||||
}
|
||||
|
||||
fun onSwipeRefresh() {
|
||||
Timber.i("Force refreshing the grade details")
|
||||
view?.notifyParentRefresh()
|
||||
}
|
||||
|
||||
@ -94,6 +106,7 @@ class GradeDetailsPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun loadData(semesterId: Int, forceRefresh: Boolean) {
|
||||
Timber.i("Loading grade details data started")
|
||||
disposable.add(studentRepository.getCurrentStudent()
|
||||
.flatMap { semesterRepository.getSemesters(it) }
|
||||
.flatMap { gradeRepository.getGrades(it.first { item -> item.semesterId == semesterId }, forceRefresh) }
|
||||
@ -110,6 +123,7 @@ class GradeDetailsPresenter @Inject constructor(
|
||||
}
|
||||
}
|
||||
.subscribe({
|
||||
Timber.i("Loading grade details result: Success")
|
||||
view?.run {
|
||||
showEmpty(it.isEmpty())
|
||||
showContent(it.isNotEmpty())
|
||||
@ -117,6 +131,7 @@ class GradeDetailsPresenter @Inject constructor(
|
||||
}
|
||||
analytics.logEvent("load_grade_details", mapOf("items" to it.size, "force_refresh" to forceRefresh))
|
||||
}) {
|
||||
Timber.i("Loading grade details result: An exception occurred")
|
||||
view?.run { showEmpty(isViewEmpty) }
|
||||
errorHandler.dispatch(it)
|
||||
})
|
||||
@ -152,10 +167,14 @@ class GradeDetailsPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun updateGrade(grade: Grade) {
|
||||
Timber.i("Attempt to update grade ${grade.id}")
|
||||
disposable.add(gradeRepository.updateGrade(grade)
|
||||
.subscribeOn(schedulers.backgroundThread)
|
||||
.observeOn(schedulers.mainThread)
|
||||
.subscribe({}) { error -> errorHandler.dispatch(error) })
|
||||
Timber.d("Grade ${grade.id} updated")
|
||||
.subscribe({ Timber.i("Update grade result: Success") })
|
||||
{ error ->
|
||||
Timber.i("Update grade result: An exception occurred")
|
||||
errorHandler.dispatch(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import io.github.wulkanowy.utils.FirebaseAnalyticsHelper
|
||||
import io.github.wulkanowy.utils.SchedulersProvider
|
||||
import io.github.wulkanowy.utils.calcAverage
|
||||
import io.github.wulkanowy.utils.changeModifier
|
||||
import timber.log.Timber
|
||||
import java.lang.String.format
|
||||
import java.util.Locale.FRANCE
|
||||
import javax.inject.Inject
|
||||
@ -33,6 +34,7 @@ class GradeSummaryPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
fun onParentViewLoadData(semesterId: Int, forceRefresh: Boolean) {
|
||||
Timber.i("Loading grade summary data started")
|
||||
disposable.add(studentRepository.getCurrentStudent()
|
||||
.flatMap { semesterRepository.getSemesters(it) }
|
||||
.map { semester -> semester.first { it.semesterId == semesterId } }
|
||||
@ -64,6 +66,7 @@ class GradeSummaryPresenter @Inject constructor(
|
||||
notifyParentDataLoaded(semesterId)
|
||||
}
|
||||
}.subscribe({
|
||||
Timber.i("Loading grade summary result: Success")
|
||||
view?.run {
|
||||
showEmpty(it.first.isEmpty())
|
||||
showContent(it.first.isNotEmpty())
|
||||
@ -71,12 +74,14 @@ class GradeSummaryPresenter @Inject constructor(
|
||||
}
|
||||
analytics.logEvent("load_grade_summary", mapOf("items" to it.first.size, "force_refresh" to forceRefresh))
|
||||
}) {
|
||||
Timber.i("Loading grade summary result: An exception occurred")
|
||||
view?.run { showEmpty(isViewEmpty) }
|
||||
errorHandler.dispatch(it)
|
||||
})
|
||||
}
|
||||
|
||||
fun onSwipeRefresh() {
|
||||
Timber.i("Force refreshing the grade summary")
|
||||
view?.notifyParentRefresh()
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ import io.github.wulkanowy.utils.nextSchoolDay
|
||||
import io.github.wulkanowy.utils.previousSchoolDay
|
||||
import io.github.wulkanowy.utils.toFormattedString
|
||||
import org.threeten.bp.LocalDate
|
||||
import timber.log.Timber
|
||||
import java.util.concurrent.TimeUnit
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -32,6 +33,7 @@ class HomeworkPresenter @Inject constructor(
|
||||
|
||||
fun onAttachView(view: HomeworkView, date: Long?) {
|
||||
super.onAttachView(view)
|
||||
Timber.i("Homework view is attached")
|
||||
view.initView()
|
||||
loadData(LocalDate.ofEpochDay(date ?: LocalDate.now().nextOrSameSchoolDay.toEpochDay()))
|
||||
reloadView()
|
||||
@ -48,14 +50,19 @@ class HomeworkPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
fun onSwipeRefresh() {
|
||||
Timber.i("Force refreshing the homework")
|
||||
loadData(currentDate, true)
|
||||
}
|
||||
|
||||
fun onHomeworkItemSelected(item: AbstractFlexibleItem<*>?) {
|
||||
if (item is HomeworkItem) view?.showTimetableDialog(item.homework)
|
||||
if (item is HomeworkItem) {
|
||||
Timber.i("Select homework item ${item.homework.id}")
|
||||
view?.showTimetableDialog(item.homework)
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadData(date: LocalDate, forceRefresh: Boolean = false) {
|
||||
Timber.i("Loading homework data started")
|
||||
currentDate = date
|
||||
disposable.apply {
|
||||
clear()
|
||||
@ -73,6 +80,7 @@ class HomeworkPresenter @Inject constructor(
|
||||
}
|
||||
}
|
||||
.subscribe({
|
||||
Timber.i("Loading homework result: Success")
|
||||
view?.apply {
|
||||
updateData(it)
|
||||
showEmpty(it.isEmpty())
|
||||
@ -80,6 +88,7 @@ class HomeworkPresenter @Inject constructor(
|
||||
}
|
||||
analytics.logEvent("load_homework", mapOf("items" to it.size, "force_refresh" to forceRefresh, START_DATE to currentDate.toFormattedString("yyyy-MM-dd")))
|
||||
}) {
|
||||
Timber.i("Loading homework result: An exception occurred")
|
||||
view?.run { showEmpty(isViewEmpty()) }
|
||||
errorHandler.dispatch(it)
|
||||
})
|
||||
@ -87,6 +96,7 @@ class HomeworkPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun reloadView() {
|
||||
Timber.i("Reload homework view with the date ${currentDate.toFormattedString()}")
|
||||
view?.apply {
|
||||
showProgress(true)
|
||||
showContent(false)
|
||||
|
@ -2,6 +2,7 @@ package io.github.wulkanowy.ui.modules.login
|
||||
|
||||
import io.github.wulkanowy.ui.base.BasePresenter
|
||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class LoginPresenter @Inject constructor(errorHandler: ErrorHandler) : BasePresenter<LoginView>(errorHandler) {
|
||||
@ -12,6 +13,7 @@ class LoginPresenter @Inject constructor(errorHandler: ErrorHandler) : BasePrese
|
||||
initAdapter()
|
||||
hideActionBar()
|
||||
}
|
||||
Timber.i("Login view is attached")
|
||||
}
|
||||
|
||||
fun onPageSelected(index: Int) {
|
||||
@ -23,6 +25,7 @@ class LoginPresenter @Inject constructor(errorHandler: ErrorHandler) : BasePrese
|
||||
}
|
||||
|
||||
fun onBackPressed(default: () -> Unit) {
|
||||
Timber.i("Back pressed in login view")
|
||||
view?.run {
|
||||
if (currentViewIndex == 1) {
|
||||
switchView(0)
|
||||
|
@ -45,6 +45,7 @@ class LoginFormPresenter @Inject constructor(
|
||||
showProgress(true)
|
||||
showContent(false)
|
||||
}
|
||||
Timber.i("Login started")
|
||||
}
|
||||
.doFinally {
|
||||
view?.apply {
|
||||
@ -58,17 +59,21 @@ class LoginFormPresenter @Inject constructor(
|
||||
showSymbolInput()
|
||||
wasEmpty = true
|
||||
analytics.logEvent("sign_up_send", mapOf(SUCCESS to false, "students" to 0, "endpoint" to endpoint, GROUP_ID to symbol.ifEmpty { "null" }))
|
||||
Timber.i("Login result: Empty student list")
|
||||
} else if (it.isEmpty() && wasEmpty) {
|
||||
showSymbolInput()
|
||||
setErrorSymbolIncorrect()
|
||||
analytics.logEvent("sign_up_send", mapOf(SUCCESS to false, "students" to it.size, "endpoint" to endpoint, GROUP_ID to symbol.ifEmpty { "nil" }))
|
||||
analytics.logEvent("sign_up_send", mapOf(SUCCESS to false, "students" to it.size, "endpoint" to endpoint, GROUP_ID to symbol.ifEmpty { "null" }))
|
||||
Timber.i("Login result: Wrong symbol")
|
||||
} else {
|
||||
analytics.logEvent("sign_up_send", mapOf(SUCCESS to true, "students" to it.size, "endpoint" to endpoint, GROUP_ID to symbol))
|
||||
Timber.i("Login result: Success")
|
||||
switchOptionsView()
|
||||
}
|
||||
}
|
||||
}, {
|
||||
analytics.logEvent(SIGN_UP, mapOf(SUCCESS to false, "endpoint" to endpoint, "message" to it.localizedMessage, GROUP_ID to symbol.ifEmpty { "nil" }))
|
||||
analytics.logEvent(SIGN_UP, mapOf(SUCCESS to false, "endpoint" to endpoint, "message" to it.localizedMessage, GROUP_ID to symbol.ifEmpty { "null" }))
|
||||
Timber.i("Login result: An exception occurred")
|
||||
errorHandler.dispatch(it)
|
||||
}))
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import io.github.wulkanowy.ui.modules.login.LoginErrorHandler
|
||||
import io.github.wulkanowy.utils.FirebaseAnalyticsHelper
|
||||
import io.github.wulkanowy.utils.SchedulersProvider
|
||||
import io.reactivex.Single
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class LoginOptionsPresenter @Inject constructor(
|
||||
@ -26,7 +27,10 @@ class LoginOptionsPresenter @Inject constructor(
|
||||
super.onAttachView(view)
|
||||
view.run {
|
||||
initView()
|
||||
errorHandler.onStudentDuplicate = { showMessage(it) }
|
||||
errorHandler.onStudentDuplicate = {
|
||||
showMessage(it)
|
||||
Timber.i("The student already registered in the app was selected")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,11 +62,14 @@ class LoginOptionsPresenter @Inject constructor(
|
||||
showContent(false)
|
||||
showActionBar(false)
|
||||
}
|
||||
Timber.i("Registration started")
|
||||
}
|
||||
.subscribe({
|
||||
analytics.logEvent(SIGN_UP, mapOf(SUCCESS to true, "endpoint" to student.endpoint, "message" to "Success", GROUP_ID to student.symbol))
|
||||
Timber.i("Registration result: Success")
|
||||
view?.openMainView()
|
||||
}, {
|
||||
Timber.i("Registration result: An exception occurred ")
|
||||
errorHandler.dispatch(it)
|
||||
view?.apply {
|
||||
showProgress(false)
|
||||
|
@ -71,7 +71,7 @@ class MainActivity : BaseActivity(), MainView {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
presenter.onViewStart()
|
||||
presenter.onViewChange()
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
@ -98,7 +98,7 @@ class MainActivity : BaseActivity(), MainView {
|
||||
}
|
||||
|
||||
navController.run {
|
||||
setOnViewChangeListener { presenter.onViewStart() }
|
||||
setOnViewChangeListener { presenter.onViewChange() }
|
||||
fragmentHideStrategy = HIDE
|
||||
rootFragments = listOf(
|
||||
GradeFragment.newInstance(),
|
||||
|
@ -10,6 +10,7 @@ import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import io.github.wulkanowy.utils.FirebaseAnalyticsHelper
|
||||
import io.github.wulkanowy.utils.SchedulersProvider
|
||||
import io.reactivex.Completable
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class MainPresenter @Inject constructor(
|
||||
@ -23,6 +24,7 @@ class MainPresenter @Inject constructor(
|
||||
|
||||
fun onAttachView(view: MainView, initMenuIndex: Int) {
|
||||
super.onAttachView(view)
|
||||
Timber.i("Main view is attached with $initMenuIndex menu index")
|
||||
view.run {
|
||||
cancelNotifications()
|
||||
startMenuIndex = if (initMenuIndex != -1) initMenuIndex else prefRepository.startMenuIndex
|
||||
@ -38,7 +40,7 @@ class MainPresenter @Inject constructor(
|
||||
}))
|
||||
}
|
||||
|
||||
fun onViewStart() {
|
||||
fun onViewChange() {
|
||||
view?.apply {
|
||||
currentViewTitle?.let { setViewTitle(it) }
|
||||
currentStackSize?.let {
|
||||
@ -49,16 +51,19 @@ class MainPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
fun onAccountManagerSelected(): Boolean {
|
||||
Timber.i("Select account manager")
|
||||
view?.showAccountPicker()
|
||||
return true
|
||||
}
|
||||
|
||||
fun onUpNavigate(): Boolean {
|
||||
Timber.i("Up navigate pressed")
|
||||
view?.popView()
|
||||
return true
|
||||
}
|
||||
|
||||
fun onBackPressed(default: () -> Unit) {
|
||||
Timber.i("Back pressed in main view")
|
||||
view?.run {
|
||||
if (isRootView) default()
|
||||
else popView()
|
||||
@ -67,6 +72,7 @@ class MainPresenter @Inject constructor(
|
||||
|
||||
fun onTabSelected(index: Int, wasSelected: Boolean): Boolean {
|
||||
return view?.run {
|
||||
Timber.i("Switch main tab index: $index, reselected: $wasSelected")
|
||||
if (wasSelected) {
|
||||
notifyMenuViewReselected()
|
||||
false
|
||||
@ -78,15 +84,25 @@ class MainPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
fun onLoginSelected() {
|
||||
Timber.i("Attempt to switch the student after the session expires")
|
||||
disposable.add(studentRepository.getCurrentStudent(false)
|
||||
.flatMapCompletable { studentRepository.logoutStudent(it) }
|
||||
.andThen(studentRepository.getSavedStudents(false))
|
||||
.flatMapCompletable {
|
||||
if (it.isNotEmpty()) studentRepository.switchStudent(it[0])
|
||||
if (it.isNotEmpty()) {
|
||||
Timber.i("Switching current student")
|
||||
studentRepository.switchStudent(it[0])
|
||||
}
|
||||
else Completable.complete()
|
||||
}
|
||||
.subscribeOn(schedulers.backgroundThread)
|
||||
.observeOn(schedulers.mainThread)
|
||||
.subscribe({ view?.openLoginView() }, { errorHandler.dispatch(it) }))
|
||||
.subscribe({
|
||||
Timber.i("Switch student result: Open login view")
|
||||
view?.openLoginView()
|
||||
}, {
|
||||
Timber.i("Switch student result: An exception occurred")
|
||||
errorHandler.dispatch(it)
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import io.github.wulkanowy.ui.base.BasePresenter
|
||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import io.github.wulkanowy.utils.SchedulersProvider
|
||||
import io.reactivex.Completable
|
||||
import timber.log.Timber
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -14,6 +15,7 @@ class MessagePresenter @Inject constructor(
|
||||
|
||||
override fun onAttachView(view: MessageView) {
|
||||
super.onAttachView(view)
|
||||
Timber.i("Message view is attached")
|
||||
disposable.add(Completable.timer(150, MILLISECONDS, schedulers.mainThread)
|
||||
.subscribe {
|
||||
view.initView()
|
||||
@ -30,6 +32,7 @@ class MessagePresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun loadChild(index: Int, forceRefresh: Boolean = false) {
|
||||
Timber.i("Load message child view index: $index")
|
||||
view?.notifyChildLoadData(index, forceRefresh)
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import io.github.wulkanowy.ui.base.session.SessionErrorHandler
|
||||
import io.github.wulkanowy.utils.FirebaseAnalyticsHelper
|
||||
import io.github.wulkanowy.utils.SchedulersProvider
|
||||
import io.github.wulkanowy.utils.toFormattedString
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class MessagePreviewPresenter @Inject constructor(
|
||||
@ -26,6 +27,7 @@ class MessagePreviewPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun loadData(id: Int) {
|
||||
Timber.i("Loading message $id preview started")
|
||||
messageId = id
|
||||
disposable.apply {
|
||||
clear()
|
||||
@ -35,6 +37,7 @@ class MessagePreviewPresenter @Inject constructor(
|
||||
.observeOn(schedulers.mainThread)
|
||||
.doFinally { view?.showProgress(false) }
|
||||
.subscribe({ message ->
|
||||
Timber.i("Loading message $id preview result: Success ")
|
||||
view?.run {
|
||||
message.let {
|
||||
setSubject(if (it.subject.isNotBlank()) it.subject else noSubjectString)
|
||||
@ -45,8 +48,9 @@ class MessagePreviewPresenter @Inject constructor(
|
||||
else setSender(it.sender)
|
||||
}
|
||||
}
|
||||
analytics.logEvent("load_attendance", mapOf(START_DATE to message.date?.toFormattedString("yyyy.MM.dd"), "lenght" to message.content?.length))
|
||||
analytics.logEvent("load_message_preview", mapOf(START_DATE to message.date?.toFormattedString("yyyy.MM.dd"), "lenght" to message.content?.length))
|
||||
}) {
|
||||
Timber.i("Loading message $id preview result: An excception occurred ")
|
||||
view?.showMessageError()
|
||||
errorHandler.dispatch(it)
|
||||
})
|
||||
|
@ -29,10 +29,12 @@ class MessageTabPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
fun onSwipeRefresh() {
|
||||
Timber.i("Force refreshing the $folder message")
|
||||
onParentViewLoadData(true)
|
||||
}
|
||||
|
||||
fun onParentViewLoadData(forceRefresh: Boolean) {
|
||||
Timber.i("Loading $folder message data started")
|
||||
disposable.apply {
|
||||
clear()
|
||||
add(studentRepository.getCurrentStudent()
|
||||
@ -48,6 +50,7 @@ class MessageTabPresenter @Inject constructor(
|
||||
}
|
||||
}
|
||||
.subscribe({
|
||||
Timber.i("Loading $folder message result: Success")
|
||||
view?.run {
|
||||
showEmpty(it.isEmpty())
|
||||
showContent(it.isNotEmpty())
|
||||
@ -55,6 +58,7 @@ class MessageTabPresenter @Inject constructor(
|
||||
}
|
||||
analytics.logEvent("load_messages", mapOf("items" to it.size, "folder" to folder.name))
|
||||
}) {
|
||||
Timber.i("Loading $folder message result: An exception occurred")
|
||||
view?.run { showEmpty(isViewEmpty) }
|
||||
errorHandler.dispatch(it)
|
||||
})
|
||||
@ -63,6 +67,7 @@ class MessageTabPresenter @Inject constructor(
|
||||
|
||||
fun onMessageItemSelected(item: AbstractFlexibleItem<*>) {
|
||||
if (item is MessageItem) {
|
||||
Timber.i("Select message ${item.message.realId} item")
|
||||
view?.run {
|
||||
openMessage(item.message.realId)
|
||||
if (item.message.unread == true) {
|
||||
@ -75,12 +80,14 @@ class MessageTabPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun updateMessage(message: Message) {
|
||||
Timber.i("Attempt to update message ${message.realId}")
|
||||
disposable.add(messagesRepository.updateMessage(message)
|
||||
.subscribeOn(schedulers.backgroundThread)
|
||||
.observeOn(schedulers.mainThread)
|
||||
.subscribe({
|
||||
Timber.d("Message ${message.realId} updated")
|
||||
}) { error -> errorHandler.dispatch(error) }
|
||||
)
|
||||
.subscribe({ Timber.d("Update message ${message.realId} result: Success") })
|
||||
{ error ->
|
||||
Timber.i("Update message ${message.realId} result: An exception occurred")
|
||||
errorHandler.dispatch(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -3,18 +3,21 @@ package io.github.wulkanowy.ui.modules.more
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||
import io.github.wulkanowy.ui.base.BasePresenter
|
||||
import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class MorePresenter @Inject constructor(errorHandler: ErrorHandler) : BasePresenter<MoreView>(errorHandler) {
|
||||
|
||||
override fun onAttachView(view: MoreView) {
|
||||
super.onAttachView(view)
|
||||
Timber.i("More view is attached")
|
||||
view.initView()
|
||||
loadData()
|
||||
}
|
||||
|
||||
fun onItemSelected(item: AbstractFlexibleItem<*>?) {
|
||||
if (item is MoreItem) {
|
||||
Timber.i("Select more item \"${item.title}\"")
|
||||
view?.run {
|
||||
when (item.title) {
|
||||
messagesRes?.first -> openMessagesView()
|
||||
@ -28,10 +31,12 @@ class MorePresenter @Inject constructor(errorHandler: ErrorHandler) : BasePresen
|
||||
}
|
||||
|
||||
fun onViewReselected() {
|
||||
Timber.i("More view is reselected")
|
||||
view?.popView()
|
||||
}
|
||||
|
||||
private fun loadData() {
|
||||
Timber.i("Load items for more view")
|
||||
view?.run {
|
||||
updateData(listOfNotNull(
|
||||
messagesRes?.let { MoreItem(it.first, it.second) },
|
||||
|
@ -23,15 +23,18 @@ class NotePresenter @Inject constructor(
|
||||
|
||||
override fun onAttachView(view: NoteView) {
|
||||
super.onAttachView(view)
|
||||
Timber.i("Note view is attached")
|
||||
view.initView()
|
||||
loadData()
|
||||
}
|
||||
|
||||
fun onSwipeRefresh() {
|
||||
Timber.i("Force refreshing the note")
|
||||
loadData(true)
|
||||
}
|
||||
|
||||
private fun loadData(forceRefresh: Boolean = false) {
|
||||
Timber.i("Loading note data started")
|
||||
disposable.add(studentRepository.getCurrentStudent()
|
||||
.flatMap { semesterRepository.getCurrentSemester(it) }
|
||||
.flatMap { noteRepository.getNotes(it, forceRefresh) }
|
||||
@ -45,6 +48,7 @@ class NotePresenter @Inject constructor(
|
||||
showProgress(false)
|
||||
}
|
||||
}.subscribe({
|
||||
Timber.i("Loading note result: Success")
|
||||
view?.apply {
|
||||
updateData(it)
|
||||
showEmpty(it.isEmpty())
|
||||
@ -52,6 +56,7 @@ class NotePresenter @Inject constructor(
|
||||
}
|
||||
analytics.logEvent("load_note", mapOf("items" to it.size, "force_refresh" to forceRefresh))
|
||||
}, {
|
||||
Timber.i("Loading note result: An exception occurred")
|
||||
view?.run { showEmpty(isViewEmpty) }
|
||||
errorHandler.dispatch(it)
|
||||
})
|
||||
@ -60,6 +65,7 @@ class NotePresenter @Inject constructor(
|
||||
|
||||
fun onNoteItemSelected(item: AbstractFlexibleItem<*>?) {
|
||||
if (item is NoteItem) {
|
||||
Timber.i("Select note item ${item.note.id}")
|
||||
view?.run {
|
||||
showNoteDialog(item.note)
|
||||
if (!item.note.isRead) {
|
||||
@ -72,12 +78,14 @@ class NotePresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun updateNote(note: Note) {
|
||||
Timber.i("Attempt to update note ${note.id}")
|
||||
disposable.add(noteRepository.updateNote(note)
|
||||
.subscribeOn(schedulers.backgroundThread)
|
||||
.observeOn(schedulers.mainThread)
|
||||
.subscribe({
|
||||
Timber.d("Note ${note.id} updated")
|
||||
}) { error -> errorHandler.dispatch(error) }
|
||||
)
|
||||
.subscribe({ Timber.i("Update note result: Success") })
|
||||
{ error ->
|
||||
Timber.i("Update note result: An exception occurred")
|
||||
errorHandler.dispatch(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.github.wulkanowy.ui.modules.settings
|
||||
|
||||
import com.readystatesoftware.chuck.api.ChuckCollector
|
||||
import io.github.wulkanowy.data.RepositoryModule_ProvideChuckCollectorFactory
|
||||
import io.github.wulkanowy.data.repositories.PreferencesRepository
|
||||
import io.github.wulkanowy.services.job.ServiceHelper
|
||||
import io.github.wulkanowy.ui.base.BasePresenter
|
||||
@ -9,6 +8,7 @@ import io.github.wulkanowy.ui.base.ErrorHandler
|
||||
import io.github.wulkanowy.utils.FirebaseAnalyticsHelper
|
||||
import io.github.wulkanowy.utils.isHolidays
|
||||
import org.threeten.bp.LocalDate.now
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class SettingsPresenter @Inject constructor(
|
||||
@ -21,6 +21,7 @@ class SettingsPresenter @Inject constructor(
|
||||
|
||||
override fun onAttachView(view: SettingsView) {
|
||||
super.onAttachView(view)
|
||||
Timber.i("Settings view is attached")
|
||||
|
||||
view.run {
|
||||
setServicesSuspended(preferencesRepository.serviceEnablesKey, now().isHolidays)
|
||||
@ -28,6 +29,7 @@ class SettingsPresenter @Inject constructor(
|
||||
}
|
||||
|
||||
fun onSharedPreferenceChanged(key: String) {
|
||||
Timber.i("Change settings $key")
|
||||
when (key) {
|
||||
preferencesRepository.serviceEnablesKey -> {
|
||||
if (preferencesRepository.isServiceEnabled) serviceHelper.startFullSyncService()
|
||||
@ -44,7 +46,6 @@ class SettingsPresenter @Inject constructor(
|
||||
chuckCollector.showNotification(preferencesRepository.isShowChuckerNotification)
|
||||
}
|
||||
}
|
||||
|
||||
analytics.logEvent("setting_changed", mapOf("name" to key))
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import io.github.wulkanowy.utils.toFormattedString
|
||||
import org.threeten.bp.LocalDate
|
||||
import org.threeten.bp.LocalDate.now
|
||||
import org.threeten.bp.LocalDate.ofEpochDay
|
||||
import timber.log.Timber
|
||||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -34,6 +35,7 @@ class TimetablePresenter @Inject constructor(
|
||||
|
||||
fun onAttachView(view: TimetableView, date: Long?) {
|
||||
super.onAttachView(view)
|
||||
Timber.i("Timetable is attached")
|
||||
view.initView()
|
||||
loadData(ofEpochDay(date ?: now().nextOrSameSchoolDay.toEpochDay()))
|
||||
reloadView()
|
||||
@ -50,10 +52,12 @@ class TimetablePresenter @Inject constructor(
|
||||
}
|
||||
|
||||
fun onSwipeRefresh() {
|
||||
Timber.i("Force refreshing the timetable")
|
||||
loadData(currentDate, true)
|
||||
}
|
||||
|
||||
fun onViewReselected() {
|
||||
Timber.i("Exam view is reselected")
|
||||
now().nextOrSameSchoolDay.also {
|
||||
if (currentDate != it) {
|
||||
loadData(it)
|
||||
@ -63,10 +67,14 @@ class TimetablePresenter @Inject constructor(
|
||||
}
|
||||
|
||||
fun onTimetableItemSelected(item: AbstractFlexibleItem<*>?) {
|
||||
if (item is TimetableItem) view?.showTimetableDialog(item.lesson)
|
||||
if (item is TimetableItem) {
|
||||
Timber.i("Select exam item ${item.lesson.id}")
|
||||
view?.showTimetableDialog(item.lesson)
|
||||
}
|
||||
}
|
||||
|
||||
private fun loadData(date: LocalDate, forceRefresh: Boolean = false) {
|
||||
Timber.i("Loading timetable data started")
|
||||
currentDate = date
|
||||
disposable.apply {
|
||||
clear()
|
||||
@ -85,13 +93,15 @@ class TimetablePresenter @Inject constructor(
|
||||
}
|
||||
}
|
||||
.subscribe({
|
||||
Timber.i("Loading timetable result: Success")
|
||||
view?.apply {
|
||||
updateData(it)
|
||||
showEmpty(it.isEmpty())
|
||||
showContent(it.isNotEmpty())
|
||||
}
|
||||
analytics.logEvent("load_attendance", mapOf("items" to it.size, "force_refresh" to forceRefresh, START_DATE to currentDate.toFormattedString("yyyy-MM-dd")))
|
||||
analytics.logEvent("load_timetable", mapOf("items" to it.size, "force_refresh" to forceRefresh, START_DATE to currentDate.toFormattedString("yyyy-MM-dd")))
|
||||
}) {
|
||||
Timber.i("Loading timetable result: An exception occurred")
|
||||
view?.run { showEmpty(isViewEmpty) }
|
||||
errorHandler.dispatch(it)
|
||||
})
|
||||
@ -99,6 +109,7 @@ class TimetablePresenter @Inject constructor(
|
||||
}
|
||||
|
||||
private fun reloadView() {
|
||||
Timber.i("Reload timetable view with the date ${currentDate.toFormattedString()}")
|
||||
view?.apply {
|
||||
showProgress(true)
|
||||
showContent(false)
|
||||
|
Loading…
x
Reference in New Issue
Block a user