Fix NPE with empty files
This commit is contained in:
parent
e26e43cd91
commit
c2ff80b9e5
|
@ -33,7 +33,7 @@ class NotesImporter(private val context: Context) {
|
|||
val json = reader.readText()
|
||||
val type = object : TypeToken<List<Note>>() {}.type
|
||||
val notes = gson.fromJson<List<Note>>(json, type)
|
||||
val totalNotes = notes.size
|
||||
val totalNotes = notes?.size ?: 0
|
||||
if (totalNotes <= 0) {
|
||||
callback.invoke(ImportResult.IMPORT_NOTHING_NEW)
|
||||
return@ensureBackgroundThread
|
||||
|
|
Loading…
Reference in New Issue