From 0112f39ff0a812ef6455d12cd8783e283f6d68fc Mon Sep 17 00:00:00 2001 From: merkost <konstantinlikes@gmail.com> Date: Mon, 10 Jul 2023 11:20:10 +1000 Subject: [PATCH] Created NoteTypeConverter --- .../simplemobiletools/notes/pro/models/Note.kt | 1 + .../notes/pro/models/NoteTypeConverter.kt | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 app/src/main/kotlin/com/simplemobiletools/notes/pro/models/NoteTypeConverter.kt diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/models/Note.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/models/Note.kt index 2ef46d7f..0b010063 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/models/Note.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/models/Note.kt @@ -17,6 +17,7 @@ import java.io.File */ @Serializable @Entity(tableName = "notes", indices = [(Index(value = ["id"], unique = true))]) +@TypeConverters(NoteTypeConverter::class) data class Note( @PrimaryKey(autoGenerate = true) var id: Long?, @ColumnInfo(name = "title") var title: String, diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/models/NoteTypeConverter.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/models/NoteTypeConverter.kt new file mode 100644 index 00000000..a2e5b2bb --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/models/NoteTypeConverter.kt @@ -0,0 +1,15 @@ +package com.simplemobiletools.notes.pro.models + +import androidx.room.TypeConverter + +class NoteTypeConverter { + @TypeConverter + fun fromNoteType(noteType: NoteType): Int { + return noteType.value + } + + @TypeConverter + fun toNoteType(value: Int): NoteType { + return NoteType.fromValue(value) + } +}