diff --git a/sdk/config/gradle/versioning.gradle b/sdk/config/gradle/versioning.gradle index 0e54595..ab5cb42 100644 --- a/sdk/config/gradle/versioning.gradle +++ b/sdk/config/gradle/versioning.gradle @@ -1,7 +1,7 @@ ext.versions = [ // Main SDK - 'sdk': '4.0.13', + 'sdk': '4.0.14', // Build time plugins 'androidgradleplugin': '3.4.2', diff --git a/sdk/src/main/java/me/digi/sdk/Init.kt b/sdk/src/main/java/me/digi/sdk/Init.kt index e042c3f..f0cceb4 100644 --- a/sdk/src/main/java/me/digi/sdk/Init.kt +++ b/sdk/src/main/java/me/digi/sdk/Init.kt @@ -652,53 +652,56 @@ class Init( DMELog.d("Fetching file list.") if (activeSyncStatus != FileList.SyncStatus.COMPLETED()) { - readFileList(userAccessToken) { fileList, listFetchError -> + Handler(Looper.getMainLooper()).postDelayed({ + readFileList(userAccessToken) { fileList, listFetchError -> - when { - fileList != null -> DMELog.d("File list obtained; Sync syncStatus is ${fileList.syncStatus.rawValue}.") - listFetchError != null -> DMELog.d("Error fetching file list: ${listFetchError.message}.") - } + when { + fileList != null -> DMELog.d("File list obtained; Sync syncStatus is ${fileList.syncStatus.rawValue}.") + listFetchError != null -> DMELog.d("Error fetching file list: ${listFetchError.message}.") + } - val syncStatus = fileList?.syncStatus ?: FileList.SyncStatus.RUNNING() + val syncStatus = fileList?.syncStatus ?: FileList.SyncStatus.RUNNING() - latestFileList = fileList - val updatedFileIds = fileListItemCache?.updateCacheWithItemsAndDeduceChanges( - fileList?.fileList.orEmpty() - ).orEmpty() + latestFileList = fileList + val updatedFileIds = fileListItemCache?.updateCacheWithItemsAndDeduceChanges( + fileList?.fileList.orEmpty() + ).orEmpty() - DMELog.i( - "${ - fileList?.fileList.orEmpty().count() - } files discovered. Of these, ${updatedFileIds.count()} have updates and need downloading." - ) - - if (updatedFileIds.count() > 0 && fileList != null) { - fileListUpdateHandler?.invoke(fileList, updatedFileIds) - stalePollCount = 0 - } else if (++stalePollCount == max(configuration.maxStalePolls, 20)) { - fileListCompletionHandler?.invoke( - fileList, - SDKError.FileListPollingTimeout() + DMELog.i( + "${ + fileList?.fileList.orEmpty().count() + } files discovered. Of these, ${updatedFileIds.count()} have updates and need downloading." ) - return@readFileList - } - when (syncStatus) { - FileList.SyncStatus.PENDING(), - FileList.SyncStatus.RUNNING() -> { - DMELog.i("Sync still in progress, continuing to poll for updates.") - scheduleNextPoll(userAccessToken) + if (updatedFileIds.count() > 0 && fileList != null) { + fileListUpdateHandler?.invoke(fileList, updatedFileIds) + stalePollCount = 0 + } else if (++stalePollCount == max(configuration.maxStalePolls, 20)) { + fileListCompletionHandler?.invoke( + fileList, + SDKError.FileListPollingTimeout() + ) + return@readFileList } - FileList.SyncStatus.COMPLETED(), - FileList.SyncStatus.PARTIAL() -> fileListCompletionHandler?.invoke( - fileList, - listFetchError - ) - else -> Unit + + when (syncStatus) { + FileList.SyncStatus.PENDING(), + FileList.SyncStatus.RUNNING() -> { + DMELog.i("Sync still in progress, continuing to poll for updates.") + scheduleNextPoll(userAccessToken) + } + FileList.SyncStatus.COMPLETED(), + FileList.SyncStatus.PARTIAL() -> fileListCompletionHandler?.invoke( + fileList, + listFetchError + ) + else -> Unit + } + + activeSyncStatus = syncStatus } - activeSyncStatus = syncStatus - } + }, 1000) } }