Skip to content

Commit dbdfc7b

Browse files
committed
minor code cleanup
1 parent 6360626 commit dbdfc7b

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,22 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
6969
}
7070

7171
private fun handleText(text: String) {
72-
val notes = DBHelper.newInstance(this@MainActivity).getNotes()
72+
val notes = mDb.getNotes()
7373
val list = arrayListOf<RadioItem>().apply {
7474
add(RadioItem(0, getString(R.string.create_new_note)))
75-
notes.forEachIndexed { index, note -> add(RadioItem(index + 1, note.title)) }
75+
notes.forEachIndexed { index, note ->
76+
add(RadioItem(index + 1, note.title))
77+
}
7678
}
7779

78-
RadioGroupDialog(this@MainActivity, list, -1, R.string.add_to_note, {
80+
RadioGroupDialog(this, list, -1, R.string.add_to_note) {
7981
if (it as Int == 0) {
8082
displayNewNoteDialog(text)
8183
} else {
8284
updateSelectedNote(notes[it - 1].id)
8385
addTextToCurrentNote(if (mCurrentNote.value.isEmpty()) text else "\n$text")
8486
}
85-
}).create()
87+
}
8688
}
8789

8890
private fun initViewPager() {

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ class NotesPagerAdapter(fm: FragmentManager, val notes: List<Note>, val activity
3636

3737
fun getCurrentNoteViewText(position: Int) = fragments[position]?.getCurrentNoteViewText()
3838

39-
fun appendText(position: Int, text: String) {
40-
val fragment = fragments[position]
41-
val finalText = fragment?.getCurrentNoteViewText() + text
42-
fragment?.getNotesView()?.setText(finalText)
43-
}
39+
fun appendText(position: Int, text: String) = fragments[position]?.getNotesView()?.append(text)
4440

4541
fun saveCurrentNote(position: Int) = fragments[position]?.saveText()
4642

0 commit comments

Comments
 (0)