handle actionMode related things only if the activity is init

This commit is contained in:
tibbi 2017-11-10 16:02:20 +01:00
parent 1ef3528a62
commit 1e51175be4

View File

@ -43,6 +43,7 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
lateinit var mNotes: List<Note> lateinit var mNotes: List<Note>
var noteViewWithTextSelected: MyEditText? = null var noteViewWithTextSelected: MyEditText? = null
private var wasInit = false
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -70,6 +71,8 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
intent.action = null intent.action = null
} }
} }
wasInit = true
} }
private fun handleText(text: String) { private fun handleText(text: String) {
@ -176,10 +179,12 @@ class MainActivity : SimpleActivity(), ViewPager.OnPageChangeListener {
// https://code.google.com/p/android/issues/detail?id=191430 quickfix // https://code.google.com/p/android/issues/detail?id=191430 quickfix
override fun onActionModeStarted(mode: ActionMode?) { override fun onActionModeStarted(mode: ActionMode?) {
super.onActionModeStarted(mode) super.onActionModeStarted(mode)
currentNotesView()?.apply { if (wasInit) {
if (config.clickableLinks || movementMethod == LinkMovementMethod.getInstance()) { currentNotesView()?.apply {
movementMethod = ArrowKeyMovementMethod.getInstance() if (config.clickableLinks || movementMethod == LinkMovementMethod.getInstance()) {
noteViewWithTextSelected = this movementMethod = ArrowKeyMovementMethod.getInstance()
noteViewWithTextSelected = this
}
} }
} }
} }