mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
优化
This commit is contained in:
parent
aee7cecc53
commit
d445db9f0c
@ -198,6 +198,9 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检测通知权限
|
||||||
|
*/
|
||||||
private suspend fun checkNotificationPermission() = suspendCoroutine { block ->
|
private suspend fun checkNotificationPermission() = suspendCoroutine { block ->
|
||||||
PermissionsCompat.Builder(this)
|
PermissionsCompat.Builder(this)
|
||||||
.addPermissions(Permissions.POST_NOTIFICATIONS)
|
.addPermissions(Permissions.POST_NOTIFICATIONS)
|
||||||
@ -217,13 +220,10 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
|||||||
/**
|
/**
|
||||||
* 备份同步
|
* 备份同步
|
||||||
*/
|
*/
|
||||||
private suspend fun backupSync() = suspendCoroutine { block ->
|
private fun backupSync() {
|
||||||
launch {
|
launch {
|
||||||
val lastBackupFile = withContext(IO) { AppWebDav.lastBackUp().getOrNull() }
|
val lastBackupFile =
|
||||||
if (lastBackupFile == null) {
|
withContext(IO) { AppWebDav.lastBackUp().getOrNull() } ?: return@launch
|
||||||
block.resume(null)
|
|
||||||
return@launch
|
|
||||||
}
|
|
||||||
if (lastBackupFile.lastModify - LocalConfig.lastBackup > DateUtils.MINUTE_IN_MILLIS) {
|
if (lastBackupFile.lastModify - LocalConfig.lastBackup > DateUtils.MINUTE_IN_MILLIS) {
|
||||||
LocalConfig.lastBackup = lastBackupFile.lastModify
|
LocalConfig.lastBackup = lastBackupFile.lastModify
|
||||||
alert("恢复", "webDav书源比本地新,是否恢复") {
|
alert("恢复", "webDav书源比本地新,是否恢复") {
|
||||||
@ -231,12 +231,7 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
|
|||||||
okButton {
|
okButton {
|
||||||
viewModel.restoreWebDav(lastBackupFile.displayName)
|
viewModel.restoreWebDav(lastBackupFile.displayName)
|
||||||
}
|
}
|
||||||
onDismiss {
|
|
||||||
block.resume(null)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
block.resume(null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user