Refactored ArrayList to List

This commit is contained in:
merkost 2023-07-07 21:42:47 +10:00
parent 8c99986e25
commit 66546df0f1
2 changed files with 4 additions and 4 deletions

View File

@ -67,7 +67,7 @@ class MainActivity : SimpleActivity() {
private val PICK_EXPORT_NOTES_INTENT = 4 private val PICK_EXPORT_NOTES_INTENT = 4
private lateinit var mCurrentNote: Note private lateinit var mCurrentNote: Note
private var mNotes = ArrayList<Note>() private var mNotes = listOf<Note>()
private var mAdapter: NotesPagerAdapter? = null private var mAdapter: NotesPagerAdapter? = null
private var noteViewWithTextSelected: MyEditText? = null private var noteViewWithTextSelected: MyEditText? = null
private var saveNoteButton: MenuItem? = null private var saveNoteButton: MenuItem? = null

View File

@ -13,7 +13,7 @@ import com.simplemobiletools.notes.pro.models.Note
import java.io.File import java.io.File
class NotesHelper(val context: Context) { class NotesHelper(val context: Context) {
fun getNotes(callback: (notes: ArrayList<Note>) -> Unit) { fun getNotes(callback: (notes: List<Note>) -> Unit) {
ensureBackgroundThread { ensureBackgroundThread {
// make sure the initial note has enough time to be precreated // make sure the initial note has enough time to be precreated
if (context.config.appRunCount <= 1) { if (context.config.appRunCount <= 1) {
@ -21,8 +21,8 @@ class NotesHelper(val context: Context) {
Thread.sleep(200) Thread.sleep(200)
} }
val notes = context.notesDB.getNotes() as ArrayList<Note> val notes = context.notesDB.getNotes().toMutableList()
val notesToDelete = ArrayList<Note>(notes.size) val notesToDelete = mutableListOf<Note>()
notes.forEach { notes.forEach {
if (it.path.isNotEmpty()) { if (it.path.isNotEmpty()) {
if (!it.path.startsWith("content://") && !File(it.path).exists()) { if (!it.path.startsWith("content://") && !File(it.path).exists()) {