fetch latest media ID at creating the app to avoid duplicate refreshing

This commit is contained in:
tibbi 2018-02-19 23:25:29 +01:00
parent 6f84478bfa
commit 93ba5d67de
2 changed files with 10 additions and 4 deletions

View file

@ -96,6 +96,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
}
mIsPasswordProtectionPending = config.appPasswordProtectionOn
setupLatestMediaId()
}
override fun onStart() {
@ -553,9 +554,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
private fun gotDirectories(newDirs: ArrayList<Directory>, isFromCache: Boolean) {
if (!isFromCache) {
Thread {
mLatestMediaId = getLatestMediaId()
}.start()
setupLatestMediaId()
}
val dirs = getSortedDirectories(newDirs)
@ -633,6 +632,12 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
private fun getBubbleTextItem(index: Int) = getRecyclerAdapter().dirs.getOrNull(index)?.getBubbleText() ?: ""
private fun setupLatestMediaId() {
Thread {
mLatestMediaId = getLatestMediaId()
}.start()
}
private fun checkLastMediaChanged() {
if (isActivityDestroyed())
return

View file

@ -113,8 +113,9 @@ class MediaFetcher(val context: Context) {
private fun getSelectionArgsQuery(path: String): Array<String>? {
return if (path.isEmpty()) {
if (context.isAndroidFour())
if (context.isAndroidFour()) {
return null
}
if (context.hasExternalSDCard()) {
arrayOf("${context.internalStoragePath}/%", "${context.sdCardPath}/%")