Skip to content

Commit

Permalink
Do not force-sync when switching to another activity
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomas2 committed Jun 11, 2023
1 parent 0dc6396 commit 275ec02
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,6 @@ class MainBibleActivity : CustomTitlebarActivityBase() {

override fun onPause() {
CommonUtils.windowControl.windowRepository.saveIntoDb(false)
if(CommonUtils.isGoogleDriveSyncEnabled) {
syncJob?.cancel(StopSync())
syncJob = null
lifecycleScope.launch { DeviceSynchronize.start() }
}
fullScreen = false;
if(CommonUtils.showCalculator) {
(window.decorView as ViewGroup).removeView(binding.root)
Expand Down Expand Up @@ -1268,7 +1263,9 @@ class MainBibleActivity : CustomTitlebarActivityBase() {
*/
override fun onRestart() {
super.onRestart()
startSync()
if(syncJob != null) {
startSync()
}
if (mWholeAppWasInBackground) {
mWholeAppWasInBackground = false
refreshIfNightModeChange()
Expand All @@ -1286,7 +1283,11 @@ class MainBibleActivity : CustomTitlebarActivityBase() {
if(now - lastSynchronized > syncInterval) {
synchronize(true)
}
syncJob = lifecycleScope.launch { periodicSync() }
if(syncJob != null) {
Log.e(TAG, "syncJob already exists")
} else {
syncJob = lifecycleScope.launch { periodicSync() }
}
}
}
}
Expand Down Expand Up @@ -1338,6 +1339,11 @@ class MainBibleActivity : CustomTitlebarActivityBase() {
fun onEvent(event: AppToBackgroundEvent) {
if (event.isMovedToBackground) {
mWholeAppWasInBackground = true
syncJob?.cancel(StopSync())
syncJob = null
if(CommonUtils.isGoogleDriveSyncEnabled) {
lifecycleScope.launch { DeviceSynchronize.start() }
}
}
else {
updateActions()
Expand Down

0 comments on commit 275ec02

Please sign in to comment.