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()) parent?.incrementProgress(endedTask.offset + (endedTask.totalProgress * endedTask.parentWeight).toInt())
} }
if (endedTask?.parent == null) { if (endedTask?.parent == null) {
this@DefaultInitialSyncProgressService.status.postValue(null) status.postValue(null)
} }
} }


fun endAll() { fun endAll() {
rootTask = null rootTask = null
this@DefaultInitialSyncProgressService.status.postValue(null) status.postValue(null)
} }




@ -96,7 +96,7 @@ class DefaultInitialSyncProgressService @Inject constructor() : InitialSyncProgr
} }
if (parent == null) { if (parent == null) {
Timber.e("--- ${leaf().nameRes}: ${currentProgress}") Timber.e("--- ${leaf().nameRes}: ${currentProgress}")
this@DefaultInitialSyncProgressService.status.postValue( status.postValue(
InitialSyncProgressService.Status(leaf().nameRes, currentProgress) 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) reporter?.startTask(nameRes, totalProgress, parentWeight)
return block().also { return block().also {
reporter?.endTask(nameRes) 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> { 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() val total = count()
var current = 0 var current = 0
reporter?.startTask(taskId, 100, weight) reporter?.startTask(taskId, 100, weight)
return this.map { 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> { fun handleResponse(syncResponse: SyncResponse, fromToken: String?, isCatchingUp: Boolean): Try<SyncResponse> {
return Try { return Try {
val isInitialSync = fromToken == null 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 } val reporter = initialSyncProgressService.takeIf { isInitialSync }


if (!cryptoManager.isStarted()) { 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) { 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) { if (syncResponse.accountData != null) {
userAccountDataSyncHandler.handle(syncResponse.accountData) userAccountDataSyncHandler.handle(syncResponse.accountData)
} }

View File

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


companion object { companion object {
@ -72,7 +72,7 @@ class BugReporter @Inject constructor(private val activeSessionHolder: ActiveSes
private var mBugReportCall: Call? = null private var mBugReportCall: Call? = null




// boolean to cancel the bug reportSubtask // boolean to cancel the bug report
private val mIsCancelled = false private val mIsCancelled = false


/** /**