From beba22b764537bb21fce88fdbb03b3c6f79d5ec0 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 9 Nov 2016 22:58:13 +0100 Subject: [PATCH] refresh the directories view after copying --- .../simplemobiletools/gallery/activities/MainActivity.java | 2 +- .../com/simplemobiletools/gallery/asynctasks/CopyTask.kt | 3 +++ .../com/simplemobiletools/gallery/dialogs/CopyDialog.kt | 7 +++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java index 5795a1063..1f4264aad 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java @@ -592,7 +592,7 @@ public class MainActivity extends SimpleActivity @Override public void copySucceeded(@NotNull File destinationDir) { - + getDirectories(); } @Override diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/CopyTask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/CopyTask.kt index 0309d7486..7a9758907 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/CopyTask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/CopyTask.kt @@ -5,6 +5,7 @@ import android.os.AsyncTask import android.support.v4.util.Pair import android.util.Log import com.simplemobiletools.gallery.Utils +import com.simplemobiletools.gallery.extensions.scanFile import java.io.* import java.lang.ref.WeakReference @@ -87,6 +88,8 @@ class CopyTask(listener: CopyTask.CopyDoneListener, val context: Context) : Asyn out = FileOutputStream(destination) } + val paths = arrayOf(destination.absolutePath) + context.scanFile(paths) copyStream(inputStream, out) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt index 310817798..897c11655 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/dialogs/CopyDialog.kt @@ -11,7 +11,6 @@ import com.simplemobiletools.gallery.Utils import com.simplemobiletools.gallery.asynctasks.CopyTask import com.simplemobiletools.gallery.extensions.scanFile import com.simplemobiletools.gallery.extensions.toast -import com.simplemobiletools.gallery.extensions.value import kotlinx.android.synthetic.main.copy_item.view.* import java.io.File import java.util.* @@ -21,10 +20,10 @@ class CopyDialog(val activity: Activity, val files: List, val copyListener init { val context = activity val view = LayoutInflater.from(context).inflate(R.layout.copy_item, null) - val path = files[0].parent.trimEnd('/') + val sourcePath = files[0].parent.trimEnd('/') var destinationPath = "" - view.source.text = context.humanizePath(path) + view.source.text = context.humanizePath(sourcePath) view.destination.setOnClickListener { PickAlbumDialog(activity, object : PickAlbumDialog.OnPickAlbumListener { @@ -78,7 +77,7 @@ class CopyDialog(val activity: Activity, val files: List, val copyListener CopyTask(copyListener, context).execute(pair) dismiss() } else { - if (Utils.isPathOnSD(context, view.source.value) && Utils.isPathOnSD(context, destinationPath)) { + if (Utils.isPathOnSD(context, sourcePath) && Utils.isPathOnSD(context, destinationPath)) { val paths = ArrayList() for (f in files) { val destination = File(destinationDir, f.name)