mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-29 09:39:03 +03:00
Added Hour timer to Episode Porgress (#438)
A simple QOL to add an Hour part to the Episode Progress when it goes above 60 minutes
This commit is contained in:
parent
28301d09b9
commit
6db203c219
1 changed files with 48 additions and 18 deletions
|
@ -1,6 +1,7 @@
|
|||
package eu.kanade.tachiyomi.ui.anime.episode
|
||||
|
||||
import android.text.SpannableStringBuilder
|
||||
import android.text.SpannedString
|
||||
import android.view.View
|
||||
import androidx.core.text.buildSpannedString
|
||||
import androidx.core.text.color
|
||||
|
@ -64,28 +65,57 @@ class EpisodeHolder(
|
|||
descriptions.add(Date(episode.date_upload).toRelativeString(itemView.context, adapter.relativeTime, adapter.dateFormat))
|
||||
}
|
||||
if (!episode.seen && episode.last_second_seen > 0) {
|
||||
val lastPageRead = buildSpannedString {
|
||||
color(adapter.readColor) {
|
||||
append(
|
||||
itemView.context.getString(
|
||||
R.string.episode_progress,
|
||||
String.format(
|
||||
"%d:%02d",
|
||||
TimeUnit.MILLISECONDS.toMinutes(episode.last_second_seen),
|
||||
TimeUnit.MILLISECONDS.toSeconds(episode.last_second_seen) -
|
||||
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(episode.last_second_seen))
|
||||
),
|
||||
String.format(
|
||||
"%d:%02d",
|
||||
TimeUnit.MILLISECONDS.toMinutes(episode.total_seconds),
|
||||
TimeUnit.MILLISECONDS.toSeconds(episode.total_seconds) -
|
||||
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(episode.total_seconds))
|
||||
val lastSecondSeen: SpannedString
|
||||
if (episode.total_seconds > 3600000) {
|
||||
lastSecondSeen = buildSpannedString {
|
||||
color(adapter.readColor) {
|
||||
append(
|
||||
itemView.context.getString(
|
||||
R.string.episode_progress,
|
||||
String.format(
|
||||
"%d:%02d:%02d",
|
||||
TimeUnit.MILLISECONDS.toHours(episode.last_second_seen),
|
||||
TimeUnit.MILLISECONDS.toMinutes(episode.last_second_seen) -
|
||||
TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(episode.last_second_seen)),
|
||||
TimeUnit.MILLISECONDS.toSeconds(episode.last_second_seen) -
|
||||
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(episode.last_second_seen))
|
||||
),
|
||||
String.format(
|
||||
"%d:%02d:%02d",
|
||||
TimeUnit.MILLISECONDS.toHours(episode.total_seconds),
|
||||
TimeUnit.MILLISECONDS.toMinutes(episode.total_seconds) -
|
||||
TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(episode.total_seconds)),
|
||||
TimeUnit.MILLISECONDS.toSeconds(episode.total_seconds) -
|
||||
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(episode.total_seconds))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lastSecondSeen = buildSpannedString {
|
||||
color(adapter.readColor) {
|
||||
append(
|
||||
itemView.context.getString(
|
||||
R.string.episode_progress,
|
||||
String.format(
|
||||
"%d:%02d",
|
||||
TimeUnit.MILLISECONDS.toMinutes(episode.last_second_seen),
|
||||
TimeUnit.MILLISECONDS.toSeconds(episode.last_second_seen) -
|
||||
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(episode.last_second_seen))
|
||||
),
|
||||
String.format(
|
||||
"%d:%02d",
|
||||
TimeUnit.MILLISECONDS.toMinutes(episode.total_seconds),
|
||||
TimeUnit.MILLISECONDS.toSeconds(episode.total_seconds) -
|
||||
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(episode.total_seconds))
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
descriptions.add(lastPageRead)
|
||||
descriptions.add(lastSecondSeen)
|
||||
}
|
||||
if (!episode.scanlator.isNullOrBlank()) {
|
||||
descriptions.add(episode.scanlator!!)
|
||||
|
|
Loading…
Reference in a new issue