diff --git a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/main/MainActivity.kt b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/main/MainActivity.kt index d8553ba7..e16ac8ee 100644 --- a/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/main/MainActivity.kt +++ b/AOS/app/src/main/java/boostcamp/and07/mindsync/ui/main/MainActivity.kt @@ -18,6 +18,7 @@ import boostcamp.and07.mindsync.databinding.ActivityMainBinding import boostcamp.and07.mindsync.ui.base.BaseActivity import boostcamp.and07.mindsync.ui.base.BaseActivityViewModel import boostcamp.and07.mindsync.ui.boardlist.UsersAdapter +import boostcamp.and07.mindsync.ui.dialog.DisConnectedNetworkDialog import boostcamp.and07.mindsync.ui.profile.ProfileActivity import boostcamp.and07.mindsync.ui.space.list.SpaceListFragmentDirections import boostcamp.and07.mindsync.ui.util.ThrottleDuration @@ -54,6 +55,7 @@ class MainActivity : setSideBarNavigation() setBinding() observeEvent() + showDisconnectedNetworkDialog() } override fun getViewModel(): BaseActivityViewModel { @@ -83,6 +85,22 @@ class MainActivity : } } + private fun showDisconnectedNetworkDialog() { + val dialog = DisConnectedNetworkDialog(mainViewModel.isConnected) + lifecycleScope.launch { + repeatOnLifecycle(Lifecycle.State.STARTED) { + mainViewModel.isConnected.collectLatest { isConnected -> + if (isConnected.not()) { + dialog.show( + this@MainActivity.supportFragmentManager, + "DisConnectedNetworkDialog", + ) + } + } + } + } + } + private fun setNavController() { val navHostFragment = (supportFragmentManager.findFragmentById(R.id.fcv_main_nav_host) as NavHostFragment) @@ -213,7 +231,11 @@ class MainActivity : spaceAdapter.setSideBarClickListener( object : SpaceClickListener { override fun onClickSpace(space: Space) { - navController.navigate(SpaceListFragmentDirections.actionToBoardListFragment(spaceId = space.id)) + navController.navigate( + SpaceListFragmentDirections.actionToBoardListFragment( + spaceId = space.id, + ), + ) mainViewModel.updateCurrentSpace(space) } },