mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2025-01-19 06:48:00 +01:00
handle deleting folders from local db
This commit is contained in:
parent
5b8143d41e
commit
73ac822661
3 changed files with 19 additions and 1 deletions
|
@ -362,6 +362,11 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
refreshItems()
|
refreshItems()
|
||||||
}
|
}
|
||||||
|
Thread {
|
||||||
|
folders.filter { !it.exists() }.forEach {
|
||||||
|
galleryDB.DirectoryDao().deleteDirPath(it.absolutePath)
|
||||||
|
}
|
||||||
|
}.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -246,7 +246,13 @@ fun Activity.loadJpg(path: String, target: MySquareImageView, cropThumbnails: Bo
|
||||||
|
|
||||||
fun Activity.getCachedDirectories(callback: (ArrayList<Directory>) -> Unit) {
|
fun Activity.getCachedDirectories(callback: (ArrayList<Directory>) -> Unit) {
|
||||||
Thread {
|
Thread {
|
||||||
callback(galleryDB.DirectoryDao().getAll() as ArrayList<Directory>)
|
val directoryDao = galleryDB.DirectoryDao()
|
||||||
|
val directories = directoryDao.getAll() as ArrayList<Directory>
|
||||||
|
callback(directories)
|
||||||
|
|
||||||
|
directories.filter { !File(it.path).exists() }.forEach {
|
||||||
|
directoryDao.deleteDir(it)
|
||||||
|
}
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.simplemobiletools.gallery.interfaces
|
package com.simplemobiletools.gallery.interfaces
|
||||||
|
|
||||||
import android.arch.persistence.room.Dao
|
import android.arch.persistence.room.Dao
|
||||||
|
import android.arch.persistence.room.Delete
|
||||||
import android.arch.persistence.room.Insert
|
import android.arch.persistence.room.Insert
|
||||||
import android.arch.persistence.room.OnConflictStrategy.REPLACE
|
import android.arch.persistence.room.OnConflictStrategy.REPLACE
|
||||||
import android.arch.persistence.room.Query
|
import android.arch.persistence.room.Query
|
||||||
|
@ -16,4 +17,10 @@ interface DirectoryDao {
|
||||||
|
|
||||||
@Insert(onConflict = REPLACE)
|
@Insert(onConflict = REPLACE)
|
||||||
fun insertAll(directories: List<Directory>)
|
fun insertAll(directories: List<Directory>)
|
||||||
|
|
||||||
|
@Delete
|
||||||
|
fun deleteDir(directory: Directory)
|
||||||
|
|
||||||
|
@Query("DELETE FROM directories WHERE path = :path")
|
||||||
|
fun deleteDirPath(path: String)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue