mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-04-03 02:01:05 +02:00
fix #68, invalid share error message
This commit is contained in:
parent
79285a197c
commit
db26e22067
@ -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
|
||||
|
@ -30,5 +30,7 @@ class NotesPagerAdapter(fm: FragmentManager, private val notes: List<Note>) : Fr
|
||||
|
||||
override fun getPageTitle(position: Int) = notes[position].title
|
||||
|
||||
fun getCurrentNoteText(position: Int) = fragments[position].getCurrentNoteText()
|
||||
|
||||
fun showKeyboard(position: Int) = fragments[position]?.showKeyboard()
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user