check latest media date id too at fetching new files

This commit is contained in:
tibbi 2018-03-15 19:31:04 +01:00
parent 64b4fdece3
commit e6b11a80b1
3 changed files with 11 additions and 3 deletions

View file

@ -46,7 +46,7 @@ ext {
} }
dependencies { 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.theartofdev.edmodo:android-image-cropper:2.6.0'
implementation 'com.android.support:multidex:1.0.3' implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.code.gson:gson:2.8.2' implementation 'com.google.code.gson:gson:2.8.2'

View file

@ -61,6 +61,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
private var mLoadedInitialPhotos = false private var mLoadedInitialPhotos = false
private var mIsPasswordProtectionPending = false private var mIsPasswordProtectionPending = false
private var mLatestMediaId = 0L private var mLatestMediaId = 0L
private var mLatestMediaDateId = 0L
private var mLastMediaHandler = Handler() private var mLastMediaHandler = Handler()
private var mTempShowHiddenHandler = Handler() private var mTempShowHiddenHandler = Handler()
private var mCurrAsyncTask: GetDirectoriesAsynctask? = null private var mCurrAsyncTask: GetDirectoriesAsynctask? = null
@ -653,6 +654,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
Thread { Thread {
if (hasPermission(PERMISSION_READ_STORAGE)) { if (hasPermission(PERMISSION_READ_STORAGE)) {
mLatestMediaId = getLatestMediaId() mLatestMediaId = getLatestMediaId()
mLatestMediaDateId = getLatestMediaByDateId()
} }
}.start() }.start()
} }
@ -666,8 +668,10 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
mLastMediaHandler.postDelayed({ mLastMediaHandler.postDelayed({
Thread { Thread {
val mediaId = getLatestMediaId() val mediaId = getLatestMediaId()
if (mLatestMediaId != mediaId) { val mediaDateId = getLatestMediaByDateId()
if (mLatestMediaId != mediaId || mLatestMediaDateId != mediaDateId) {
mLatestMediaId = mediaId mLatestMediaId = mediaId
mLatestMediaDateId = mediaDateId
runOnUiThread { runOnUiThread {
getDirectories() getDirectories()
} }

View file

@ -58,6 +58,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
private var mLoadedInitialPhotos = false private var mLoadedInitialPhotos = false
private var mIsSearchOpen = false private var mIsSearchOpen = false
private var mLatestMediaId = 0L private var mLatestMediaId = 0L
private var mLatestMediaDateId = 0L
private var mLastMediaHandler = Handler() private var mLastMediaHandler = Handler()
private var mTempShowHiddenHandler = Handler() private var mTempShowHiddenHandler = Handler()
private var mCurrAsyncTask: GetMediaAsynctask? = null private var mCurrAsyncTask: GetMediaAsynctask? = null
@ -359,8 +360,10 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
mLastMediaHandler.postDelayed({ mLastMediaHandler.postDelayed({
Thread { Thread {
val mediaId = getLatestMediaId() val mediaId = getLatestMediaId()
if (mLatestMediaId != mediaId) { val mediaDateId = getLatestMediaByDateId()
if (mLatestMediaId != mediaId || mLatestMediaDateId != mediaDateId) {
mLatestMediaId = mediaId mLatestMediaId = mediaId
mLatestMediaDateId = mediaDateId
runOnUiThread { runOnUiThread {
getMedia() getMedia()
} }
@ -632,6 +635,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
private fun gotMedia(media: ArrayList<Medium>, isFromCache: Boolean = false) { private fun gotMedia(media: ArrayList<Medium>, isFromCache: Boolean = false) {
Thread { Thread {
mLatestMediaId = getLatestMediaId() mLatestMediaId = getLatestMediaId()
mLatestMediaDateId = getLatestMediaByDateId()
}.start() }.start()
mIsGettingMedia = false mIsGettingMedia = false