From a5975a099efe833f0050e49d3986224fefc08f1c Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 5 Sep 2019 17:23:09 +0200 Subject: [PATCH] Cleanup and document DefaultInitialSyncProgressService --- .../api/session/InitialSyncProgressService.kt | 4 ++-- .../session/DefaultInitialSyncProgressService.kt | 2 +- .../im/vector/riotx/features/home/HomeActivity.kt | 15 +++++---------- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/InitialSyncProgressService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/InitialSyncProgressService.kt index 3bb567ae00..a4c9d81beb 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/InitialSyncProgressService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/InitialSyncProgressService.kt @@ -20,10 +20,10 @@ import androidx.lifecycle.LiveData interface InitialSyncProgressService { - fun getLiveStatus() : LiveData + fun getInitialSyncProgressStatus() : LiveData data class Status( - @StringRes val statusText: Int?, + @StringRes val statusText: Int, val percentProgress: Int = 0 ) } \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultInitialSyncProgressService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultInitialSyncProgressService.kt index 69f608d0d5..1d3ce23302 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultInitialSyncProgressService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/DefaultInitialSyncProgressService.kt @@ -30,7 +30,7 @@ class DefaultInitialSyncProgressService @Inject constructor() : InitialSyncProgr private var rootTask: TaskInfo? = null - override fun getLiveStatus(): LiveData { + override fun getInitialSyncProgressStatus(): LiveData { return status } diff --git a/vector/src/main/java/im/vector/riotx/features/home/HomeActivity.kt b/vector/src/main/java/im/vector/riotx/features/home/HomeActivity.kt index 64a86b9040..247c0c1981 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/HomeActivity.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/HomeActivity.kt @@ -26,7 +26,6 @@ import androidx.appcompat.widget.Toolbar import androidx.core.view.GravityCompat import androidx.core.view.isVisible import androidx.drawerlayout.widget.DrawerLayout -import androidx.fragment.app.FragmentManager import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders 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.observeEvent 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.VectorBaseActivity import im.vector.riotx.core.pushers.PushersManager 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.rageshake.VectorUncaughtExceptionHandler import im.vector.riotx.features.workers.signout.SignOutViewModel @@ -119,22 +116,22 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable { intent.removeExtra(EXTRA_CLEAR_EXISTING_NOTIFICATION) } - activeSessionHolder.getSafeActiveSession()?.getLiveStatus()?.observe(this, Observer { sprogress -> - Timber.e("${sprogress?.statusText?.let { getString(it) }} ${sprogress?.percentProgress}") - if (sprogress == null) { + activeSessionHolder.getSafeActiveSession()?.getInitialSyncProgressStatus()?.observe(this, Observer { status -> + if (status == null) { waiting_view.isVisible = false } else { + Timber.e("${getString(status.statusText)} ${status.percentProgress}") waiting_view.setOnClickListener { //block interactions } waiting_view_status_horizontal_progress.apply { isIndeterminate = false max = 100 - progress = sprogress.percentProgress + progress = status.percentProgress isVisible = true } waiting_view_status_text.apply { - text = sprogress.statusText?.let { getString(it) } + text = getString(status.statusText) isVisible = true } waiting_view.isVisible = true @@ -213,8 +210,6 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable { } - - companion object { private const val EXTRA_CLEAR_EXISTING_NOTIFICATION = "EXTRA_CLEAR_EXISTING_NOTIFICATION"