mirror of
https://github.com/NiciDieNase/chaosflix
synced 2024-11-26 06:00:25 +00:00
Leanback: update formatstring to also use hours
This commit is contained in:
parent
b2188b8c19
commit
4e8d5fb371
1 changed files with 13 additions and 2 deletions
|
@ -157,7 +157,7 @@ class ChaosflixSeekDataProvider(
|
||||||
Log.d(TAG, "Thumb size: ${thumb.width}x${thumb.height}")
|
Log.d(TAG, "Thumb size: ${thumb.width}x${thumb.height}")
|
||||||
|
|
||||||
val seconds = positions[index] / 1000
|
val seconds = positions[index] / 1000
|
||||||
val time = String.format("%d:%02d:%02d",(seconds / 3600) ,(seconds / 60) % 60, seconds % 60)
|
val time = formatTime(seconds)
|
||||||
drawStringToBitmap(thumb, time)
|
drawStringToBitmap(thumb, time)
|
||||||
|
|
||||||
val duration = System.currentTimeMillis() - startTime
|
val duration = System.currentTimeMillis() - startTime
|
||||||
|
@ -166,6 +166,17 @@ class ChaosflixSeekDataProvider(
|
||||||
return thumb
|
return thumb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun formatTime(seconds: Long): String {
|
||||||
|
val s = seconds % 60
|
||||||
|
val m = (seconds / 60) % 60
|
||||||
|
val h = seconds / 3600
|
||||||
|
return if(h > 0){
|
||||||
|
String.format("%d:%02d:%02d", h, m, s)
|
||||||
|
} else {
|
||||||
|
String.format("%d:%02d", m, s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun drawStringToBitmap(thumb: Bitmap, time: String) {
|
private fun drawStringToBitmap(thumb: Bitmap, time: String) {
|
||||||
val canvas = Canvas(thumb)
|
val canvas = Canvas(thumb)
|
||||||
val paint = Paint()
|
val paint = Paint()
|
||||||
|
@ -192,7 +203,7 @@ class ChaosflixSeekDataProvider(
|
||||||
|
|
||||||
private fun createDummyThumbnail(index: Int): Bitmap {
|
private fun createDummyThumbnail(index: Int): Bitmap {
|
||||||
val seconds = positions[index] / 1000
|
val seconds = positions[index] / 1000
|
||||||
val time = String.format("%d:%02d", seconds / 60, seconds % 60)
|
val time = formatTime(seconds)
|
||||||
val bitmap = Bitmap.createBitmap(THUMB_WIDTH, THUMB_HEIGHT, Bitmap.Config.ARGB_8888)
|
val bitmap = Bitmap.createBitmap(THUMB_WIDTH, THUMB_HEIGHT, Bitmap.Config.ARGB_8888)
|
||||||
|
|
||||||
drawStringToBitmap(bitmap, time)
|
drawStringToBitmap(bitmap, time)
|
||||||
|
|
Loading…
Reference in a new issue