properly count how many files should be copied/moved at telling the result
This commit is contained in:
parent
4ee846921d
commit
4df35ca1d6
2 changed files with 6 additions and 3 deletions
|
@ -6,7 +6,7 @@ buildscript {
|
||||||
propMinSdkVersion = 16
|
propMinSdkVersion = 16
|
||||||
propTargetSdkVersion = propCompileSdkVersion
|
propTargetSdkVersion = propCompileSdkVersion
|
||||||
propVersionCode = 1
|
propVersionCode = 1
|
||||||
propVersionName = '3.11.11'
|
propVersionName = '3.11.12'
|
||||||
kotlin_version = '1.2.21'
|
kotlin_version = '1.2.21'
|
||||||
support_libs = '27.0.2'
|
support_libs = '27.0.2'
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,8 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal
|
||||||
private var mListener: WeakReference<CopyMoveListener>? = null
|
private var mListener: WeakReference<CopyMoveListener>? = null
|
||||||
private var mMovedFiles: ArrayList<File> = ArrayList()
|
private var mMovedFiles: ArrayList<File> = ArrayList()
|
||||||
private var mDocuments = LinkedHashMap<String, DocumentFile?>()
|
private var mDocuments = LinkedHashMap<String, DocumentFile?>()
|
||||||
lateinit var mFiles: ArrayList<File>
|
private lateinit var mFiles: ArrayList<File>
|
||||||
|
private var mFileCountToCopy = 0
|
||||||
|
|
||||||
// progress indication
|
// progress indication
|
||||||
private var mNotificationManager: NotificationManager
|
private var mNotificationManager: NotificationManager
|
||||||
|
@ -54,6 +55,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal
|
||||||
|
|
||||||
val pair = params[0]
|
val pair = params[0]
|
||||||
mFiles = pair.first!!
|
mFiles = pair.first!!
|
||||||
|
mFileCountToCopy = mFiles.size
|
||||||
mNotifId = mFiles.hashCode()
|
mNotifId = mFiles.hashCode()
|
||||||
mMaxSize = 0
|
mMaxSize = 0
|
||||||
for (file in mFiles) {
|
for (file in mFiles) {
|
||||||
|
@ -74,6 +76,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal
|
||||||
if (newFile.exists()) {
|
if (newFile.exists()) {
|
||||||
val resolution = getConflictResolution(newFile)
|
val resolution = getConflictResolution(newFile)
|
||||||
if (resolution == CONFLICT_SKIP) {
|
if (resolution == CONFLICT_SKIP) {
|
||||||
|
mFileCountToCopy--
|
||||||
continue
|
continue
|
||||||
} else if (resolution == CONFLICT_OVERWRITE) {
|
} else if (resolution == CONFLICT_OVERWRITE) {
|
||||||
activity.deleteFilesBg(arrayListOf(newFile), true)
|
activity.deleteFilesBg(arrayListOf(newFile), true)
|
||||||
|
@ -101,7 +104,7 @@ class CopyMoveTask(val activity: BaseSimpleActivity, val copyOnly: Boolean = fal
|
||||||
val listener = mListener?.get() ?: return
|
val listener = mListener?.get() ?: return
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
listener.copySucceeded(copyOnly, mMovedFiles.size >= mFiles.size)
|
listener.copySucceeded(copyOnly, mMovedFiles.size >= mFileCountToCopy)
|
||||||
} else {
|
} else {
|
||||||
listener.copyFailed()
|
listener.copyFailed()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue