diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index cdf8b2186..2c7b24435 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -39,7 +39,6 @@ import com.simplemobiletools.gallery.pro.interfaces.DirectoryDao import com.simplemobiletools.gallery.pro.interfaces.DirectoryOperationsListener import com.simplemobiletools.gallery.pro.interfaces.MediumDao import com.simplemobiletools.gallery.pro.jobs.NewPhotoFetcher -import com.simplemobiletools.gallery.pro.models.AlbumCover import com.simplemobiletools.gallery.pro.models.Directory import com.simplemobiletools.gallery.pro.models.Medium import kotlinx.android.synthetic.main.activity_main.* @@ -1007,25 +1006,6 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { directories_grid.beVisibleIf(directories_empty_text_label.isGone()) } - private fun createDirectoryFromMedia(path: String, curMedia: ArrayList, albumCovers: ArrayList, hiddenString: String, - includedFolders: MutableSet, isSortingAscending: Boolean, getProperFileSize: Boolean): Directory { - var thumbnail = curMedia.firstOrNull { File(it.path).exists() }?.path ?: "" - albumCovers.forEach { - if (it.path == path && File(it.tmb).exists()) { - thumbnail = it.tmb - } - } - - val firstItem = curMedia.first() - val lastItem = curMedia.last() - val dirName = checkAppendingHidden(path, hiddenString, includedFolders) - val lastModified = if (isSortingAscending) Math.min(firstItem.modified, lastItem.modified) else Math.max(firstItem.modified, lastItem.modified) - val dateTaken = if (isSortingAscending) Math.min(firstItem.taken, lastItem.taken) else Math.max(firstItem.taken, lastItem.taken) - val size = if (getProperFileSize) curMedia.sumByLong { it.size } else 0L - val mediaTypes = curMedia.getDirMediaTypes() - return Directory(null, path, thumbnail, dirName, curMedia.size, lastModified, dateTaken, size, getPathLocation(path), mediaTypes) - } - private fun setupAdapter(dirs: ArrayList, textToSearch: String = "") { val currAdapter = directories_grid.adapter val distinctDirs = dirs.distinctBy { it.path.getDistinctPath() }.toMutableList() as ArrayList diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index 02d2e2aca..78aa74824 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -28,6 +28,7 @@ import com.simplemobiletools.gallery.pro.helpers.* import com.simplemobiletools.gallery.pro.interfaces.DirectoryDao import com.simplemobiletools.gallery.pro.interfaces.MediumDao import com.simplemobiletools.gallery.pro.interfaces.WidgetsDao +import com.simplemobiletools.gallery.pro.models.AlbumCover import com.simplemobiletools.gallery.pro.models.Directory import com.simplemobiletools.gallery.pro.models.Medium import com.simplemobiletools.gallery.pro.models.ThumbnailItem @@ -786,3 +787,22 @@ fun Context.addPathToDB(path: String) { } }.start() } + +fun Context.createDirectoryFromMedia(path: String, curMedia: ArrayList, albumCovers: ArrayList, hiddenString: String, + includedFolders: MutableSet, isSortingAscending: Boolean, getProperFileSize: Boolean): Directory { + var thumbnail = curMedia.firstOrNull { File(it.path).exists() }?.path ?: "" + albumCovers.forEach { + if (it.path == path && File(it.tmb).exists()) { + thumbnail = it.tmb + } + } + + val firstItem = curMedia.first() + val lastItem = curMedia.last() + val dirName = checkAppendingHidden(path, hiddenString, includedFolders) + val lastModified = if (isSortingAscending) Math.min(firstItem.modified, lastItem.modified) else Math.max(firstItem.modified, lastItem.modified) + val dateTaken = if (isSortingAscending) Math.min(firstItem.taken, lastItem.taken) else Math.max(firstItem.taken, lastItem.taken) + val size = if (getProperFileSize) curMedia.sumByLong { it.size } else 0L + val mediaTypes = curMedia.getDirMediaTypes() + return Directory(null, path, thumbnail, dirName, curMedia.size, lastModified, dateTaken, size, getPathLocation(path), mediaTypes) +}