renaming some variables here and there
This commit is contained in:
parent
d2c152ecd6
commit
53beff0949
11 changed files with 39 additions and 39 deletions
|
@ -677,7 +677,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
|
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
folders.filter { !getDoesFilePathExist(it.absolutePath, OTGPath) }.forEach {
|
folders.filter { !getDoesFilePathExist(it.absolutePath, OTGPath) }.forEach {
|
||||||
directoryDao.deleteDirPath(it.absolutePath)
|
directoryDB.deleteDirPath(it.absolutePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.deleteEmptyFolders) {
|
if (config.deleteEmptyFolders) {
|
||||||
|
@ -1063,7 +1063,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
if (dirPathsToRemove.isNotEmpty()) {
|
if (dirPathsToRemove.isNotEmpty()) {
|
||||||
val dirsToRemove = dirs.filter { dirPathsToRemove.contains(it.path) }
|
val dirsToRemove = dirs.filter { dirPathsToRemove.contains(it.path) }
|
||||||
dirsToRemove.forEach {
|
dirsToRemove.forEach {
|
||||||
directoryDao.deleteDirPath(it.path)
|
directoryDB.deleteDirPath(it.path)
|
||||||
}
|
}
|
||||||
dirs.removeAll(dirsToRemove)
|
dirs.removeAll(dirsToRemove)
|
||||||
setupAdapter(dirs)
|
setupAdapter(dirs)
|
||||||
|
@ -1132,7 +1132,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
// make sure to create a new thread for these operations, dont just use the common bg thread
|
// make sure to create a new thread for these operations, dont just use the common bg thread
|
||||||
Thread {
|
Thread {
|
||||||
try {
|
try {
|
||||||
directoryDao.insert(newDir)
|
directoryDB.insert(newDir)
|
||||||
if (folder != RECYCLE_BIN && folder != FAVORITES) {
|
if (folder != RECYCLE_BIN && folder != FAVORITES) {
|
||||||
mediaDB.insertAll(newMedia)
|
mediaDB.insertAll(newMedia)
|
||||||
}
|
}
|
||||||
|
@ -1346,7 +1346,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
setupAdapter(dirs)
|
setupAdapter(dirs)
|
||||||
invalidDirs.forEach {
|
invalidDirs.forEach {
|
||||||
try {
|
try {
|
||||||
directoryDao.deleteDirPath(it.path)
|
directoryDB.deleteDirPath(it.path)
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -517,7 +517,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
val paths = mMedia.filter { it is Medium }.map { (it as Medium).path } as ArrayList<String>
|
val paths = mMedia.filter { it is Medium }.map { (it as Medium).path } as ArrayList<String>
|
||||||
restoreRecycleBinPaths(paths) {
|
restoreRecycleBinPaths(paths) {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
directoryDao.deleteDirPath(RECYCLE_BIN)
|
directoryDB.deleteDirPath(RECYCLE_BIN)
|
||||||
}
|
}
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
@ -625,7 +625,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
|
|
||||||
if (mPath == FAVORITES) {
|
if (mPath == FAVORITES) {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
directoryDao.deleteDirPath(FAVORITES)
|
directoryDB.deleteDirPath(FAVORITES)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,7 +639,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
private fun deleteDBDirectory() {
|
private fun deleteDBDirectory() {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
try {
|
try {
|
||||||
directoryDao.deleteDirPath(mPath)
|
directoryDB.deleteDirPath(mPath)
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,7 +224,6 @@ class SettingsActivity : SimpleActivity() {
|
||||||
private fun setupShowHiddenItems() {
|
private fun setupShowHiddenItems() {
|
||||||
if (isRPlus() && !isExternalStorageManager()) {
|
if (isRPlus() && !isExternalStorageManager()) {
|
||||||
settings_show_hidden_items_holder.beGone()
|
settings_show_hidden_items_holder.beGone()
|
||||||
settings_manage_excluded_folders_holder.background = resources.getDrawable(R.drawable.ripple_bottom_corners, theme)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
settings_show_hidden_items.isChecked = config.showHiddenMedia
|
settings_show_hidden_items.isChecked = config.showHiddenMedia
|
||||||
|
|
|
@ -173,7 +173,7 @@ class WidgetConfigureActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
val path = directoryDao.getDirectoryThumbnail(folderPath)
|
val path = directoryDB.getDirectoryThumbnail(folderPath)
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
val signature = ObjectKey(System.currentTimeMillis().toString())
|
val signature = ObjectKey(System.currentTimeMillis().toString())
|
||||||
|
|
|
@ -266,7 +266,7 @@ class DirectoryAdapter(
|
||||||
updateDirs(dirs)
|
updateDirs(dirs)
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
try {
|
try {
|
||||||
activity.directoryDao.updateDirectoryAfterRename(firstDir.tmb, firstDir.name, firstDir.path, sourcePath)
|
activity.directoryDB.updateDirectoryAfterRename(firstDir.tmb, firstDir.name, firstDir.path, sourcePath)
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
activity.showErrorToast(e)
|
activity.showErrorToast(e)
|
||||||
|
|
|
@ -18,16 +18,16 @@ class GetMediaAsynctask(val context: Context, val mPath: String, val isPickImage
|
||||||
override fun doInBackground(vararg params: Void): ArrayList<ThumbnailItem> {
|
override fun doInBackground(vararg params: Void): ArrayList<ThumbnailItem> {
|
||||||
val pathToUse = if (showAll) SHOW_ALL else mPath
|
val pathToUse = if (showAll) SHOW_ALL else mPath
|
||||||
val folderGrouping = context.config.getFolderGrouping(pathToUse)
|
val folderGrouping = context.config.getFolderGrouping(pathToUse)
|
||||||
val fileSorting = context.config.getFolderSorting(pathToUse)
|
val folderSorting = context.config.getFolderSorting(pathToUse)
|
||||||
val getProperDateTaken = fileSorting and SORT_BY_DATE_TAKEN != 0 ||
|
val getProperDateTaken = folderSorting and SORT_BY_DATE_TAKEN != 0 ||
|
||||||
folderGrouping and GROUP_BY_DATE_TAKEN_DAILY != 0 ||
|
folderGrouping and GROUP_BY_DATE_TAKEN_DAILY != 0 ||
|
||||||
folderGrouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0
|
folderGrouping and GROUP_BY_DATE_TAKEN_MONTHLY != 0
|
||||||
|
|
||||||
val getProperLastModified = fileSorting and SORT_BY_DATE_MODIFIED != 0 ||
|
val getProperLastModified = folderSorting and SORT_BY_DATE_MODIFIED != 0 ||
|
||||||
folderGrouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 ||
|
folderGrouping and GROUP_BY_LAST_MODIFIED_DAILY != 0 ||
|
||||||
folderGrouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0
|
folderGrouping and GROUP_BY_LAST_MODIFIED_MONTHLY != 0
|
||||||
|
|
||||||
val getProperFileSize = fileSorting and SORT_BY_SIZE != 0
|
val getProperFileSize = folderSorting and SORT_BY_SIZE != 0
|
||||||
val favoritePaths = context.getFavoritePaths()
|
val favoritePaths = context.getFavoritePaths()
|
||||||
val getVideoDurations = context.config.showThumbnailVideoDuration
|
val getVideoDurations = context.config.showThumbnailVideoDuration
|
||||||
val lastModifieds = if (getProperLastModified) mediaFetcher.getLastModifieds() else HashMap()
|
val lastModifieds = if (getProperLastModified) mediaFetcher.getLastModifieds() else HashMap()
|
||||||
|
|
|
@ -460,7 +460,7 @@ fun BaseSimpleActivity.emptyTheRecycleBin(callback: (() -> Unit)? = null) {
|
||||||
try {
|
try {
|
||||||
recycleBin.deleteRecursively()
|
recycleBin.deleteRecursively()
|
||||||
mediaDB.clearRecycleBin()
|
mediaDB.clearRecycleBin()
|
||||||
directoryDao.deleteRecycleBin()
|
directoryDB.deleteRecycleBin()
|
||||||
toast(R.string.recycle_bin_emptied)
|
toast(R.string.recycle_bin_emptied)
|
||||||
callback?.invoke()
|
callback?.invoke()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ val Context.widgetsDB: WidgetsDao get() = GalleryDatabase.getInstance(applicatio
|
||||||
|
|
||||||
val Context.mediaDB: MediumDao get() = GalleryDatabase.getInstance(applicationContext).MediumDao()
|
val Context.mediaDB: MediumDao get() = GalleryDatabase.getInstance(applicationContext).MediumDao()
|
||||||
|
|
||||||
val Context.directoryDao: DirectoryDao get() = GalleryDatabase.getInstance(applicationContext).DirectoryDao()
|
val Context.directoryDB: DirectoryDao get() = GalleryDatabase.getInstance(applicationContext).DirectoryDao()
|
||||||
|
|
||||||
val Context.favoritesDB: FavoritesDao get() = GalleryDatabase.getInstance(applicationContext).FavoritesDao()
|
val Context.favoritesDB: FavoritesDao get() = GalleryDatabase.getInstance(applicationContext).FavoritesDao()
|
||||||
|
|
||||||
|
@ -397,7 +397,7 @@ fun Context.rescanFolderMediaSync(path: String) {
|
||||||
|
|
||||||
fun Context.storeDirectoryItems(items: ArrayList<Directory>) {
|
fun Context.storeDirectoryItems(items: ArrayList<Directory>) {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
directoryDao.insertAll(items)
|
directoryDB.insertAll(items)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -644,7 +644,7 @@ fun Context.getCachedDirectories(
|
||||||
}
|
}
|
||||||
|
|
||||||
val directories = try {
|
val directories = try {
|
||||||
directoryDao.getAll() as ArrayList<Directory>
|
directoryDB.getAll() as ArrayList<Directory>
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
ArrayList()
|
ArrayList()
|
||||||
}
|
}
|
||||||
|
@ -801,11 +801,11 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.removeInvalidDBDirectories(dirs: ArrayList<Directory>? = null) {
|
fun Context.removeInvalidDBDirectories(dirs: ArrayList<Directory>? = null) {
|
||||||
val dirsToCheck = dirs ?: directoryDao.getAll()
|
val dirsToCheck = dirs ?: directoryDB.getAll()
|
||||||
val OTGPath = config.OTGPath
|
val OTGPath = config.OTGPath
|
||||||
dirsToCheck.filter { !it.areFavorites() && !it.isRecycleBin() && !getDoesFilePathExist(it.path, OTGPath) && it.path != config.tempFolderPath }.forEach {
|
dirsToCheck.filter { !it.areFavorites() && !it.isRecycleBin() && !getDoesFilePathExist(it.path, OTGPath) && it.path != config.tempFolderPath }.forEach {
|
||||||
try {
|
try {
|
||||||
directoryDao.deleteDirPath(it.path)
|
directoryDB.deleteDirPath(it.path)
|
||||||
} catch (ignored: Exception) {
|
} catch (ignored: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -823,7 +823,7 @@ fun Context.updateDBMediaPath(oldPath: String, newPath: String) {
|
||||||
|
|
||||||
fun Context.updateDBDirectory(directory: Directory) {
|
fun Context.updateDBDirectory(directory: Directory) {
|
||||||
try {
|
try {
|
||||||
directoryDao.updateDirectory(
|
directoryDB.updateDirectory(
|
||||||
directory.path,
|
directory.path,
|
||||||
directory.tmb,
|
directory.tmb,
|
||||||
directory.mediaCnt,
|
directory.mediaCnt,
|
||||||
|
|
|
@ -18,7 +18,7 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.activities.MediaActivity
|
import com.simplemobiletools.gallery.pro.activities.MediaActivity
|
||||||
import com.simplemobiletools.gallery.pro.extensions.config
|
import com.simplemobiletools.gallery.pro.extensions.config
|
||||||
import com.simplemobiletools.gallery.pro.extensions.directoryDao
|
import com.simplemobiletools.gallery.pro.extensions.directoryDB
|
||||||
import com.simplemobiletools.gallery.pro.extensions.getFolderNameFromPath
|
import com.simplemobiletools.gallery.pro.extensions.getFolderNameFromPath
|
||||||
import com.simplemobiletools.gallery.pro.extensions.widgetsDB
|
import com.simplemobiletools.gallery.pro.extensions.widgetsDB
|
||||||
import com.simplemobiletools.gallery.pro.models.Widget
|
import com.simplemobiletools.gallery.pro.models.Widget
|
||||||
|
@ -45,7 +45,7 @@ class MyWidgetProvider : AppWidgetProvider() {
|
||||||
setText(R.id.widget_folder_name, context.getFolderNameFromPath(it.folderPath))
|
setText(R.id.widget_folder_name, context.getFolderNameFromPath(it.folderPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
val path = context.directoryDao.getDirectoryThumbnail(it.folderPath) ?: return@forEach
|
val path = context.directoryDB.getDirectoryThumbnail(it.folderPath) ?: return@forEach
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
.signature(path.getFileSignature())
|
.signature(path.getFileSignature())
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||||
|
|
|
@ -40,7 +40,7 @@ interface MediumDao {
|
||||||
fun deleteMediumPath(path: String)
|
fun deleteMediumPath(path: String)
|
||||||
|
|
||||||
@Query("UPDATE OR REPLACE media SET filename = :newFilename, full_path = :newFullPath, parent_path = :newParentPath WHERE full_path = :oldPath COLLATE NOCASE")
|
@Query("UPDATE OR REPLACE media SET filename = :newFilename, full_path = :newFullPath, parent_path = :newParentPath WHERE full_path = :oldPath COLLATE NOCASE")
|
||||||
fun updateMedium(newFilename: String, newFullPath: String, newParentPath: String, oldPath: String)
|
fun updateMedium(oldPath: String, newParentPath: String, newFilename: String, newFullPath: String)
|
||||||
|
|
||||||
@Query("UPDATE OR REPLACE media SET full_path = :newPath, deleted_ts = :deletedTS WHERE full_path = :oldPath COLLATE NOCASE")
|
@Query("UPDATE OR REPLACE media SET full_path = :newPath, deleted_ts = :deletedTS WHERE full_path = :oldPath COLLATE NOCASE")
|
||||||
fun updateDeleted(newPath: String, deletedTS: Long, oldPath: String)
|
fun updateDeleted(newPath: String, deletedTS: Long, oldPath: String)
|
||||||
|
|
|
@ -10,22 +10,23 @@ import com.simplemobiletools.gallery.pro.helpers.RECYCLE_BIN
|
||||||
|
|
||||||
@Entity(tableName = "directories", indices = [Index(value = ["path"], unique = true)])
|
@Entity(tableName = "directories", indices = [Index(value = ["path"], unique = true)])
|
||||||
data class Directory(
|
data class Directory(
|
||||||
@PrimaryKey(autoGenerate = true) var id: Long?,
|
@PrimaryKey(autoGenerate = true) var id: Long?,
|
||||||
@ColumnInfo(name = "path") var path: String,
|
@ColumnInfo(name = "path") var path: String,
|
||||||
@ColumnInfo(name = "thumbnail") var tmb: String,
|
@ColumnInfo(name = "thumbnail") var tmb: String,
|
||||||
@ColumnInfo(name = "filename") var name: String,
|
@ColumnInfo(name = "filename") var name: String,
|
||||||
@ColumnInfo(name = "media_count") var mediaCnt: Int,
|
@ColumnInfo(name = "media_count") var mediaCnt: Int,
|
||||||
@ColumnInfo(name = "last_modified") var modified: Long,
|
@ColumnInfo(name = "last_modified") var modified: Long,
|
||||||
@ColumnInfo(name = "date_taken") var taken: Long,
|
@ColumnInfo(name = "date_taken") var taken: Long,
|
||||||
@ColumnInfo(name = "size") var size: Long,
|
@ColumnInfo(name = "size") var size: Long,
|
||||||
@ColumnInfo(name = "location") var location: Int,
|
@ColumnInfo(name = "location") var location: Int,
|
||||||
@ColumnInfo(name = "media_types") var types: Int,
|
@ColumnInfo(name = "media_types") var types: Int,
|
||||||
@ColumnInfo(name = "sort_value") var sortValue: String,
|
@ColumnInfo(name = "sort_value") var sortValue: String,
|
||||||
|
|
||||||
// used with "Group direct subfolders" enabled
|
// used with "Group direct subfolders" enabled
|
||||||
@Ignore var subfoldersCount: Int = 0,
|
@Ignore var subfoldersCount: Int = 0,
|
||||||
@Ignore var subfoldersMediaCount: Int = 0,
|
@Ignore var subfoldersMediaCount: Int = 0,
|
||||||
@Ignore var containsMediaFilesDirectly: Boolean = true) {
|
@Ignore var containsMediaFilesDirectly: Boolean = true
|
||||||
|
) {
|
||||||
|
|
||||||
constructor() : this(null, "", "", "", 0, 0L, 0L, 0L, 0, 0, "", 0, 0)
|
constructor() : this(null, "", "", "", 0, 0L, 0L, 0L, 0, 0, "", 0, 0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue