From 58ebbc0ba3830220ce10e1a5cdffde21034204b4 Mon Sep 17 00:00:00 2001 From: androidacy-user Date: Mon, 3 Jul 2023 23:37:54 -0400 Subject: [PATCH] rework again Signed-off-by: androidacy-user --- .../kotlin/com/fox2code/mmm/repo/RepoManager.kt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/app/src/main/kotlin/com/fox2code/mmm/repo/RepoManager.kt b/app/src/main/kotlin/com/fox2code/mmm/repo/RepoManager.kt index 4f2163d..abac6b3 100644 --- a/app/src/main/kotlin/com/fox2code/mmm/repo/RepoManager.kt +++ b/app/src/main/kotlin/com/fox2code/mmm/repo/RepoManager.kt @@ -209,12 +209,9 @@ class RepoManager private constructor(mainApplication: MainApplication) : SyncMa Timber.e(e) } updatedModules++ - // update the update listener - // STEP1 is done so always add it - // step2 percentage is calculated by the number of modules updated out of total, then multiplied by the percentage of repos done - updateListener.update( - STEP1 + STEP2 * ((updatedModules / moduleToUpdate) * (i + 1) / repoDatas.size) - ) + val repoProgressIncrement = STEP2 / repoDatas.size.toDouble() + val moduleProgressIncrement = repoProgressIncrement / repoModules.size.toDouble() + updateListener.update((STEP1 + moduleProgressIncrement * updatedModules).toInt()) } for (repoModule in repoUpdaters[i]!!.toApply()!!) { if (repoModule.moduleInfo.flags and ModuleInfo.FLAG_METADATA_INVALID == 0) { @@ -349,8 +346,8 @@ class RepoManager private constructor(mainApplication: MainApplication) : SyncMa private const val MAGISK_REPO_MANAGER = "https://magisk-modules-repo.github.io/submission/modules.json" private val lock = Any() - private const val STEP1 = 40 - private const val STEP2 = 40 + private const val STEP1 = 20 + private const val STEP2 = 60 private const val STEP3 = 20 @Volatile @@ -415,4 +412,4 @@ class RepoManager private constructor(mainApplication: MainApplication) : SyncMa val isAndroidacyRepoEnabled: Boolean get() = INSTANCE != null && INSTANCE!!.androidacyRepoData != null && INSTANCE!!.androidacyRepoData!!.isEnabled } -} \ No newline at end of file +}