Skip to content

Commit

Permalink
[Refactor/#109] Home view 코드 간결화
Browse files Browse the repository at this point in the history
  • Loading branch information
ss99x2002 committed Aug 28, 2023
1 parent 04dee80 commit 1c1c300
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home
private fun observeData() {
viewModel.homeData.observe(viewLifecycleOwner) {
setBackground(it.section)
if (it.index == 8 && viewModel.isCloseEnding.value == false && viewModel.isObserveIndex.value == false) {
if (it.index == 8 && viewModel.isShowedEndingPage()) {
viewModel.setStateObserveIndex()
startForResult.launch(Intent(requireActivity(), EndingActivity::class.java))
}
Expand Down Expand Up @@ -99,7 +99,7 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home

override fun onResume() {
super.onResume()
if (viewModel.isObserveIndex.value != true) {
if (viewModel.isObserveIndex.value == false) {
viewModel.getHomeData()
}
viewModel.getResponseCase()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,8 @@ class HomeViewModel(private val homeRepositoryImpl: HomeRepositoryImpl) : ViewMo
fun setStateObserveIndex() {
_isObserveIndex.value = true
}

fun isShowedEndingPage(): Boolean {
return (_isCloseEnding.value == false && _isObserveIndex.value == false)
}
}

0 comments on commit 1c1c300

Please sign in to comment.