Skip to content

Commit de13dbd

Browse files
committed
add some null checks at getting current text
1 parent 45e2e0c commit de13dbd

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

app/src/main/kotlin/com/simplemobiletools/notes/activities/MainActivity.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
214214

215215
private fun exportAsFile() {
216216
ExportAsDialog(this, mCurrentNote) {
217-
exportNoteValueToFile(it, getCurrentNoteText())
217+
if (getCurrentNoteText()?.isNotEmpty() == true)
218+
exportNoteValueToFile(it, getCurrentNoteText()!!)
218219
}
219220
}
220221

@@ -307,7 +308,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
307308

308309
private fun shareText() {
309310
val text = getCurrentNoteText()
310-
if (text.isEmpty()) {
311+
if (text == null || text.isEmpty()) {
311312
toast(R.string.cannot_share_empty_text)
312313
return
313314
}

app/src/main/kotlin/com/simplemobiletools/notes/adapters/NotesPagerAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class NotesPagerAdapter(fm: FragmentManager, val notes: List<Note>, val activity
3434

3535
override fun getPageTitle(position: Int) = notes[position].title
3636

37-
fun getCurrentNoteViewText(position: Int) = fragments[position].getCurrentNoteViewText()
37+
fun getCurrentNoteViewText(position: Int) = fragments[position]?.getCurrentNoteViewText()
3838

3939
fun saveCurrentNote(position: Int) = fragments[position]?.saveText()
4040

0 commit comments

Comments
 (0)