move the function for getting note value in the note model itself

This commit is contained in:
tibbi
2018-04-05 21:55:03 +02:00
parent 696858e2bc
commit 5ca8290c97
4 changed files with 34 additions and 34 deletions

View File

@ -1,3 +1,18 @@
package com.simplemobiletools.notes.models
data class Note(var id: Int, var title: String, var value: String, val type: Int, var path: String = "")
import java.io.File
import java.io.FileNotFoundException
data class Note(var id: Int, var title: String, var value: String, val type: Int, var path: String = "") {
fun getNoteStoredValue(): String? {
return if (path.isNotEmpty()) {
return try {
File(path).readText()
} catch (e: FileNotFoundException) {
null
}
} else {
value
}
}
}