class
BFragment : BaseFragment<FragmentBBinding>(R.layout.fragment_b) {
private
val viewModel by activityViewModels<LocationViewModel>()
fun backBtn(view: View) {
view.findNavController().popBackStack()
}
override fun init() {
binding.fragment =
this
observeViewModel()
}
private
fun observeViewModel() {
viewModel.viewEvent.observe(requireActivity(), {
it.getContentIfNotHandled()?.let { event ->
Log.d(
"TAG"
,
"Event : $event"
)
when (event) {
"SUCCESS"
-> {
Log.d(
"TAG"
,
"SUCCESS"
)
this
@LocationFragment
.findNavController().navigate(
LocationFragmentDirections.actionLocationFragmentToLocationSelectFragment(
"location"
)
)
}
"ERROR"
-> shortShowToast(
"오류가 발생했습니다"
)
}
}
})
}
fun clickAddressSearchBtn(view: View) {
if
(!TextUtils.isEmpty(binding.query.text.toString())) viewModel.searchAddress(
KEY,
"similar"
,
1
,
10
,
binding.query.text.toString()
)
else
shortShowToast(
"주소를 입력해 주세요"
)
}
}