This commit is contained in:
Benoit Marty 2019-07-09 16:36:46 +02:00
parent 1a4157a663
commit 34ac987494
3 changed files with 10 additions and 10 deletions

View file

@ -61,13 +61,13 @@ class DefaultInitialSyncProgressService @Inject constructor() : InitialSyncProgr
parent?.incrementProgress(endedTask.offset + (endedTask.totalProgress * endedTask.parentWeight).toInt())
}
if (endedTask?.parent == null) {
this@DefaultInitialSyncProgressService.status.postValue(null)
status.postValue(null)
}
}
fun endAll() {
rootTask = null
this@DefaultInitialSyncProgressService.status.postValue(null)
status.postValue(null)
}
@ -96,7 +96,7 @@ class DefaultInitialSyncProgressService @Inject constructor() : InitialSyncProgr
}
if (parent == null) {
Timber.e("--- ${leaf().nameRes}: ${currentProgress}")
this@DefaultInitialSyncProgressService.status.postValue(
status.postValue(
InitialSyncProgressService.Status(leaf().nameRes, currentProgress)
)
}
@ -105,7 +105,7 @@ class DefaultInitialSyncProgressService @Inject constructor() : InitialSyncProgr
}
public inline fun <T> reportSubtask(reporter: DefaultInitialSyncProgressService?, nameRes: Int, totalProgress: Int, parentWeight: Float = 1f, block: () -> T): T {
inline fun <T> reportSubtask(reporter: DefaultInitialSyncProgressService?, nameRes: Int, totalProgress: Int, parentWeight: Float = 1f, block: () -> T): T {
reporter?.startTask(nameRes, totalProgress, parentWeight)
return block().also {
reporter?.endTask(nameRes)
@ -113,8 +113,8 @@ public inline fun <T> reportSubtask(reporter: DefaultInitialSyncProgressService?
}
public inline fun <K, V, R> Map<out K, V>.mapWithProgress(reporter: DefaultInitialSyncProgressService?, taskId: Int, weight: Float, transform: (Map.Entry<K, V>) -> R): List<R> {
val total = this.count()
inline fun <K, V, R> Map<out K, V>.mapWithProgress(reporter: DefaultInitialSyncProgressService?, taskId: Int, weight: Float, transform: (Map.Entry<K, V>) -> R): List<R> {
val total = count()
var current = 0
reporter?.startTask(taskId, 100, weight)
return this.map {

View file

@ -36,7 +36,7 @@ internal class SyncResponseHandler @Inject constructor(private val roomSyncHandl
fun handleResponse(syncResponse: SyncResponse, fromToken: String?, isCatchingUp: Boolean): Try<SyncResponse> {
return Try {
val isInitialSync = fromToken == null
Timber.v("Start handling sync, is InitialSync: ${isInitialSync}")
Timber.v("Start handling sync, is InitialSync: $isInitialSync")
val reporter = initialSyncProgressService.takeIf { isInitialSync }
if (!cryptoManager.isStarted()) {
@ -68,7 +68,7 @@ internal class SyncResponseHandler @Inject constructor(private val roomSyncHandl
}
reportSubtask(reporter, R.string.initial_sync_start_importing_account_data, 100, 0.1f) {
Timber.v("Handle accoundData")
Timber.v("Handle accountData")
if (syncResponse.accountData != null) {
userAccountDataSyncHandler.handle(syncResponse.accountData)
}

View file

@ -72,7 +72,7 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
private var mBugReportCall: Call? = null
// boolean to cancel the bug reportSubtask
// boolean to cancel the bug report
private val mIsCancelled = false
/**