Cleanup and document DefaultInitialSyncProgressService

This commit is contained in:
Benoit Marty 2019-09-05 17:23:09 +02:00
parent 38da4b9ee5
commit a5975a099e
3 changed files with 8 additions and 13 deletions

View File

@ -20,10 +20,10 @@ import androidx.lifecycle.LiveData


interface InitialSyncProgressService { interface InitialSyncProgressService {


fun getLiveStatus() : LiveData<Status?> fun getInitialSyncProgressStatus() : LiveData<Status?>


data class Status( data class Status(
@StringRes val statusText: Int?, @StringRes val statusText: Int,
val percentProgress: Int = 0 val percentProgress: Int = 0
) )
} }

View File

@ -30,7 +30,7 @@ class DefaultInitialSyncProgressService @Inject constructor() : InitialSyncProgr


private var rootTask: TaskInfo? = null private var rootTask: TaskInfo? = null


override fun getLiveStatus(): LiveData<InitialSyncProgressService.Status?> { override fun getInitialSyncProgressStatus(): LiveData<InitialSyncProgressService.Status?> {
return status return status
} }



View File

@ -26,7 +26,6 @@ import androidx.appcompat.widget.Toolbar
import androidx.core.view.GravityCompat import androidx.core.view.GravityCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.drawerlayout.widget.DrawerLayout import androidx.drawerlayout.widget.DrawerLayout
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders import androidx.lifecycle.ViewModelProviders
import com.airbnb.mvrx.viewModel import com.airbnb.mvrx.viewModel
@ -36,12 +35,10 @@ import im.vector.riotx.core.di.ScreenComponent
import im.vector.riotx.core.extensions.hideKeyboard import im.vector.riotx.core.extensions.hideKeyboard
import im.vector.riotx.core.extensions.observeEvent import im.vector.riotx.core.extensions.observeEvent
import im.vector.riotx.core.extensions.replaceFragment import im.vector.riotx.core.extensions.replaceFragment
import im.vector.riotx.core.platform.OnBackPressed
import im.vector.riotx.core.platform.ToolbarConfigurable import im.vector.riotx.core.platform.ToolbarConfigurable
import im.vector.riotx.core.platform.VectorBaseActivity import im.vector.riotx.core.platform.VectorBaseActivity
import im.vector.riotx.core.pushers.PushersManager import im.vector.riotx.core.pushers.PushersManager
import im.vector.riotx.features.disclaimer.showDisclaimerDialog import im.vector.riotx.features.disclaimer.showDisclaimerDialog
import im.vector.riotx.features.navigation.Navigator
import im.vector.riotx.features.notifications.NotificationDrawerManager import im.vector.riotx.features.notifications.NotificationDrawerManager
import im.vector.riotx.features.rageshake.VectorUncaughtExceptionHandler import im.vector.riotx.features.rageshake.VectorUncaughtExceptionHandler
import im.vector.riotx.features.workers.signout.SignOutViewModel import im.vector.riotx.features.workers.signout.SignOutViewModel
@ -119,22 +116,22 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable {
intent.removeExtra(EXTRA_CLEAR_EXISTING_NOTIFICATION) intent.removeExtra(EXTRA_CLEAR_EXISTING_NOTIFICATION)
} }


activeSessionHolder.getSafeActiveSession()?.getLiveStatus()?.observe(this, Observer { sprogress -> activeSessionHolder.getSafeActiveSession()?.getInitialSyncProgressStatus()?.observe(this, Observer { status ->
Timber.e("${sprogress?.statusText?.let { getString(it) }} ${sprogress?.percentProgress}") if (status == null) {
if (sprogress == null) {
waiting_view.isVisible = false waiting_view.isVisible = false
} else { } else {
Timber.e("${getString(status.statusText)} ${status.percentProgress}")
waiting_view.setOnClickListener { waiting_view.setOnClickListener {
//block interactions //block interactions
} }
waiting_view_status_horizontal_progress.apply { waiting_view_status_horizontal_progress.apply {
isIndeterminate = false isIndeterminate = false
max = 100 max = 100
progress = sprogress.percentProgress progress = status.percentProgress
isVisible = true isVisible = true
} }
waiting_view_status_text.apply { waiting_view_status_text.apply {
text = sprogress.statusText?.let { getString(it) } text = getString(status.statusText)
isVisible = true isVisible = true
} }
waiting_view.isVisible = true waiting_view.isVisible = true
@ -213,8 +210,6 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable {
} }






companion object { companion object {
private const val EXTRA_CLEAR_EXISTING_NOTIFICATION = "EXTRA_CLEAR_EXISTING_NOTIFICATION" private const val EXTRA_CLEAR_EXISTING_NOTIFICATION = "EXTRA_CLEAR_EXISTING_NOTIFICATION"