mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
properly update files after renaming in the local database
This commit is contained in:
parent
505c5a7e37
commit
0039591a53
7 changed files with 34 additions and 14 deletions
|
@ -47,7 +47,7 @@ ext {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:3.19.5'
|
implementation 'com.simplemobiletools:commons:3.19.7'
|
||||||
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
|
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
|
||||||
implementation 'com.android.support:multidex:1.0.3'
|
implementation 'com.android.support:multidex:1.0.3'
|
||||||
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
implementation 'it.sephiroth.android.exif:library:1.0.1'
|
||||||
|
|
|
@ -657,15 +657,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
override fun deleteFiles(fileDirItems: ArrayList<FileDirItem>) {
|
override fun deleteFiles(fileDirItems: ArrayList<FileDirItem>) {
|
||||||
val filtered = fileDirItems.filter { it.path.isImageVideoGif() } as ArrayList
|
val filtered = fileDirItems.filter { it.path.isImageVideoGif() } as ArrayList
|
||||||
deleteFiles(filtered) {
|
deleteFiles(filtered) {
|
||||||
Thread {
|
|
||||||
val mediumDao = galleryDB.MediumDao()
|
|
||||||
filtered.forEach {
|
|
||||||
if (!File(it.path).exists()) {
|
|
||||||
mediumDao.deleteMediumPath(it.path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.start()
|
|
||||||
|
|
||||||
if (!it) {
|
if (!it) {
|
||||||
toast(R.string.unknown_error_occurred)
|
toast(R.string.unknown_error_occurred)
|
||||||
} else if (mMedia.isEmpty()) {
|
} else if (mMedia.isEmpty()) {
|
||||||
|
@ -673,6 +664,13 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
finish()
|
finish()
|
||||||
} else {
|
} else {
|
||||||
updateStoredDirectories()
|
updateStoredDirectories()
|
||||||
|
|
||||||
|
Thread {
|
||||||
|
val mediumDao = galleryDB.MediumDao()
|
||||||
|
filtered.forEach {
|
||||||
|
mediumDao.deleteMediumPath(it.path)
|
||||||
|
}
|
||||||
|
}.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -757,8 +757,16 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renameFile() {
|
private fun renameFile() {
|
||||||
RenameItemDialog(this, getCurrentPath()) {
|
val oldPath = getCurrentPath()
|
||||||
getCurrentMedia()[mPos].path = it
|
RenameItemDialog(this, oldPath) {
|
||||||
|
getCurrentMedia()[mPos].apply {
|
||||||
|
path = it
|
||||||
|
name = it.getFilenameFromPath()
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread {
|
||||||
|
updateMediaPath(oldPath, it)
|
||||||
|
}.start()
|
||||||
updateActionbarTitle()
|
updateActionbarTitle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,12 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renameFile() {
|
private fun renameFile() {
|
||||||
RenameItemDialog(activity, getCurrentPath()) {
|
val oldPath = getCurrentPath()
|
||||||
|
RenameItemDialog(activity, oldPath) {
|
||||||
|
Thread {
|
||||||
|
activity.updateMediaPath(oldPath, it)
|
||||||
|
}.start()
|
||||||
|
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
finishActMode()
|
finishActMode()
|
||||||
|
|
|
@ -267,3 +267,9 @@ fun Context.getCachedMedia(path: String, callback: (ArrayList<Medium>) -> Unit)
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Context.updateMediaPath(oldPath: String, newPath: String) {
|
||||||
|
val newFilename = newPath.getFilenameFromPath()
|
||||||
|
val newParentPath = newPath.getParentPath()
|
||||||
|
galleryDB.MediumDao().updateMedia(oldPath, newParentPath, newFilename, newPath)
|
||||||
|
}
|
||||||
|
|
|
@ -22,4 +22,7 @@ interface MediumDao {
|
||||||
|
|
||||||
@Query("DELETE FROM media WHERE full_path = :path")
|
@Query("DELETE FROM media WHERE full_path = :path")
|
||||||
fun deleteMediumPath(path: String)
|
fun deleteMediumPath(path: String)
|
||||||
|
|
||||||
|
@Query("UPDATE media SET filename = :newFilename, full_path = :newFullPath, parent_path = :newParentPath WHERE full_path = :oldPath")
|
||||||
|
fun updateMedia(oldPath: String, newParentPath: String, newFilename: String, newFullPath: String)
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@
|
||||||
<string name="slideshow">Slideshow</string>
|
<string name="slideshow">Slideshow</string>
|
||||||
<string name="interval">Frekvens (sekunder):</string>
|
<string name="interval">Frekvens (sekunder):</string>
|
||||||
<string name="include_photos">Inkluder billeder</string>
|
<string name="include_photos">Inkluder billeder</string>
|
||||||
<string name="include_videos">Inkluder videoer/string>
|
<string name="include_videos">Inkluder videoer</string>
|
||||||
<string name="include_gifs">Inkluder GIF\'er</string>
|
<string name="include_gifs">Inkluder GIF\'er</string>
|
||||||
<string name="random_order">Tilfældig rækkefølge</string>
|
<string name="random_order">Tilfældig rækkefølge</string>
|
||||||
<string name="use_fade">Use fade animations</string>
|
<string name="use_fade">Use fade animations</string>
|
||||||
|
|
Loading…
Reference in a new issue