Commit 7fb927f7 by Paktalin

Fixed the bug with starting tag state when being in edit mode

parent f0081656
...@@ -136,13 +136,15 @@ class MainActivity : AppCompatActivity() { ...@@ -136,13 +136,15 @@ class MainActivity : AppCompatActivity() {
private fun whenSelectionChanges(selection: Selection<Long>) { private fun whenSelectionChanges(selection: Selection<Long>) {
vocabularyAdapter?.let { vocabularyAdapter?.let {
if (!selection.isEmpty && it.state.notAddOrEdit()) { if (it.state.notAddOrEdit()) {
vocabularyAdapter?.state = State.TAG if (!selection.isEmpty) {
tagFragment.setSelection(selection.toList()) vocabularyAdapter?.state = State.TAG
addFragment(supportFragmentManager, tagFragment, R.id.main_activity_container) tagFragment.setSelection(selection.toList())
} else { addFragment(supportFragmentManager, tagFragment, R.id.main_activity_container)
vocabularyAdapter?.state = State.NONE } else {
removeFragment(supportFragmentManager, tagFragment) vocabularyAdapter?.state = State.NONE
removeFragment(supportFragmentManager, tagFragment)
}
} }
} }
} }
......
...@@ -22,6 +22,7 @@ class SubmitEditedFragment : SubmitFragment() { ...@@ -22,6 +22,7 @@ class SubmitEditedFragment : SubmitFragment() {
scrollToPositionWithOffset(recyclerViewPosition, 2) scrollToPositionWithOffset(recyclerViewPosition, 2)
isScrollEnabled = false isScrollEnabled = false
} }
mainActivity.vocabularyAdapter?.state = State.EDIT mainActivity.vocabularyAdapter?.state = State.EDIT
gone(clickableView) gone(clickableView)
wordEt.requestFocus() wordEt.requestFocus()
......
package com.paktalin.vocabularynotebook.ui.recycler_view package com.paktalin.vocabularynotebook.ui.recycler_view
import com.paktalin.vocabularynotebook.ui.activities.MainActivity
enum class State { enum class State {
EDIT, ADD, TAG, NONE; EDIT, ADD, TAG, NONE;
fun notAddOrEdit(): Boolean { fun notAddOrEdit(): Boolean {
return this != ADD && this != EDIT return this != ADD && this != EDIT
} }
companion object {
private val TAGG = "VN/" + MainActivity::class.simpleName
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment