-
Notifications
You must be signed in to change notification settings - Fork 5
5.5. 키워드 초기 설정
JiHwan edited this page Jan 15, 2021
·
6 revisions
- 그 전 Fragment에서 Text를 받아와서 뿌려줌
- 그 전 Fragment에서 Text를 받아와서 뿌려줌
- 그 전 Fragment에서 Text를 받아와서 뿌려줌
- 그 전 Fragment에서 Text를 받아와서 뿌려줌
private fun initEditText() {
binding.tvKeyword.text = keyword
binding.etDefine.addTextChangedListener {
val length = binding.etDefine.length()
binding.tvDefineByte.text = length.toString()
binding.btnSetPriority.isEnabled = length > 0
}
}
private fun initButton() {
binding.btnSetPriority.isEnabled = false
binding.btnSetPriority.setOnClickListener {
viewModel.postKeywordDefinition(name = keyword!!, definition = binding.etDefine.text.toString())
viewModel.isDefineSet[position] = true
popBackStack()
}
}
private fun initToolbar() {
binding.tbKeywordDefineDetail.setNavigationOnClickListener {
popBackStack()
}
}
private fun observeKeywordDefinition() {
viewModel.keywordDefinition.observe(viewLifecycleOwner, {
binding.tvKeyword.text = it.name
binding.etDefine.setText(it.definition)
})
}
keywordDefineAdapter.setKeywordExistListener { keyword, position ->
//정의 없을때
val bundle = Bundle().apply {
putString("keyword", keyword.name)
putInt("position", position)
}
val keywordDefineAddFragment = KeywordDefineAddFragment().apply {
arguments = bundle
}
replaceAndAddBackStack(
R.id.container_keyword_settings,
keywordDefineAddFragment,
"add"
)
}
private fun initRecyclerView() {
val itemTouchHelper = ItemTouchHelper(ItemTouchHelperCallback(keywordPriorityAdapter))
val dividerItemDecoration = DividerItemDecoration(requireContext(),LinearLayoutManager.VERTICAL)
dividerItemDecoration.setDrawable(ContextCompat.getDrawable(requireContext(),R.drawable.divider_recyclerview)!!)
binding.rvPriority.apply {
adapter = keywordPriorityAdapter
layoutManager = LinearLayoutManager(requireContext())
addItemDecoration(dividerItemDecoration)
setHasFixedSize(true)
itemTouchHelper.attachToRecyclerView(this)
}
keywordPriorityAdapter.data = keywordList?.toList() ?: listOf()
}