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() { private fun tryExportEvents() {
handlePermission(PERMISSION_WRITE_STORAGE) { handlePermission(PERMISSION_WRITE_STORAGE) {
if (it) { if (it) {
exportEvents() 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)
private fun exportEvents() { } else {
ExportEventsDialog(this, config.lastExportPath, false) { exportPastEvents, file, eventTypes -> getFileOutputStream(file.toFileDirItem(this), true) {
ensureBackgroundThread { IcsExporter().exportEvents(this, it, events, true) {
val events = eventsHelper.getEventsToExport(exportPastEvents, eventTypes) toast(when (it) {
if (events.isEmpty()) { IcsExporter.ExportResult.EXPORT_OK -> R.string.exporting_successful
toast(R.string.no_entries_for_exporting) IcsExporter.ExportResult.EXPORT_PARTIAL -> R.string.exporting_some_entries_failed
} else { else -> R.string.exporting_failed
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.* import java.util.*
class ExportEventsDialog(val activity: SimpleActivity, val path: String, val hidePath: Boolean, 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 private var realPath = if (path.isEmpty()) activity.internalStoragePath else path
val config = activity.config 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 config.exportPastEvents = view.export_events_checkbox.isChecked
val eventTypes = (view.export_events_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsList() val eventTypes = (view.export_events_types_list.adapter as FilterEventTypeAdapter).getSelectedItemsList()
callback(view.export_events_checkbox.isChecked, file, eventTypes) callback(file, eventTypes)
dismiss() dismiss()
} }
else -> activity.toast(R.string.invalid_name) else -> activity.toast(R.string.invalid_name)