mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-22 11:30:10 +01:00
Removed onProgress
This commit is contained in:
parent
3137d6273b
commit
6bd9500c8c
@ -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()
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user