From 4df35ca1d6ab2b8565e11b93c22339d8dfb2467b Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 12 Feb 2018 23:49:49 +0100 Subject: [PATCH] properly count how many files should be copied/moved at telling the result --- build.gradle | 2 +- .../simplemobiletools/commons/asynctasks/CopyMoveTask.kt | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index a804709e9..1ad32bc81 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { propMinSdkVersion = 16 propTargetSdkVersion = propCompileSdkVersion propVersionCode = 1 - propVersionName = '3.11.11' + propVersionName = '3.11.12' kotlin_version = '1.2.21' support_libs = '27.0.2' } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/asynctasks/CopyMoveTask.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/asynctasks/CopyMoveTask.kt index 0369ae7a9..c026f79dc 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/asynctasks/CopyMoveTask.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/asynctasks/CopyMoveTask.kt @@ -30,7 +30,8 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal private var mListener: WeakReference? = null private var mMovedFiles: ArrayList = ArrayList() private var mDocuments = LinkedHashMap() - lateinit var mFiles: ArrayList + private lateinit var mFiles: ArrayList + private var mFileCountToCopy = 0 // progress indication private var mNotificationManager: NotificationManager @@ -54,6 +55,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal val pair = params[0] mFiles = pair.first!! + mFileCountToCopy = mFiles.size mNotifId = mFiles.hashCode() mMaxSize = 0 for (file in mFiles) { @@ -74,6 +76,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal if (newFile.exists()) { val resolution = getConflictResolution(newFile) if (resolution == CONFLICT_SKIP) { + mFileCountToCopy-- continue } else if (resolution == CONFLICT_OVERWRITE) { activity.deleteFilesBg(arrayListOf(newFile), true) @@ -101,7 +104,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal val listener = mListener?.get() ?: return if (success) { - listener.copySucceeded(copyOnly, mMovedFiles.size >= mFiles.size) + listener.copySucceeded(copyOnly, mMovedFiles.size >= mFileCountToCopy) } else { listener.copyFailed() }