timerstates fixed
This commit is contained in:
		
							parent
							
								
									adafae332a
								
							
						
					
					
						commit
						dc43b26dc0
					
				
					 1 changed files with 3 additions and 19 deletions
				
			
		|  | @ -35,8 +35,6 @@ import be.ugent.sel.studeez.resources | ||||||
| import kotlinx.coroutines.delay | import kotlinx.coroutines.delay | ||||||
| import kotlin.time.Duration.Companion.seconds | import kotlin.time.Duration.Companion.seconds | ||||||
| 
 | 
 | ||||||
| var timerEnd = false |  | ||||||
| 
 |  | ||||||
| @Composable | @Composable | ||||||
| fun SessionScreen( | fun SessionScreen( | ||||||
|     open: (String) -> Unit, |     open: (String) -> Unit, | ||||||
|  | @ -46,17 +44,7 @@ fun SessionScreen( | ||||||
|     val context = LocalContext.current |     val context = LocalContext.current | ||||||
|     val uri: Uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION) |     val uri: Uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION) | ||||||
|     val mediaplayer = MediaPlayer.create(context, uri) |     val mediaplayer = MediaPlayer.create(context, uri) | ||||||
|     mediaplayer.setOnCompletionListener { |     mediaplayer.isLooping = false | ||||||
|         if (!mediaplayer.isPlaying) { |  | ||||||
|             mediaplayer.stop() |  | ||||||
|         } |  | ||||||
|         if (timerEnd) { |  | ||||||
|             mediaplayer.release() |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|     mediaplayer.setOnPreparedListener { |  | ||||||
|         mediaplayer.start() |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     Column( |     Column( | ||||||
|        modifier = Modifier.padding(10.dp) |        modifier = Modifier.padding(10.dp) | ||||||
|  | @ -71,6 +59,7 @@ fun SessionScreen( | ||||||
|         ) { |         ) { | ||||||
|             TextButton( |             TextButton( | ||||||
|                 onClick = { |                 onClick = { | ||||||
|  |                     mediaplayer.stop() | ||||||
|                     mediaplayer.release() |                     mediaplayer.release() | ||||||
|                     open(StudeezDestinations.HOME_SCREEN) |                     open(StudeezDestinations.HOME_SCREEN) | ||||||
|                     // Vanaf hier ook naar report gaan als "end session" knop word ingedrukt |                     // Vanaf hier ook naar report gaan als "end session" knop word ingedrukt | ||||||
|  | @ -102,12 +91,7 @@ private fun Timer(viewModel: SessionViewModel = hiltViewModel(), mediaplayer: Me | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (viewModel.getTimer().hasCurrentCountdownEnded() && !viewModel.getTimer().hasEnded()) { |     if (viewModel.getTimer().hasCurrentCountdownEnded() && !viewModel.getTimer().hasEnded()) { | ||||||
|         mediaplayer.prepare() |         mediaplayer.start() | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     if (!timerEnd && viewModel.getTimer().hasEnded()) { |  | ||||||
|         mediaplayer.prepare() |  | ||||||
|         timerEnd = true // Placeholder, vanaf hier moet het report opgestart worden en de sessie afgesloten |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     val hms = viewModel.getTimer().getHoursMinutesSeconds() |     val hms = viewModel.getTimer().getHoursMinutesSeconds() | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Rune Dyselinck
						Rune Dyselinck