@@ -36,11 +36,11 @@ import java.io.File
36
36
import java.nio.charset.Charset
37
37
38
38
class 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
41
42
42
43
lateinit var mCurrentNote: Note
43
- lateinit var mAdapter: NotesPagerAdapter
44
44
lateinit var mDb: DBHelper
45
45
lateinit var mNotes: List <Note >
46
46
@@ -154,7 +154,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
154
154
// https://code.google.com/p/android/issues/detail?id=191430 quickfix
155
155
override fun onActionModeStarted (mode : ActionMode ? ) {
156
156
super .onActionModeStarted(mode)
157
- currentNotesView().apply {
157
+ currentNotesView()? .apply {
158
158
if (config.clickableLinks || movementMethod == LinkMovementMethod .getInstance()) {
159
159
movementMethod = ArrowKeyMovementMethod .getInstance()
160
160
noteViewWithTextSelected = this
@@ -169,7 +169,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
169
169
}
170
170
}
171
171
172
- private fun currentNotesView () = mAdapter.getItem(view_pager.currentItem).notes_view
172
+ private fun currentNotesView () = mAdapter? .getItem(view_pager.currentItem)? .notes_view
173
173
174
174
private fun displayRenameDialog () {
175
175
RenameNoteDialog (this , mDb, mCurrentNote) {
@@ -200,7 +200,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
200
200
updateSelectedNote(id)
201
201
view_pager.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver .OnGlobalLayoutListener {
202
202
override fun onGlobalLayout () {
203
- mAdapter.showKeyboard(getNoteIndexWithId(id))
203
+ mAdapter? .showKeyboard(getNoteIndexWithId(id))
204
204
view_pager.viewTreeObserver.removeOnGlobalLayoutListener(this )
205
205
}
206
206
})
0 commit comments