Removed onProgress

This commit is contained in:
Agnieszka C 2022-03-08 13:46:44 +01:00
parent 3137d6273b
commit 6bd9500c8c
2 changed files with 2 additions and 6 deletions

View File

@ -16,7 +16,7 @@ class NotesExporter(private val context: Context) {
private val gson = Gson()
fun exportNotes(outputStream: OutputStream?, onProgress: (total: Int, current: Int) -> Unit = { _, _ -> }, callback: (result: ExportResult) -> Unit) {
fun exportNotes(outputStream: OutputStream?, callback: (result: ExportResult) -> Unit) {
ensureBackgroundThread {
if (outputStream == null) {
callback.invoke(ExportResult.EXPORT_FAIL)
@ -28,13 +28,11 @@ class NotesExporter(private val context: Context) {
var written = 0
writer.beginArray()
val notes = context.notesDB.getNotes() as ArrayList<Note>
val totalNotes = notes.size
for (note in notes) {
if (note.protectionType === PROTECTION_NONE) {
val noteToSave = getNoteToExport(note)
writer.jsonValue(gson.toJson(noteToSave))
written++
onProgress.invoke(totalNotes, written)
}
}
writer.endArray()

View File

@ -18,7 +18,7 @@ class NotesImporter(private val context: Context) {
private var notesImported = 0
private var notesFailed = 0
fun importNotes(path: String, onProgress: (total: Int, current: Int) -> Unit = { _, _ -> }, callback: (result: ImportResult) -> Unit) {
fun importNotes(path: String, callback: (result: ImportResult) -> Unit) {
ensureBackgroundThread {
try {
val inputStream = if (path.contains("/")) {
@ -37,13 +37,11 @@ class NotesImporter(private val context: Context) {
return@ensureBackgroundThread
}
onProgress.invoke(totalNotes, notesImported)
for (note in notes) {
val exists = context.notesDB.getNoteIdWithTitle(note.title) != null
if (!exists) {
context.notesDB.insertOrUpdate(note)
notesImported++
onProgress.invoke(totalNotes, notesImported)
}
}
}