mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-06-05 17:00:23 +02:00
- wip: app crash when gson can not deserialize note
This commit is contained in:
@ -11,9 +11,8 @@ import com.simplemobiletools.notes.pro.R
|
||||
import com.simplemobiletools.notes.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.notes.pro.extensions.notesDB
|
||||
import com.simplemobiletools.notes.pro.extensions.parseChecklistItems
|
||||
import com.simplemobiletools.notes.pro.helpers.NoteType
|
||||
import com.simplemobiletools.notes.pro.helpers.NotesHelper
|
||||
import com.simplemobiletools.notes.pro.helpers.TYPE_CHECKLIST
|
||||
import com.simplemobiletools.notes.pro.helpers.TYPE_TEXT
|
||||
import com.simplemobiletools.notes.pro.models.Note
|
||||
import kotlinx.android.synthetic.main.dialog_import_folder.view.*
|
||||
import java.io.File
|
||||
@ -59,14 +58,14 @@ class ImportFolderDialog(val activity: SimpleActivity, val path: String, val cal
|
||||
val fileText = it.readText().trim()
|
||||
val checklistItems = fileText.parseChecklistItems()
|
||||
if (checklistItems != null) {
|
||||
saveNote(title.substringBeforeLast('.'), fileText, TYPE_CHECKLIST, "")
|
||||
saveNote(title.substringBeforeLast('.'), fileText, NoteType.TYPE_CHECKLIST.value, "")
|
||||
} else {
|
||||
if (updateFilesOnEdit) {
|
||||
activity.handleSAFDialog(path) {
|
||||
saveNote(title, value, TYPE_TEXT, storePath)
|
||||
saveNote(title, value, NoteType.TYPE_TEXT.value, storePath)
|
||||
}
|
||||
} else {
|
||||
saveNote(title, value, TYPE_TEXT, storePath)
|
||||
saveNote(title, value, NoteType.TYPE_TEXT.value, storePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,15 +11,14 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
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.helpers.TYPE_CHECKLIST
|
||||
import com.simplemobiletools.notes.pro.helpers.TYPE_TEXT
|
||||
import com.simplemobiletools.notes.pro.helpers.NoteType
|
||||
import com.simplemobiletools.notes.pro.models.Note
|
||||
import kotlinx.android.synthetic.main.dialog_new_note.view.*
|
||||
|
||||
class NewNoteDialog(val activity: Activity, callback: (note: Note) -> Unit) {
|
||||
init {
|
||||
val view = activity.layoutInflater.inflate(R.layout.dialog_new_note, null).apply {
|
||||
new_note_type.check(if (activity.config.lastCreatedNoteType == TYPE_TEXT) type_text_note.id else type_checklist.id)
|
||||
new_note_type.check(if (activity.config.lastCreatedNoteType == NoteType.TYPE_TEXT.value) type_text_note.id else type_checklist.id)
|
||||
}
|
||||
|
||||
AlertDialog.Builder(activity)
|
||||
@ -35,7 +34,7 @@ class NewNoteDialog(val activity: Activity, callback: (note: Note) -> Unit) {
|
||||
title.isEmpty() -> activity.toast(R.string.no_title)
|
||||
activity.notesDB.getNoteIdWithTitle(title) != null -> activity.toast(R.string.title_taken)
|
||||
else -> {
|
||||
val type = if (view.new_note_type.checkedRadioButtonId == view.type_checklist.id) TYPE_CHECKLIST else TYPE_TEXT
|
||||
val type = if (view.new_note_type.checkedRadioButtonId == view.type_checklist.id) NoteType.TYPE_CHECKLIST.value else NoteType.TYPE_TEXT.value
|
||||
activity.config.lastCreatedNoteType = type
|
||||
val newNote = Note(null, title, "", type)
|
||||
callback(newNote)
|
||||
|
@ -7,7 +7,7 @@ import com.simplemobiletools.commons.extensions.humanizePath
|
||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||
import com.simplemobiletools.notes.pro.R
|
||||
import com.simplemobiletools.notes.pro.activities.SimpleActivity
|
||||
import com.simplemobiletools.notes.pro.helpers.TYPE_TEXT
|
||||
import com.simplemobiletools.notes.pro.helpers.NoteType
|
||||
import com.simplemobiletools.notes.pro.models.Note
|
||||
import kotlinx.android.synthetic.main.dialog_open_file.*
|
||||
import kotlinx.android.synthetic.main.dialog_open_file.view.*
|
||||
@ -45,7 +45,7 @@ class OpenFileDialog(val activity: SimpleActivity, val path: String, val callbac
|
||||
|
||||
private fun saveNote(storeContent: String, storePath: String) {
|
||||
val filename = path.getFilenameFromPath()
|
||||
val note = Note(null, filename, storeContent, TYPE_TEXT, storePath)
|
||||
val note = Note(null, filename, storeContent, NoteType.TYPE_TEXT.value, storePath)
|
||||
callback(note)
|
||||
dialog.dismiss()
|
||||
}
|
||||
|
Reference in New Issue
Block a user