mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-18 01:07:23 +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) {
|
private fun handleText(text: String) {
|
||||||
val notes = DBHelper.newInstance(this@MainActivity).getNotes()
|
val notes = mDb.getNotes()
|
||||||
val list = arrayListOf<RadioItem>().apply {
|
val list = arrayListOf<RadioItem>().apply {
|
||||||
add(RadioItem(0, getString(R.string.create_new_note)))
|
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) {
|
if (it as Int == 0) {
|
||||||
displayNewNoteDialog(text)
|
displayNewNoteDialog(text)
|
||||||
} else {
|
} else {
|
||||||
updateSelectedNote(notes[it - 1].id)
|
updateSelectedNote(notes[it - 1].id)
|
||||||
addTextToCurrentNote(if (mCurrentNote.value.isEmpty()) text else "\n$text")
|
addTextToCurrentNote(if (mCurrentNote.value.isEmpty()) text else "\n$text")
|
||||||
}
|
}
|
||||||
}).create()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initViewPager() {
|
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 getCurrentNoteViewText(position: Int) = fragments[position]?.getCurrentNoteViewText()
|
||||||
|
|
||||||
fun appendText(position: Int, text: String) {
|
fun appendText(position: Int, text: String) = fragments[position]?.getNotesView()?.append(text)
|
||||||
val fragment = fragments[position]
|
|
||||||
val finalText = fragment?.getCurrentNoteViewText() + text
|
|
||||||
fragment?.getNotesView()?.setText(finalText)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun saveCurrentNote(position: Int) = fragments[position]?.saveText()
|
fun saveCurrentNote(position: Int) = fragments[position]?.saveText()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user