do not pass exportPastEvents in the Export dialogs callback

This commit is contained in:
tibbi 2020-03-17 16:51:03 +01:00
parent a7d8c88174
commit dabbe0dff1
2 changed files with 17 additions and 21 deletions

View File

@ -783,25 +783,21 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
private fun tryExportEvents() {
handlePermission(PERMISSION_WRITE_STORAGE) {
if (it) {
exportEvents()
}
}
}
private fun exportEvents() {
ExportEventsDialog(this, config.lastExportPath, false) { exportPastEvents, file, eventTypes ->
ensureBackgroundThread {
val events = eventsHelper.getEventsToExport(exportPastEvents, eventTypes)
if (events.isEmpty()) {
toast(R.string.no_entries_for_exporting)
} else {
getFileOutputStream(file.toFileDirItem(this), true) {
IcsExporter().exportEvents(this, it, events, true) {
toast(when (it) {
IcsExporter.ExportResult.EXPORT_OK -> R.string.exporting_successful
IcsExporter.ExportResult.EXPORT_PARTIAL -> R.string.exporting_some_entries_failed
else -> R.string.exporting_failed
})
ExportEventsDialog(this, config.lastExportPath, false) { file, eventTypes ->
ensureBackgroundThread {
val events = eventsHelper.getEventsToExport(config.exportPastEvents, eventTypes)
if (events.isEmpty()) {
toast(R.string.no_entries_for_exporting)
} else {
getFileOutputStream(file.toFileDirItem(this), true) {
IcsExporter().exportEvents(this, it, events, true) {
toast(when (it) {
IcsExporter.ExportResult.EXPORT_OK -> R.string.exporting_successful
IcsExporter.ExportResult.EXPORT_PARTIAL -> R.string.exporting_some_entries_failed
else -> R.string.exporting_failed
})
}
}
}
}
}

View File

@ -15,7 +15,7 @@ import java.io.File
import java.util.*
class ExportEventsDialog(val activity: SimpleActivity, val path: String, val hidePath: Boolean,
val callback: (exportPastEvents: Boolean, file: File, eventTypes: ArrayList<Long>) -> Unit) {
val callback: (file: File, eventTypes: ArrayList<Long>) -> Unit) {
private var realPath = if (path.isEmpty()) activity.internalStoragePath else path
val config = activity.config
@ -72,7 +72,7 @@ class ExportEventsDialog(val activity: SimpleActivity, val path: String, val hid
config.exportPastEvents = view.export_events_checkbox.isChecked
val eventTypes = (view.export_events_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsList()
callback(view.export_events_checkbox.isChecked, file, eventTypes)
callback(file, eventTypes)
dismiss()
}
else -> activity.toast(R.string.invalid_name)