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

View file

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