Latest improvement

This commit is contained in:
Benoit Marty 2021-02-09 11:41:26 +01:00 committed by Benoit Marty
parent 24e9e6bbd7
commit c3192d9f7c
2 changed files with 22 additions and 15 deletions

View file

@ -35,21 +35,29 @@ internal class DefaultInitialSyncProgressService @Inject constructor()
return status
}
/**
* Create a rootTask
*/
fun startRoot(@StringRes nameRes: Int,
totalProgress: Int) {
endAll()
rootTask = TaskInfo(nameRes, totalProgress, null, 1F)
reportProgress(0F)
}
/**
* Add a child to the leaf
*/
override fun startTask(@StringRes nameRes: Int,
totalProgress: Int,
parentWeight: Float) {
// Create a rootTask, or add a child to the leaf
if (rootTask == null) {
rootTask = TaskInfo(nameRes, totalProgress, null, 1F)
} else {
val currentLeaf = rootTask!!.leaf()
currentLeaf.child = TaskInfo(
nameRes = nameRes,
totalProgress = totalProgress,
parent = currentLeaf,
parentWeight = parentWeight
)
}
val currentLeaf = rootTask?.leaf() ?: return
currentLeaf.child = TaskInfo(
nameRes = nameRes,
totalProgress = totalProgress,
parent = currentLeaf,
parentWeight = parentWeight
)
reportProgress(0F)
}

View file

@ -24,9 +24,9 @@ import org.matrix.android.sdk.internal.network.GlobalErrorReceiver
import org.matrix.android.sdk.internal.network.TimeOutInterceptor
import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.network.toFailure
import org.matrix.android.sdk.internal.session.initsync.DefaultInitialSyncProgressService
import org.matrix.android.sdk.internal.session.filter.FilterRepository
import org.matrix.android.sdk.internal.session.homeserver.GetHomeServerCapabilitiesTask
import org.matrix.android.sdk.internal.session.initsync.DefaultInitialSyncProgressService
import org.matrix.android.sdk.internal.session.initsync.reportSubtask
import org.matrix.android.sdk.internal.session.sync.model.LazyRoomSync
import org.matrix.android.sdk.internal.session.sync.model.SyncResponse
@ -90,8 +90,7 @@ internal class DefaultSyncTask @Inject constructor(
if (isInitialSync) {
// We might want to get the user information in parallel too
userStore.createOrUpdate(userId)
initialSyncProgressService.endAll()
initialSyncProgressService.startTask(R.string.initial_sync_start_importing_account, 100, 1F)
initialSyncProgressService.startRoot(R.string.initial_sync_start_importing_account, 100)
}
// Maybe refresh the home server capabilities data we know
getHomeServerCapabilitiesTask.execute(GetHomeServerCapabilitiesTask.Params(forceRefresh = false))