Skip to content

Commit 7b1e0a5

Browse files
committed
fix some glitches related to exporting current notes
1 parent 53340c9 commit 7b1e0a5

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ class MainActivity : SimpleActivity() {
488488
mCurrentNote.value = textToExport
489489
}
490490

491+
getPagerAdapter().updateCurrentNoteData(view_pager.currentItem, mCurrentNote.path, mCurrentNote.value)
491492
NotesHelper(this).insertOrUpdateNote(mCurrentNote)
492493
}
493494
}
@@ -532,6 +533,7 @@ class MainActivity : SimpleActivity() {
532533
if (mCurrentNote.id == note.id) {
533534
mCurrentNote.value = note.value
534535
mCurrentNote.path = note.path
536+
getPagerAdapter().updateCurrentNoteData(view_pager.currentItem, mCurrentNote.path, mCurrentNote.value)
535537
}
536538

537539
if (!it) {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ class NotesPagerAdapter(fm: FragmentManager, val notes: List<Note>, val activity
3636

3737
override fun getPageTitle(position: Int) = notes[position].title
3838

39+
fun updateCurrentNoteData(position: Int, path: String, value: String) {
40+
(fragments[position] as? TextFragment)?.apply {
41+
updateNotePath(path)
42+
updateNoteValue(value)
43+
}
44+
}
45+
3946
fun getCurrentNotesView(position: Int) = (fragments[position] as? TextFragment)?.getNotesView()
4047

4148
fun getCurrentNoteViewText(position: Int) = (fragments[position] as? TextFragment)?.getCurrentNoteViewText()

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ class TextFragment : NoteFragment() {
155155
view.text_note_view.addTextChangedListener(textWatcher)
156156
}
157157

158+
fun updateNoteValue(value: String) {
159+
note?.value = value
160+
}
161+
162+
fun updateNotePath(path: String) {
163+
note?.path = path
164+
}
165+
158166
fun getNotesView() = view.text_note_view
159167

160168
fun saveText(force: Boolean) {

0 commit comments

Comments
 (0)