@@ -36,11 +36,11 @@ import java.io.File
3636import java.nio.charset.Charset
3737
3838class MainActivity : SimpleActivity (), ViewPager.OnPageChangeListener {
39- val STORAGE_OPEN_FILE = 1
40- val STORAGE_EXPORT_AS_FILE = 2
39+ private val STORAGE_OPEN_FILE = 1
40+ private val STORAGE_EXPORT_AS_FILE = 2
41+ private var mAdapter: NotesPagerAdapter ? = null
4142
4243 lateinit var mCurrentNote: Note
43- lateinit var mAdapter: NotesPagerAdapter
4444 lateinit var mDb: DBHelper
4545 lateinit var mNotes: List <Note >
4646
@@ -154,7 +154,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
154154 // https://code.google.com/p/android/issues/detail?id=191430 quickfix
155155 override fun onActionModeStarted (mode : ActionMode ? ) {
156156 super .onActionModeStarted(mode)
157- currentNotesView().apply {
157+ currentNotesView()? .apply {
158158 if (config.clickableLinks || movementMethod == LinkMovementMethod .getInstance()) {
159159 movementMethod = ArrowKeyMovementMethod .getInstance()
160160 noteViewWithTextSelected = this
@@ -169,7 +169,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
169169 }
170170 }
171171
172- private fun currentNotesView () = mAdapter.getItem(view_pager.currentItem).notes_view
172+ private fun currentNotesView () = mAdapter? .getItem(view_pager.currentItem)? .notes_view
173173
174174 private fun displayRenameDialog () {
175175 RenameNoteDialog (this , mDb, mCurrentNote) {
@@ -200,7 +200,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
200200 updateSelectedNote(id)
201201 view_pager.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver .OnGlobalLayoutListener {
202202 override fun onGlobalLayout () {
203- mAdapter.showKeyboard(getNoteIndexWithId(id))
203+ mAdapter? .showKeyboard(getNoteIndexWithId(id))
204204 view_pager.viewTreeObserver.removeOnGlobalLayoutListener(this )
205205 }
206206 })
0 commit comments