From e05ba083509df62124bd15284d906707b097c3f4 Mon Sep 17 00:00:00 2001 From: Mark Raynsford Date: Thu, 28 Nov 2024 15:53:23 +0000 Subject: [PATCH] Improve time tracking example. --- .../audiobook/demo/ExampleFragmentSelectBook.kt | 2 ++ .../audiobook/demo/ExamplePlayerActivity.kt | 9 ++++++--- .../audiobook/demo/ExampleTimeTracking.kt | 8 ++++++++ org.thepalaceproject.android.platform | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 org.librarysimplified.audiobook.demo/src/main/java/org/librarysimplified/audiobook/demo/ExampleTimeTracking.kt diff --git a/org.librarysimplified.audiobook.demo/src/main/java/org/librarysimplified/audiobook/demo/ExampleFragmentSelectBook.kt b/org.librarysimplified.audiobook.demo/src/main/java/org/librarysimplified/audiobook/demo/ExampleFragmentSelectBook.kt index 67faa65d..690f762d 100644 --- a/org.librarysimplified.audiobook.demo/src/main/java/org/librarysimplified/audiobook/demo/ExampleFragmentSelectBook.kt +++ b/org.librarysimplified.audiobook.demo/src/main/java/org/librarysimplified/audiobook/demo/ExampleFragmentSelectBook.kt @@ -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 -> { diff --git a/org.librarysimplified.audiobook.demo/src/main/java/org/librarysimplified/audiobook/demo/ExamplePlayerActivity.kt b/org.librarysimplified.audiobook.demo/src/main/java/org/librarysimplified/audiobook/demo/ExamplePlayerActivity.kt index 52b8a770..f5a0d72d 100644 --- a/org.librarysimplified.audiobook.demo/src/main/java/org/librarysimplified/audiobook/demo/ExamplePlayerActivity.kt +++ b/org.librarysimplified.audiobook.demo/src/main/java/org/librarysimplified/audiobook/demo/ExamplePlayerActivity.kt @@ -133,7 +133,6 @@ class ExamplePlayerActivity : AppCompatActivity(R.layout.example_player_activity when (f) { is PlayerFragment -> { this.close() - Unit } is PlayerTOCFragment -> { @@ -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 } diff --git a/org.librarysimplified.audiobook.demo/src/main/java/org/librarysimplified/audiobook/demo/ExampleTimeTracking.kt b/org.librarysimplified.audiobook.demo/src/main/java/org/librarysimplified/audiobook/demo/ExampleTimeTracking.kt new file mode 100644 index 00000000..677c6c31 --- /dev/null +++ b/org.librarysimplified.audiobook.demo/src/main/java/org/librarysimplified/audiobook/demo/ExampleTimeTracking.kt @@ -0,0 +1,8 @@ +package org.librarysimplified.audiobook.demo + +object ExampleTimeTracking { + + @Volatile + var timeSecondsTracked = 0L + +} diff --git a/org.thepalaceproject.android.platform b/org.thepalaceproject.android.platform index 22ceaff2..a59ccb41 160000 --- a/org.thepalaceproject.android.platform +++ b/org.thepalaceproject.android.platform @@ -1 +1 @@ -Subproject commit 22ceaff23480a46d0b334244a77490437b591627 +Subproject commit a59ccb41191cbd293cad81bec60b1a6a63865bb9