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 b5749f27..7bb9f93a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/activities/MainActivity.kt @@ -12,7 +12,6 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.extensions.checkWhatsNew import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.extensions.updateTextColors -import com.simplemobiletools.commons.extensions.value import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN import com.simplemobiletools.commons.helpers.LICENSE_RTL import com.simplemobiletools.commons.helpers.LICENSE_STETHO @@ -29,7 +28,6 @@ import com.simplemobiletools.notes.helpers.DBHelper import com.simplemobiletools.notes.helpers.TYPE_NOTE import com.simplemobiletools.notes.models.Note import kotlinx.android.synthetic.main.activity_main.* -import kotlinx.android.synthetic.main.fragment_note.* class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener { lateinit var mCurrentNote: Note @@ -179,7 +177,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener { } private fun shareText() { - val text = notes_view.value + val text = (view_pager.adapter as NotesPagerAdapter).getCurrentNoteText(view_pager.currentItem) if (text.isEmpty()) { toast(R.string.cannot_share_empty_text) return diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/adapters/NotesPagerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/notes/adapters/NotesPagerAdapter.kt index 65f73154..e6ce7bce 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/adapters/NotesPagerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/adapters/NotesPagerAdapter.kt @@ -30,5 +30,7 @@ class NotesPagerAdapter(fm: FragmentManager, private val notes: List) : Fr override fun getPageTitle(position: Int) = notes[position].title + fun getCurrentNoteText(position: Int) = fragments[position].getCurrentNoteText() + fun showKeyboard(position: Int) = fragments[position]?.showKeyboard() } diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/fragments/NoteFragment.kt b/app/src/main/kotlin/com/simplemobiletools/notes/fragments/NoteFragment.kt index 6cadc6c8..43d2ad1a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/fragments/NoteFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/fragments/NoteFragment.kt @@ -22,7 +22,6 @@ import com.simplemobiletools.notes.helpers.NOTE_ID import com.simplemobiletools.notes.models.Note import kotlinx.android.synthetic.main.fragment_note.view.* - class NoteFragment : Fragment() { var noteId = 0 lateinit var view: ViewGroup @@ -57,8 +56,10 @@ class NoteFragment : Fragment() { return view } + fun getCurrentNoteText() = view.notes_view.text.toString() + fun saveText() { - val newText = view.notes_view.text.toString() + val newText = getCurrentNoteText() val oldText = note.value if (newText != oldText) { note.value = newText