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 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, override fun startTask(@StringRes nameRes: Int,
totalProgress: Int, totalProgress: Int,
parentWeight: Float) { parentWeight: Float) {
// Create a rootTask, or add a child to the leaf val currentLeaf = rootTask?.leaf() ?: return
if (rootTask == null) { currentLeaf.child = TaskInfo(
rootTask = TaskInfo(nameRes, totalProgress, null, 1F) nameRes = nameRes,
} else { totalProgress = totalProgress,
val currentLeaf = rootTask!!.leaf() parent = currentLeaf,
currentLeaf.child = TaskInfo( parentWeight = parentWeight
nameRes = nameRes, )
totalProgress = totalProgress,
parent = currentLeaf,
parentWeight = parentWeight
)
}
reportProgress(0F) 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.TimeOutInterceptor
import org.matrix.android.sdk.internal.network.executeRequest import org.matrix.android.sdk.internal.network.executeRequest
import org.matrix.android.sdk.internal.network.toFailure 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.filter.FilterRepository
import org.matrix.android.sdk.internal.session.homeserver.GetHomeServerCapabilitiesTask 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.initsync.reportSubtask
import org.matrix.android.sdk.internal.session.sync.model.LazyRoomSync import org.matrix.android.sdk.internal.session.sync.model.LazyRoomSync
import org.matrix.android.sdk.internal.session.sync.model.SyncResponse import org.matrix.android.sdk.internal.session.sync.model.SyncResponse
@ -90,8 +90,7 @@ internal class DefaultSyncTask @Inject constructor(
if (isInitialSync) { if (isInitialSync) {
// We might want to get the user information in parallel too // We might want to get the user information in parallel too
userStore.createOrUpdate(userId) userStore.createOrUpdate(userId)
initialSyncProgressService.endAll() initialSyncProgressService.startRoot(R.string.initial_sync_start_importing_account, 100)
initialSyncProgressService.startTask(R.string.initial_sync_start_importing_account, 100, 1F)
} }
// Maybe refresh the home server capabilities data we know // Maybe refresh the home server capabilities data we know
getHomeServerCapabilitiesTask.execute(GetHomeServerCapabilitiesTask.Params(forceRefresh = false)) getHomeServerCapabilitiesTask.execute(GetHomeServerCapabilitiesTask.Params(forceRefresh = false))