mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
replace lastModified mediaitem checking with latest media date taken
This commit is contained in:
parent
373e06c98f
commit
33a4b81279
4 changed files with 11 additions and 27 deletions
|
@ -37,7 +37,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.simplemobiletools:commons:2.28.7'
|
||||
compile 'com.simplemobiletools:commons:2.28.9'
|
||||
compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
|
||||
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.0'
|
||||
compile 'com.bignerdranch.android:recyclerview-multiselect:0.2'
|
||||
|
|
|
@ -56,7 +56,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
private var mStoredCropThumbnails = true
|
||||
private var mStoredScrollHorizontally = true
|
||||
private var mLoadedInitialPhotos = false
|
||||
private var mLastMediaModified = 0
|
||||
private var mLatestMediaId = 0L
|
||||
private var mLastMediaHandler = Handler()
|
||||
|
||||
private var mCurrAsyncTask: GetDirectoriesAsynctask? = null
|
||||
|
@ -428,7 +428,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
private fun gotDirectories(newDirs: ArrayList<Directory>, isFromCache: Boolean) {
|
||||
val dirs = getSortedDirectories(newDirs)
|
||||
|
||||
mLastMediaModified = getLastMediaModified()
|
||||
mLatestMediaId = getLatestMediaId()
|
||||
directories_refresh_layout.isRefreshing = false
|
||||
mIsGettingDirs = false
|
||||
|
||||
|
@ -491,9 +491,9 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
mLastMediaHandler.removeCallbacksAndMessages(null)
|
||||
mLastMediaHandler.postDelayed({
|
||||
Thread({
|
||||
val lastModified = getLastMediaModified()
|
||||
if (mLastMediaModified != lastModified) {
|
||||
mLastMediaModified = lastModified
|
||||
val mediaId = getLatestMediaId()
|
||||
if (mLatestMediaId != mediaId) {
|
||||
mLatestMediaId = mediaId
|
||||
runOnUiThread {
|
||||
getDirectories()
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
private var mStoredCropThumbnails = true
|
||||
private var mStoredScrollHorizontally = true
|
||||
private var mLastDrawnHashCode = 0
|
||||
private var mLastMediaModified = 0
|
||||
private var mLatestMediaId = 0L
|
||||
private var mLastMediaHandler = Handler()
|
||||
|
||||
companion object {
|
||||
|
@ -181,9 +181,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
mLastMediaHandler.removeCallbacksAndMessages(null)
|
||||
mLastMediaHandler.postDelayed({
|
||||
Thread({
|
||||
val lastModified = getLastMediaModified()
|
||||
if (mLastMediaModified != lastModified) {
|
||||
mLastMediaModified = lastModified
|
||||
val mediaId = getLatestMediaId()
|
||||
if (mLatestMediaId != mediaId) {
|
||||
mLatestMediaId = mediaId
|
||||
runOnUiThread {
|
||||
getMedia()
|
||||
}
|
||||
|
@ -463,7 +463,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
}
|
||||
|
||||
private fun gotMedia(media: ArrayList<Medium>, isFromCache: Boolean = false) {
|
||||
mLastMediaModified = getLastMediaModified()
|
||||
mLatestMediaId = getLatestMediaId()
|
||||
mIsGettingMedia = false
|
||||
media_refresh_layout.isRefreshing = false
|
||||
|
||||
|
|
|
@ -300,22 +300,6 @@ fun Context.getNoMediaFolders(): ArrayList<String> {
|
|||
return folders
|
||||
}
|
||||
|
||||
fun Context.getLastMediaModified(): Int {
|
||||
val max = "max"
|
||||
val uri = MediaStore.Files.getContentUri("external")
|
||||
val projection = arrayOf(MediaStore.Images.Media._ID, "MAX(${MediaStore.Images.Media.DATE_MODIFIED}) AS $max")
|
||||
var cursor: Cursor? = null
|
||||
try {
|
||||
cursor = contentResolver.query(uri, projection, null, null, null)
|
||||
if (cursor?.moveToFirst() == true) {
|
||||
return cursor.getIntValue(max)
|
||||
}
|
||||
} finally {
|
||||
cursor?.close()
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
fun Context.movePinnedDirectoriesToFront(dirs: ArrayList<Directory>): ArrayList<Directory> {
|
||||
val foundFolders = ArrayList<Directory>()
|
||||
val pinnedFolders = config.pinnedFolders
|
||||
|
|
Loading…
Reference in a new issue