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 f1a8a0380..37fcd87af 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MainActivity.kt @@ -48,6 +48,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { private var mIsGettingDirs = false private var mStoredAnimateGifs = true private var mStoredCropThumbnails = true + private var mLoadedInitialPhotos = false private var mCurrAsyncTask: GetDirectoriesAsynctask? = null @@ -165,11 +166,13 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener { val dirs = Gson().fromJson>(config.directories, token) ?: ArrayList(1) if (dirs.size == 0) { directories_refresh_layout.isRefreshing = true - } else { + } else if (!mLoadedInitialPhotos) { + mLoadedInitialPhotos = true gotDirectories(dirs) return } + mLoadedInitialPhotos = true mCurrAsyncTask = GetDirectoriesAsynctask(applicationContext, mIsPickVideoIntent || mIsGetVideoContentIntent, mIsPickImageIntent || mIsGetImageContentIntent) { gotDirectories(it) } 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 be252b463..dfaa19ccf 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -217,18 +217,17 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { return mIsGettingMedia = true - mLoadedInitialPhotos = true val token = object : TypeToken>() {}.type val media = Gson().fromJson>(config.loadFolderMedia(mPath), token) ?: ArrayList(1) if (media.size == 0) { media_refresh_layout.isRefreshing = true - } else { - if (!mLoadedInitialPhotos) { - gotMedia(media) - return - } + } else if (!mLoadedInitialPhotos) { + mLoadedInitialPhotos = true + gotMedia(media) + return } + mLoadedInitialPhotos = true mCurrAsyncTask = GetMediaAsynctask(applicationContext, mPath, mIsGetVideoIntent, mIsGetImageIntent, mShowAll) { gotMedia(it) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt index 6101f80fd..420fcc0ee 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/models/Directory.kt @@ -9,7 +9,7 @@ import java.io.Serializable data class Directory(val path: String, val thumbnail: String, val name: String, var mediaCnt: Int, val date_modified: Long, val date_taken: Long, var size: Long) : Serializable, Comparable { companion object { - private val serialVersionUID = -6553649863575455L + private val serialVersionUID = -6553345863575455L var sorting: Int = 0 }