Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- viewModel.addPlayer(asPlayer).addOnCompleteListener {
- Log.d("Game", "current destination before joining: "+resources.getResourceEntryName(navController.currentDestination!!.id))
- navController.navigate(R.id.action_joinGameFragment_to_waitingFragment)
- }
- //so this observer is not getting detached, maybe manually detach it and reattach it in on resume
- viewModel.gameExists.observe(this, androidx.lifecycle.Observer { exists ->
- //someone ended the game
- var debug = navController
- if(!exists && navController.currentDestination?.id == R.id.gameFragment){ endGame() }
- })
- fun endGame(){
- viewModel.endGame()
- Log.d("Game", "current destination before crash: "+resources.getResourceEntryName(navController.currentDestination!!.id))
- timer.cancel()
- Log.d("Game", "current destination before poping: "+resources.getResourceEntryName(navController.currentDestination!!.id))
- navController.popBackStack(R.id.startFragment, false)
- Log.d("Game", "current destination after poping: "+resources.getResourceEntryName(navController.currentDestination!!.id))
- }
- 2019-06-16 20:13:40.278 13021-13021/com.dangerfield.spyfall D/Game: current destination before poping: (FRAGMENT C)
- 2019-06-16 20:13:40.279 13021-13021/com.dangerfield.spyfall D/Game: current destination after poping: (FRAGMENT A)
- 2019-06-16 20:13:40.279 13021-13021/com.dangerfield.spyfall D/View Model: game = null
- 2019-06-16 20:13:40.299 13021-13021/com.dangerfield.spyfall D/GAME: ON DESTROY
- 2019-06-16 20:13:40.315 13021-13021/com.dangerfield.spyfall D/View Model: game = null
- 2019-06-16 20:14:05.289 13021-13021/com.dangerfield.spyfall D/Game: current destination before joining: (FRAGMENT A)
- 2019-06-16 20:14:05.316 13021-13021/com.dangerfield.spyfall D/Game: on Create
- 2019-06-16 20:14:05.317 13021-13021/com.dangerfield.spyfall D/Game: onCreateView
- 2019-06-16 20:14:05.353 13021-13021/com.dangerfield.spyfall D/GAME: ON RESUME
- 2019-06-16 20:14:05.353 13021-13021/com.dangerfield.spyfall D/Game: current destination before crash: (FRAGMENT C)
- 019-06-16 20:14:05.359 13021-13021/com.dangerfield.spyfall E/AndroidRuntime: FATAL EXCEPTION: main
- Process: com.dangerfield.spyfall, PID: 13021
- kotlin.UninitializedPropertyAccessException: lateinit property timer has not been initialized
- at com.dangerfield.spyfall.game.GameFragment.endGame(GameFragment.kt:158)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement