feat: 优化代码

pull/123/head
kunfei 5 years ago
parent f461806b0d
commit f1caa4abb1
  1. 14
      app/src/main/java/io/legado/app/ui/config/BackupRestoreUi.kt

@ -78,9 +78,7 @@ object BackupRestoreUi {
} }
fun selectBackupFolder(fragment: Fragment, requestCode: Int = selectFolderRequestCode) { fun selectBackupFolder(fragment: Fragment, requestCode: Int = selectFolderRequestCode) {
FilePicker.selectFolder(fragment, requestCode) { FilePicker.selectFolder(fragment, requestCode)
backupUsePermission(fragment, requestCode = requestCode)
}
} }
fun restore(fragment: Fragment) { fun restore(fragment: Fragment) {
@ -97,13 +95,13 @@ object BackupRestoreUi {
Restore.restore(fragment.requireContext(), backupPath) Restore.restore(fragment.requireContext(), backupPath)
fragment.toast(R.string.restore_success) fragment.toast(R.string.restore_success)
} else { } else {
selectRestoreFolder(fragment) selectBackupFolder(fragment, restoreSelectRequestCode)
} }
} else { } else {
restoreUsePermission(fragment, backupPath) restoreUsePermission(fragment, backupPath)
} }
} else { } else {
selectRestoreFolder(fragment) selectBackupFolder(fragment, restoreSelectRequestCode)
} }
} }
} }
@ -124,12 +122,6 @@ object BackupRestoreUi {
.request() .request()
} }
private fun selectRestoreFolder(fragment: Fragment) {
FilePicker.selectFolder(fragment, restoreSelectRequestCode) {
restoreUsePermission(fragment)
}
}
fun importOldData(fragment: Fragment) { fun importOldData(fragment: Fragment) {
FilePicker.selectFolder(fragment, oldDataRequestCode) { FilePicker.selectFolder(fragment, oldDataRequestCode) {
importOldUsePermission(fragment) importOldUsePermission(fragment)

Loading…
Cancel
Save