mediaplayer null safe listeners
This commit is contained in:
parent
94336348c5
commit
2ca7d062f3
2 changed files with 12 additions and 8 deletions
|
@ -31,11 +31,13 @@ class BreakSessionScreen(
|
||||||
|
|
||||||
override fun callMediaPlayer() {
|
override fun callMediaPlayer() {
|
||||||
if (funPomoDoroTimer.hasEnded()) {
|
if (funPomoDoroTimer.hasEnded()) {
|
||||||
mediaplayer?.setOnCompletionListener {
|
mediaplayer?.let { it: MediaPlayer ->
|
||||||
mediaplayer!!.release()
|
it.setOnCompletionListener {
|
||||||
mediaplayer = null
|
it.release()
|
||||||
|
mediaplayer = null
|
||||||
|
}
|
||||||
|
it.start()
|
||||||
}
|
}
|
||||||
mediaplayer?.start()
|
|
||||||
} else if (funPomoDoroTimer.hasCurrentCountdownEnded()) {
|
} else if (funPomoDoroTimer.hasCurrentCountdownEnded()) {
|
||||||
mediaplayer?.start()
|
mediaplayer?.start()
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,13 @@ class CustomSessionScreen(
|
||||||
|
|
||||||
override fun callMediaPlayer() {
|
override fun callMediaPlayer() {
|
||||||
if (functionalTimer.hasEnded()) {
|
if (functionalTimer.hasEnded()) {
|
||||||
mediaplayer?.setOnCompletionListener {
|
mediaplayer?.let { it: MediaPlayer ->
|
||||||
mediaplayer!!.release()
|
it.setOnCompletionListener {
|
||||||
mediaplayer = null
|
it.release()
|
||||||
|
mediaplayer = null
|
||||||
|
}
|
||||||
|
it.start()
|
||||||
}
|
}
|
||||||
mediaplayer?.start()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue