Skip to content

Commit bbc14d4

Browse files
committed
fix #298, properly save checklist values at renaming
1 parent 2667cc4 commit bbc14d4

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,12 @@ class MainActivity : SimpleActivity() {
619619

620620
private fun addTextToCurrentNote(text: String) = getPagerAdapter().appendText(view_pager.currentItem, text)
621621

622-
private fun saveCurrentNote(force: Boolean) = getPagerAdapter().saveCurrentNote(view_pager.currentItem, force)
622+
private fun saveCurrentNote(force: Boolean) {
623+
getPagerAdapter().saveCurrentNote(view_pager.currentItem, force)
624+
if (mCurrentNote.type == TYPE_CHECKLIST) {
625+
mCurrentNote.value = getPagerAdapter().getNoteChecklistItems(view_pager.currentItem) ?: ""
626+
}
627+
}
623628

624629
private fun displayDeleteNotePrompt() {
625630
DeleteNoteDialog(this, mCurrentNote) {

app/src/main/kotlin/com/simplemobiletools/notes/pro/adapters/NotesPagerAdapter.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class NotesPagerAdapter(fm: FragmentManager, val notes: List<Note>, val activity
5757

5858
fun saveAllFragmentTexts() = fragments.values.forEach { (it as? TextFragment)?.saveText(false) }
5959

60+
fun getNoteChecklistItems(position: Int) = (fragments[position] as? ChecklistFragment)?.getChecklistItems()
61+
6062
fun undo(position: Int) = (fragments[position] as? TextFragment)?.undo()
6163

6264
fun redo(position: Int) = (fragments[position] as? TextFragment)?.redo()

app/src/main/kotlin/com/simplemobiletools/notes/pro/fragments/ChecklistFragment.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,15 @@ class ChecklistFragment : NoteFragment(), ChecklistItemsListener {
122122
}
123123
}
124124

125-
note!!.value = Gson().toJson(items)
125+
note!!.value = getChecklistItems()
126126
context?.notesDB?.insertOrUpdate(note!!)
127127
context?.updateWidgets()
128128
}
129129
}
130130
}
131131

132+
fun getChecklistItems() = Gson().toJson(items)
133+
132134
override fun saveChecklist() {
133135
saveNote()
134136
}

0 commit comments

Comments
 (0)