renaming some DAO to Dao
This commit is contained in:
parent
61c4db155d
commit
b9369139f1
|
@ -375,7 +375,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
else -> TYPE_IMAGES
|
||||
}
|
||||
|
||||
val isFavorite = galleryDB.FavoritesDAO().isFavorite(mPath)
|
||||
val isFavorite = favoritesDB.isFavorite(mPath)
|
||||
val duration = if (type == TYPE_VIDEOS) mPath.getVideoDuration() else 0
|
||||
val ts = System.currentTimeMillis()
|
||||
val medium = Medium(null, mPath.getFilenameFromPath(), mPath, mPath.getParentPath(), ts, ts, File(mPath).length(), type, duration, isFavorite, 0)
|
||||
|
|
|
@ -555,7 +555,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
|||
tryEmptyRecycleBin(false)
|
||||
} else {
|
||||
ensureBackgroundThread {
|
||||
activity.galleryDB.MediumDao().clearFavorites()
|
||||
activity.favoritesDB.clearFavorites()
|
||||
listener?.refreshItems()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ abstract class GalleryDatabase : RoomDatabase() {
|
|||
|
||||
abstract fun WidgetsDao(): WidgetsDao
|
||||
|
||||
abstract fun DateTakensDAO(): DateTakensDAO
|
||||
abstract fun DateTakensDao(): DateTakensDao
|
||||
|
||||
abstract fun FavoritesDAO(): FavoritesDAO
|
||||
abstract fun FavoritesDao(): FavoritesDao
|
||||
|
||||
companion object {
|
||||
private var db: GalleryDatabase? = null
|
||||
|
|
|
@ -26,6 +26,7 @@ import com.simplemobiletools.gallery.pro.asynctasks.GetMediaAsynctask
|
|||
import com.simplemobiletools.gallery.pro.databases.GalleryDatabase
|
||||
import com.simplemobiletools.gallery.pro.helpers.*
|
||||
import com.simplemobiletools.gallery.pro.interfaces.DirectoryDao
|
||||
import com.simplemobiletools.gallery.pro.interfaces.FavoritesDao
|
||||
import com.simplemobiletools.gallery.pro.interfaces.MediumDao
|
||||
import com.simplemobiletools.gallery.pro.interfaces.WidgetsDao
|
||||
import com.simplemobiletools.gallery.pro.models.*
|
||||
|
@ -116,6 +117,8 @@ val Context.widgetsDB: WidgetsDao get() = GalleryDatabase.getInstance(applicatio
|
|||
|
||||
val Context.directoryDB: DirectoryDao get() = GalleryDatabase.getInstance(applicationContext).DirectoryDao()
|
||||
|
||||
val Context.favoritesDB: FavoritesDao get() = GalleryDatabase.getInstance(applicationContext).FavoritesDao()
|
||||
|
||||
val Context.recycleBin: File get() = filesDir
|
||||
|
||||
val Context.recycleBinPath: String get() = filesDir.absolutePath
|
||||
|
@ -712,7 +715,7 @@ fun Context.getOTGFolderChildrenNames(path: String) = getOTGFolderChildren(path)
|
|||
|
||||
fun Context.getFavoritePaths(): ArrayList<String> {
|
||||
return try {
|
||||
galleryDB.FavoritesDAO().getValidFavoritePaths() as ArrayList<String>
|
||||
favoritesDB.getValidFavoritePaths() as ArrayList<String>
|
||||
} catch (e: Exception) {
|
||||
ArrayList()
|
||||
}
|
||||
|
@ -721,11 +724,10 @@ fun Context.getFavoritePaths(): ArrayList<String> {
|
|||
fun Context.getFavoriteFromPath(path: String) = Favorite(null, path, path.getFilenameFromPath(), path.getParentPath())
|
||||
|
||||
fun Context.updateFavorite(path: String, isFavorite: Boolean) {
|
||||
val favoritesDAO = galleryDB.FavoritesDAO()
|
||||
if (isFavorite) {
|
||||
favoritesDAO.insert(getFavoriteFromPath(path))
|
||||
favoritesDB.insert(getFavoriteFromPath(path))
|
||||
} else {
|
||||
favoritesDAO.deleteFavoritePath(path)
|
||||
favoritesDB.deleteFavoritePath(path)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -750,7 +752,7 @@ fun Context.deleteDBPath(mediumDao: MediumDao, path: String) {
|
|||
fun Context.deleteMediumWithPath(mediumDao: MediumDao, path: String) {
|
||||
try {
|
||||
mediumDao.deleteMediumPath(path)
|
||||
galleryDB.FavoritesDAO().deleteFavoritePath(path)
|
||||
favoritesDB.deleteFavoritePath(path)
|
||||
} catch (ignored: Exception) {
|
||||
}
|
||||
}
|
||||
|
@ -840,7 +842,7 @@ fun Context.addPathToDB(path: String) {
|
|||
|
||||
try {
|
||||
val mediumDao = galleryDB.MediumDao()
|
||||
val isFavorite = galleryDB.FavoritesDAO().isFavorite(path)
|
||||
val isFavorite = favoritesDB.isFavorite(path)
|
||||
val videoDuration = if (type == TYPE_VIDEOS) path.getVideoDuration() else 0
|
||||
val medium = Medium(null, path.getFilenameFromPath(), path, path.getParentPath(), System.currentTimeMillis(), System.currentTimeMillis(),
|
||||
File(path).length(), type, videoDuration, isFavorite, 0L)
|
||||
|
|
|
@ -3,6 +3,6 @@ package com.simplemobiletools.gallery.pro.interfaces
|
|||
import androidx.room.Dao
|
||||
|
||||
@Dao
|
||||
interface DateTakensDAO {
|
||||
interface DateTakensDao {
|
||||
|
||||
}
|
|
@ -7,7 +7,7 @@ import androidx.room.Query
|
|||
import com.simplemobiletools.gallery.pro.models.Favorite
|
||||
|
||||
@Dao
|
||||
interface FavoritesDAO {
|
||||
interface FavoritesDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insert(favorite: Favorite)
|
||||
|
||||
|
@ -25,4 +25,7 @@ interface FavoritesDAO {
|
|||
|
||||
@Query("DELETE FROM favorites WHERE full_path = :path COLLATE NOCASE")
|
||||
fun deleteFavoritePath(path: String)
|
||||
|
||||
@Query("DELETE FROM favorites")
|
||||
fun clearFavorites()
|
||||
}
|
|
@ -44,7 +44,4 @@ interface MediumDao {
|
|||
|
||||
@Query("DELETE FROM media WHERE deleted_ts != 0")
|
||||
fun clearRecycleBin()
|
||||
|
||||
@Query("UPDATE media SET is_favorite = 0")
|
||||
fun clearFavorites()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue