mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
rescan and cache destination path after copy
This commit is contained in:
parent
42bd31f38b
commit
7ebc110ac8
5 changed files with 24 additions and 10 deletions
|
@ -46,7 +46,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.16.9'
|
||||
implementation 'com.simplemobiletools:commons:3.16.10'
|
||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
|
||||
implementation 'com.android.support:multidex:1.0.3'
|
||||
implementation 'com.google.code.gson:gson:2.8.2'
|
||||
|
|
|
@ -20,7 +20,6 @@ import com.bumptech.glide.Glide
|
|||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.bumptech.glide.request.target.SimpleTarget
|
||||
import com.bumptech.glide.request.transition.Transition
|
||||
import com.google.gson.Gson
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
|
@ -663,13 +662,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
private fun storeFolder() {
|
||||
if (!config.temporarilyShowHidden) {
|
||||
Thread {
|
||||
try {
|
||||
val subList = mMedia.subList(0, Math.min(SAVE_MEDIA_CNT, mMedia.size))
|
||||
val json = Gson().toJson(subList)
|
||||
config.saveFolderMedia(mPath, json)
|
||||
} catch (ignored: Exception) {
|
||||
} catch (ignored: OutOfMemoryError) {
|
||||
}
|
||||
storeFolderItems(mPath, mMedia)
|
||||
}.start()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,6 +187,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
|
|||
val fileDirItems = paths.map { FileDirItem(it, it.getFilenameFromPath()) } as ArrayList
|
||||
activity.tryCopyMoveFilesTo(fileDirItems, isCopyOperation) {
|
||||
config.tempFolderPath = ""
|
||||
activity.applicationContext.updateStoredFolderItems(it)
|
||||
if (!isCopyOperation) {
|
||||
listener?.refreshItems()
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ fun Activity.loadImage(type: Int, path: String, target: MySquareImageView, horiz
|
|||
}
|
||||
}
|
||||
|
||||
fun BaseSimpleActivity.tryCopyMoveFilesTo(fileDirItems: ArrayList<FileDirItem>, isCopyOperation: Boolean, callback: () -> Unit) {
|
||||
fun BaseSimpleActivity.tryCopyMoveFilesTo(fileDirItems: ArrayList<FileDirItem>, isCopyOperation: Boolean, callback: (destinationPath: String) -> Unit) {
|
||||
if (fileDirItems.isEmpty()) {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
return
|
||||
|
|
|
@ -9,13 +9,17 @@ import android.media.AudioManager
|
|||
import android.os.Build
|
||||
import android.provider.MediaStore
|
||||
import android.view.WindowManager
|
||||
import com.google.gson.Gson
|
||||
import com.simplemobiletools.commons.extensions.getStringValue
|
||||
import com.simplemobiletools.commons.extensions.humanizePath
|
||||
import com.simplemobiletools.commons.helpers.OTG_PATH
|
||||
import com.simplemobiletools.gallery.activities.SettingsActivity
|
||||
import com.simplemobiletools.gallery.asynctasks.GetMediaAsynctask
|
||||
import com.simplemobiletools.gallery.helpers.Config
|
||||
import com.simplemobiletools.gallery.helpers.NOMEDIA
|
||||
import com.simplemobiletools.gallery.helpers.SAVE_MEDIA_CNT
|
||||
import com.simplemobiletools.gallery.models.Directory
|
||||
import com.simplemobiletools.gallery.models.Medium
|
||||
import java.io.File
|
||||
|
||||
val Context.portrait get() = resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT
|
||||
|
@ -128,3 +132,19 @@ fun Context.isPathInMediaStore(path: String): Boolean {
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun Context.updateStoredFolderItems(path: String) {
|
||||
GetMediaAsynctask(this, path, false, false, false) {
|
||||
storeFolderItems(path, it)
|
||||
}.execute()
|
||||
}
|
||||
|
||||
fun Context.storeFolderItems(path: String, items: ArrayList<Medium>) {
|
||||
try {
|
||||
val subList = items.subList(0, Math.min(SAVE_MEDIA_CNT, items.size))
|
||||
val json = Gson().toJson(subList)
|
||||
config.saveFolderMedia(path, json)
|
||||
} catch (ignored: Exception) {
|
||||
} catch (ignored: OutOfMemoryError) {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue