update renamed videos properly too

This commit is contained in:
tibbi 2016-12-07 19:37:39 +01:00
parent 4a2d8076d0
commit 1ae4e0cc02
2 changed files with 3 additions and 3 deletions

View File

@ -4,9 +4,9 @@ import android.app.AlertDialog
import android.view.LayoutInflater
import android.view.WindowManager
import com.simplemobiletools.filepicker.extensions.*
import com.simplemobiletools.gallery.helpers.Config
import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.activities.SimpleActivity
import com.simplemobiletools.gallery.helpers.Config
import kotlinx.android.synthetic.main.rename_directory.view.*
import java.io.File
import java.util.*

View File

@ -80,8 +80,8 @@ class RenameFileDialog(val activity: SimpleActivity, val file: File, val callbac
private fun sendSuccess(oldFile: File, newFile: File) {
val values = ContentValues()
values.put(MediaStore.MediaColumns.DATA, newFile.absolutePath)
val updated = activity.contentResolver.update(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values,
"${MediaStore.MediaColumns.DATA} = '${oldFile.absolutePath}'", null) == 1
val uri = if (oldFile.isImageSlow()) MediaStore.Images.Media.EXTERNAL_CONTENT_URI else MediaStore.Video.Media.EXTERNAL_CONTENT_URI
val updated = activity.contentResolver.update(uri, values, "${MediaStore.MediaColumns.DATA} = '${oldFile.absolutePath}'", null) == 1
if (updated) {
callback.invoke(newFile)