Skip to content

Commit

Permalink
Improve time tracking example.
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed Nov 28, 2024
1 parent 4e26493 commit e05ba08
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ class ExampleFragmentSelectBook : Fragment(R.layout.example_config_screen) {
}

private fun onSelectedPlay() {
ExampleTimeTracking.timeSecondsTracked = 0L

val credentials =
when (this.authenticationSelected) {
this.authBasic -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ class ExamplePlayerActivity : AppCompatActivity(R.layout.example_player_activity
when (f) {
is PlayerFragment -> {
this.close()
Unit
}

is PlayerTOCFragment -> {
Expand Down Expand Up @@ -329,10 +328,14 @@ class ExamplePlayerActivity : AppCompatActivity(R.layout.example_player_activity
) {
this.logger.debug("TimeTracked: {}", time)

ExampleTimeTracking.timeSecondsTracked += time.duration.toSeconds()

PlayerUIThread.runOnUIThread {
try {
Toast.makeText(this, "Time tracked: ${time.duration}", Toast.LENGTH_SHORT)
.show()
Toast.makeText(this, "" +
"Time tracked: ${time.duration.toSeconds()} (Total seconds: ${ExampleTimeTracking.timeSecondsTracked})",
Toast.LENGTH_LONG
).show()
} catch (e: Throwable) {
// Don't care
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.librarysimplified.audiobook.demo

object ExampleTimeTracking {

@Volatile
var timeSecondsTracked = 0L

}
2 changes: 1 addition & 1 deletion org.thepalaceproject.android.platform

0 comments on commit e05ba08

Please sign in to comment.