1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2025-01-18 21:26:48 -06:00

Add lucky number logging (#256)

This commit is contained in:
Kacper Ziubryniewicz 2019-02-24 19:23:03 +01:00 committed by Mikołaj Pich
parent c72c301039
commit f8ee5cb062
2 changed files with 9 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import io.github.wulkanowy.ui.base.BasePresenter
import io.github.wulkanowy.ui.base.session.SessionErrorHandler
import io.github.wulkanowy.utils.FirebaseAnalyticsHelper
import io.github.wulkanowy.utils.SchedulersProvider
import timber.log.Timber
import javax.inject.Inject
class LuckyNumberPresenter @Inject constructor(
@ -20,11 +21,13 @@ class LuckyNumberPresenter @Inject constructor(
override fun onAttachView(view: LuckyNumberView) {
super.onAttachView(view)
Timber.i("Lucky number view is attached")
view.initView()
loadData()
}
private fun loadData(forceRefresh: Boolean = false) {
Timber.i("Loading lucky number started")
disposable.apply {
clear()
add(studentRepository.getCurrentStudent()
@ -39,6 +42,7 @@ class LuckyNumberPresenter @Inject constructor(
}
}
.subscribe({
Timber.i("Loading lucky number result: Success")
view?.apply {
updateData(it)
showContent(true)
@ -46,9 +50,11 @@ class LuckyNumberPresenter @Inject constructor(
}
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)
@ -59,6 +65,7 @@ class LuckyNumberPresenter @Inject constructor(
}
fun onSwipeRefresh() {
Timber.i("Force refreshing the lucky number")
loadData(true)
}
}

View File

@ -28,8 +28,8 @@ class SendMessagePresenter @Inject constructor(
private lateinit var reportingUnit: ReportingUnit
override fun onAttachView(view: SendMessageView) {
Timber.i("Send message view is attached")
super.onAttachView(view)
Timber.i("Send message view is attached")
view.run {
initView()
showBottomNav(false)
@ -60,13 +60,13 @@ class SendMessagePresenter @Inject constructor(
}
}
.subscribe({
Timber.i("Loading recipients result: Success, fetched %s recipients", it.size.toString())
view?.apply {
setReportingUnit(reportingUnit)
setRecipients(it)
refreshRecipientsAdapter()
showContent(true)
}
Timber.i("Loading recipients result: Success, fetched %s recipients", it.size.toString())
}, {
Timber.i("Loading recipients result: An exception occurred")
view?.showContent(true)