mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-13 23:12:02 +02:00
minor code cleanup
This commit is contained in:
parent
63606269de
commit
dbdfc7b49f
@ -69,20 +69,22 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
|
||||
}
|
||||
|
||||
private fun handleText(text: String) {
|
||||
val notes = DBHelper.newInstance(this@MainActivity).getNotes()
|
||||
val notes = mDb.getNotes()
|
||||
val list = arrayListOf<RadioItem>().apply {
|
||||
add(RadioItem(0, getString(R.string.create_new_note)))
|
||||
notes.forEachIndexed { index, note -> add(RadioItem(index + 1, note.title)) }
|
||||
notes.forEachIndexed { index, note ->
|
||||
add(RadioItem(index + 1, note.title))
|
||||
}
|
||||
}
|
||||
|
||||
RadioGroupDialog(this@MainActivity, list, -1, R.string.add_to_note, {
|
||||
RadioGroupDialog(this, list, -1, R.string.add_to_note) {
|
||||
if (it as Int == 0) {
|
||||
displayNewNoteDialog(text)
|
||||
} else {
|
||||
updateSelectedNote(notes[it - 1].id)
|
||||
addTextToCurrentNote(if (mCurrentNote.value.isEmpty()) text else "\n$text")
|
||||
}
|
||||
}).create()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initViewPager() {
|
||||
|
@ -36,11 +36,7 @@ class NotesPagerAdapter(fm: FragmentManager, val notes: List<Note>, val activity
|
||||
|
||||
fun getCurrentNoteViewText(position: Int) = fragments[position]?.getCurrentNoteViewText()
|
||||
|
||||
fun appendText(position: Int, text: String) {
|
||||
val fragment = fragments[position]
|
||||
val finalText = fragment?.getCurrentNoteViewText() + text
|
||||
fragment?.getNotesView()?.setText(finalText)
|
||||
}
|
||||
fun appendText(position: Int, text: String) = fragments[position]?.getNotesView()?.append(text)
|
||||
|
||||
fun saveCurrentNote(position: Int) = fragments[position]?.saveText()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user