Commit 685ba537 by Paktalin

Hide previous views inside EditWordFragment

parent 63e5838b
...@@ -12,7 +12,6 @@ import android.widget.TextView ...@@ -12,7 +12,6 @@ import android.widget.TextView
import com.paktalin.vocabularynotebook.ui.EditWordFragment import com.paktalin.vocabularynotebook.ui.EditWordFragment
import com.paktalin.vocabularynotebook.ui.MainActivity import com.paktalin.vocabularynotebook.ui.MainActivity
class VocabularyAdapter(private val wordItems: MutableList<WordItem>, private val activity: Activity) : RecyclerView.Adapter<VocabularyAdapter.ViewHolder>() { class VocabularyAdapter(private val wordItems: MutableList<WordItem>, private val activity: Activity) : RecyclerView.Adapter<VocabularyAdapter.ViewHolder>() {
private lateinit var recyclerView: RecyclerView private lateinit var recyclerView: RecyclerView
...@@ -65,10 +64,6 @@ class VocabularyAdapter(private val wordItems: MutableList<WordItem>, private va ...@@ -65,10 +64,6 @@ class VocabularyAdapter(private val wordItems: MutableList<WordItem>, private va
@SuppressLint("ResourceType") @SuppressLint("ResourceType")
private fun editWordItem(container:View, wordItem: WordItem) { private fun editWordItem(container:View, wordItem: WordItem) {
//hide textViews
container.findViewById<TextView>(R.id.word).visibility = View.GONE
container.findViewById<TextView>(R.id.translation).visibility = View.GONE
//set container id //set container id
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
container.id = View.generateViewId() container.id = View.generateViewId()
......
...@@ -9,6 +9,7 @@ import android.view.ViewGroup ...@@ -9,6 +9,7 @@ import android.view.ViewGroup
import android.view.WindowManager import android.view.WindowManager
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
import android.widget.EditText import android.widget.EditText
import android.widget.TextView
import com.paktalin.vocabularynotebook.R import com.paktalin.vocabularynotebook.R
import com.paktalin.vocabularynotebook.WordItem import com.paktalin.vocabularynotebook.WordItem
...@@ -18,6 +19,7 @@ class EditWordFragment : Fragment() { ...@@ -18,6 +19,7 @@ class EditWordFragment : Fragment() {
private lateinit var etWord: EditText private lateinit var etWord: EditText
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
hidePreviousViews(container)
wordItem = arguments!!["wordItem"] as WordItem wordItem = arguments!!["wordItem"] as WordItem
return inflater.inflate(R.layout.editable_word_item, container, false) return inflater.inflate(R.layout.editable_word_item, container, false)
} }
...@@ -40,4 +42,11 @@ class EditWordFragment : Fragment() { ...@@ -40,4 +42,11 @@ class EditWordFragment : Fragment() {
val imm = activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager? val imm = activity!!.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager?
imm!!.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY) imm!!.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY)
} }
private fun hidePreviousViews(container: ViewGroup?) {
if (container != null) {
container.findViewById<TextView>(R.id.word).visibility = View.GONE
container.findViewById<TextView>(R.id.translation).visibility = View.GONE
}
}
} }
\ 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