Advertisement
andyshon

Timer

Feb 13th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.86 KB | None | 0 0
  1. val onEverySecond = object : Runnable {
  2.         override fun run() {
  3.             if (exoPlayer != null) {
  4.                 if (phrases.isNotEmpty()) {
  5.                     try {
  6.                         if (exoPlayer?.currentPosition ?: 0 >= audioDuration || exoPlayer?.playWhenReady == false) {
  7.                             Timber.e("Stop self")
  8.                         }
  9.                         else {
  10.                             Handler().postDelayed(this, EVERY_SECOND_DELAY)
  11.  
  12.                             sendUpdateSeekBar(exoPlayer?.currentPosition?.toInt()!!)
  13.                             updateFlowButtons()
  14.                             sendUpdateTimeText()
  15.                             sendUpdatePhrase()
  16.                         }
  17.                     } catch (e: IllegalStateException) { }
  18.                 }
  19.             }
  20.             else { }
  21.         }
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement