From e6b11a80b1136496616da843a5d60f8a43cfb29b Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 15 Mar 2018 19:31:04 +0100 Subject: [PATCH] check latest media date id too at fetching new files --- app/build.gradle | 2 +- .../simplemobiletools/gallery/activities/MainActivity.kt | 6 +++++- .../simplemobiletools/gallery/activities/MediaActivity.kt | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 8d84e7283..43477f528 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -46,7 +46,7 @@ ext { } dependencies { - implementation 'com.simplemobiletools:commons:3.16.1' + implementation 'com.simplemobiletools:commons:3.16.2' implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0' implementation 'com.android.support:multidex:1.0.3' implementation 'com.google.code.gson:gson:2.8.2' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt index 77a9a0e4a..8ebbc88da 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -61,6 +61,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private var mLoadedInitialPhotos = false private var mIsPasswordProtectionPending = false private var mLatestMediaId = 0L + private var mLatestMediaDateId = 0L private var mLastMediaHandler = Handler() private var mTempShowHiddenHandler = Handler() private var mCurrAsyncTask: GetDirectoriesAsynctask? = null @@ -653,6 +654,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { Thread { if (hasPermission(PERMISSION_READ_STORAGE)) { mLatestMediaId = getLatestMediaId() + mLatestMediaDateId = getLatestMediaByDateId() } }.start() } @@ -666,8 +668,10 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { mLastMediaHandler.postDelayed({ Thread { val mediaId = getLatestMediaId() - if (mLatestMediaId != mediaId) { + val mediaDateId = getLatestMediaByDateId() + if (mLatestMediaId != mediaId || mLatestMediaDateId != mediaDateId) { mLatestMediaId = mediaId + mLatestMediaDateId = mediaDateId runOnUiThread { getDirectories() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 5b5d07f84..dc6d589d8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -58,6 +58,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private var mLoadedInitialPhotos = false private var mIsSearchOpen = false private var mLatestMediaId = 0L + private var mLatestMediaDateId = 0L private var mLastMediaHandler = Handler() private var mTempShowHiddenHandler = Handler() private var mCurrAsyncTask: GetMediaAsynctask? = null @@ -359,8 +360,10 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { mLastMediaHandler.postDelayed({ Thread { val mediaId = getLatestMediaId() - if (mLatestMediaId != mediaId) { + val mediaDateId = getLatestMediaByDateId() + if (mLatestMediaId != mediaId || mLatestMediaDateId != mediaDateId) { mLatestMediaId = mediaId + mLatestMediaDateId = mediaDateId runOnUiThread { getMedia() } @@ -632,6 +635,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { private fun gotMedia(media: ArrayList, isFromCache: Boolean = false) { Thread { mLatestMediaId = getLatestMediaId() + mLatestMediaDateId = getLatestMediaByDateId() }.start() mIsGettingMedia = false