From e6fac3aa844accb0c55b8c017aef0ad75920b1e0 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 10 Nov 2017 20:24:49 +0100 Subject: [PATCH] reordering some functions --- .../notes/activities/MainActivity.kt | 108 +++++++++--------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/notes/activities/MainActivity.kt index 0e1410d7..54125dc7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/activities/MainActivity.kt @@ -75,60 +75,6 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener { wasInit = true } - private fun handleText(text: String) { - val notes = mDb.getNotes() - val list = arrayListOf().apply { - add(RadioItem(0, getString(R.string.create_new_note))) - notes.forEachIndexed { index, note -> - add(RadioItem(index + 1, note.title)) - } - } - - 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") - } - } - } - - private fun handleFile(path: String) { - val id = mDb.getNoteId(path) - - if (mDb.isValidId(id)) { - updateSelectedNote(id) - return - } - - handlePermission(PERMISSION_WRITE_STORAGE) { - if (it) { - importFileWithSync(path) - } - } - } - - private fun initViewPager() { - mNotes = mDb.getNotes() - mCurrentNote = mNotes[0] - var wantedNoteId = intent.getIntExtra(OPEN_NOTE_ID, -1) - if (wantedNoteId == -1) - wantedNoteId = config.currentNoteId - - val itemIndex = getNoteIndexWithId(wantedNoteId) - - mAdapter = NotesPagerAdapter(supportFragmentManager, mNotes, this) - view_pager.apply { - adapter = mAdapter - currentItem = itemIndex - addOnPageChangeListener(this@MainActivity) - } - - if (!config.showKeyboard) - hideKeyboard() - } - override fun onResume() { super.onResume() invalidateOptionsMenu() @@ -196,6 +142,60 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener { } } + private fun handleText(text: String) { + val notes = mDb.getNotes() + val list = arrayListOf().apply { + add(RadioItem(0, getString(R.string.create_new_note))) + notes.forEachIndexed { index, note -> + add(RadioItem(index + 1, note.title)) + } + } + + 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") + } + } + } + + private fun handleFile(path: String) { + val id = mDb.getNoteId(path) + + if (mDb.isValidId(id)) { + updateSelectedNote(id) + return + } + + handlePermission(PERMISSION_WRITE_STORAGE) { + if (it) { + importFileWithSync(path) + } + } + } + + private fun initViewPager() { + mNotes = mDb.getNotes() + mCurrentNote = mNotes[0] + var wantedNoteId = intent.getIntExtra(OPEN_NOTE_ID, -1) + if (wantedNoteId == -1) + wantedNoteId = config.currentNoteId + + val itemIndex = getNoteIndexWithId(wantedNoteId) + + mAdapter = NotesPagerAdapter(supportFragmentManager, mNotes, this) + view_pager.apply { + adapter = mAdapter + currentItem = itemIndex + addOnPageChangeListener(this@MainActivity) + } + + if (!config.showKeyboard) + hideKeyboard() + } + private fun currentNotesView() = if (view_pager == null) null else mAdapter?.getItem(view_pager.currentItem)?.notes_view private fun displayRenameDialog() {