Add ability to stop restore

This commit is contained in:
Moez Bhatti
2018-09-01 02:48:54 -04:00
parent 8c008acd9c
commit dc3e54a85a
6 changed files with 26 additions and 13 deletions
@@ -115,6 +115,7 @@ class BackupController : QkController<BackupView, BackupState, BackupPresenter>(
progressTitle.setText(R.string.backup_backing_up)
progressSummary.text = state.backupProgress.getLabel(activity!!)
progressSummary.isVisible = progressSummary.text.isNotEmpty()
progressCancel.isVisible = false
val running = (state.backupProgress as? BackupRepository.Progress.Running)
progressBar.isVisible = state.backupProgress.indeterminate || running?.max ?: 0 > 0
progressBar.isIndeterminate = state.backupProgress.indeterminate
@@ -129,6 +130,7 @@ class BackupController : QkController<BackupView, BackupState, BackupPresenter>(
progressTitle.setText(R.string.backup_restoring)
progressSummary.text = state.restoreProgress.getLabel(activity!!)
progressSummary.isVisible = progressSummary.text.isNotEmpty()
progressCancel.isVisible = true
val running = (state.restoreProgress as? BackupRepository.Progress.Running)
progressBar.isVisible = state.restoreProgress.indeterminate || running?.max ?: 0 > 0
progressBar.isIndeterminate = state.restoreProgress.indeterminate
@@ -103,7 +103,7 @@ class BackupPresenter @Inject constructor(
view.stopRestoreConfirmed()
.autoDisposable(view.scope())
.subscribe()
.subscribe { backupRepo.stopRestore() }
view.fabClicks()
.withLatestFrom(billingManager.upgradeStatus) { _, upgraded -> upgraded }
@@ -86,19 +86,15 @@ class RestoreBackupService : Service() {
when (progress) {
is BackupRepository.Progress.Idle -> stop()
is BackupRepository.Progress.Running -> {
notification
.setProgress(progress.max, progress.count, progress.indeterminate)
.setContentText(progress.getLabel(this))
notificationManager.notify(NOTIFICATION_ID, notification.build())
}
is BackupRepository.Progress.Running -> notification
.setProgress(progress.max, progress.count, progress.indeterminate)
.setContentText(progress.getLabel(this))
.let { notificationManager.notify(NOTIFICATION_ID, it.build()) }
else -> {
notification
.setProgress(0, 0, progress.indeterminate)
.setContentText(progress.getLabel(this))
notificationManager.notify(NOTIFICATION_ID, notification.build())
}
else -> notification
.setProgress(0, 0, progress.indeterminate)
.setContentText(progress.getLabel(this))
.let { notificationManager.notify(NOTIFICATION_ID, it.build()) }
}
}