Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
fixed remaining time of sleep timer
Browse files Browse the repository at this point in the history
  • Loading branch information
jamal2362 committed Sep 23, 2023
1 parent 92b0e80 commit adb2386
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions app/src/main/java/com/jamal2367/urlradio/ui/LayoutHolder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.google.android.material.snackbar.Snackbar
import com.jamal2367.urlradio.Keys
import com.jamal2367.urlradio.R
import com.jamal2367.urlradio.core.Station
import com.jamal2367.urlradio.helpers.DateTimeHelper
import com.jamal2367.urlradio.helpers.ImageHelper
import com.jamal2367.urlradio.helpers.PreferencesHelper
import com.jamal2367.urlradio.helpers.UiHelper
Expand Down Expand Up @@ -275,7 +276,7 @@ data class LayoutHolder(var rootView: View) {
}
else -> {
sleepTimerRunningViews.isVisible = true
val sleepTimerTimeRemaining = convertToHHmmss(timeRemaining)
val sleepTimerTimeRemaining = DateTimeHelper.convertToMinutesAndSeconds(timeRemaining)
sheetSleepTimerRemainingTimeView.text = sleepTimerTimeRemaining
sheetSleepTimerRemainingTimeView.contentDescription = "${context.getString(R.string.descr_expanded_player_sleep_timer_remaining_time)}: $sleepTimerTimeRemaining"
stationNameView.isSelected = false
Expand All @@ -284,17 +285,6 @@ data class LayoutHolder(var rootView: View) {
}


private fun convertToHHmmss(milliseconds: Long): String {
val hours = TimeUnit.MILLISECONDS.toHours(milliseconds)
val minutes = TimeUnit.MILLISECONDS.toMinutes(milliseconds) % 60
val seconds = TimeUnit.MILLISECONDS.toSeconds(milliseconds) % 60

val dateFormat = SimpleDateFormat("HH:mm:ss", Locale.US)
val date = Date(hours * 60 * 60 * 1000 + minutes * 60 * 1000 + seconds * 1000)
return dateFormat.format(date)
}


/* Toggles play/pause button */
fun togglePlayButton(isPlaying: Boolean) {
if (isPlaying) {
Expand Down

0 comments on commit adb2386

Please sign in to comment.