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

@ -51,7 +51,7 @@ import javax.inject.Singleton
* BugReporter creates and sends the bug reports.
*/
@Singleton
class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSessionHolder){
class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSessionHolder) {
var inMultiWindowMode = false

companion object {
@ -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

/**