Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. viewModel.addPlayer(asPlayer).addOnCompleteListener {
  2. Log.d("Game", "current destination before joining: "+resources.getResourceEntryName(navController.currentDestination!!.id))
  3. navController.navigate(R.id.action_joinGameFragment_to_waitingFragment)
  4. }
  5.  
  6. //so this observer is not getting detached, maybe manually detach it and reattach it in on resume
  7. viewModel.gameExists.observe(this, androidx.lifecycle.Observer { exists ->
  8. //someone ended the game
  9. var debug = navController
  10. if(!exists && navController.currentDestination?.id == R.id.gameFragment){ endGame() }
  11. })
  12.  
  13. fun endGame(){
  14. viewModel.endGame()
  15. Log.d("Game", "current destination before crash: "+resources.getResourceEntryName(navController.currentDestination!!.id))
  16. timer.cancel()
  17. Log.d("Game", "current destination before poping: "+resources.getResourceEntryName(navController.currentDestination!!.id))
  18. navController.popBackStack(R.id.startFragment, false)
  19. Log.d("Game", "current destination after poping: "+resources.getResourceEntryName(navController.currentDestination!!.id))
  20.  
  21. }
  22.  
  23. 2019-06-16 20:13:40.278 13021-13021/com.dangerfield.spyfall D/Game: current destination before poping: (FRAGMENT C)
  24. 2019-06-16 20:13:40.279 13021-13021/com.dangerfield.spyfall D/Game: current destination after poping: (FRAGMENT A)
  25. 2019-06-16 20:13:40.279 13021-13021/com.dangerfield.spyfall D/View Model: game = null
  26. 2019-06-16 20:13:40.299 13021-13021/com.dangerfield.spyfall D/GAME: ON DESTROY
  27. 2019-06-16 20:13:40.315 13021-13021/com.dangerfield.spyfall D/View Model: game = null
  28. 2019-06-16 20:14:05.289 13021-13021/com.dangerfield.spyfall D/Game: current destination before joining: (FRAGMENT A)
  29. 2019-06-16 20:14:05.316 13021-13021/com.dangerfield.spyfall D/Game: on Create
  30. 2019-06-16 20:14:05.317 13021-13021/com.dangerfield.spyfall D/Game: onCreateView
  31. 2019-06-16 20:14:05.353 13021-13021/com.dangerfield.spyfall D/GAME: ON RESUME
  32. 2019-06-16 20:14:05.353 13021-13021/com.dangerfield.spyfall D/Game: current destination before crash: (FRAGMENT C)
  33. 019-06-16 20:14:05.359 13021-13021/com.dangerfield.spyfall E/AndroidRuntime: FATAL EXCEPTION: main
  34. Process: com.dangerfield.spyfall, PID: 13021
  35. kotlin.UninitializedPropertyAccessException: lateinit property timer has not been initialized
  36. at com.dangerfield.spyfall.game.GameFragment.endGame(GameFragment.kt:158)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement