From 60bf552984d16e90b43bd0dd370aec62ec7a0c72 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 7 Nov 2018 22:40:08 +0100 Subject: [PATCH] adding a hack at first app launch to ensure proper database prepopulation --- .../com/simplemobiletools/notes/pro/helpers/NotesHelper.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/NotesHelper.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/NotesHelper.kt index 34cbf7b0..c7c804c6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/NotesHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/helpers/NotesHelper.kt @@ -2,6 +2,7 @@ package com.simplemobiletools.notes.pro.helpers import android.app.Activity import com.simplemobiletools.notes.pro.R +import com.simplemobiletools.notes.pro.extensions.config import com.simplemobiletools.notes.pro.extensions.notesDB import com.simplemobiletools.notes.pro.models.Note import java.io.File @@ -9,6 +10,12 @@ import java.io.File class NotesHelper(val activity: Activity) { fun getNotes(callback: (notes: ArrayList) -> Unit) { Thread { + // make sure the initial note has enough time to be precreated + if (activity.config.appRunCount == 1) { + activity.notesDB.getNotes() + Thread.sleep(200) + } + val notes = activity.notesDB.getNotes() as ArrayList val notesToDelete = ArrayList(notes.size) notes.forEach {