From 03bbdcf160cdc07f416dec73667bf35a141a12c2 Mon Sep 17 00:00:00 2001 From: xufuji456 <839789740@qq.com> Date: Sun, 1 Aug 2021 16:08:31 +0800 Subject: [PATCH] move timeConvert method to TimeUtil --- .../java/com/frank/ffmpeg/tool/LrcLineTool.kt | 15 ++------------- .../main/java/com/frank/ffmpeg/util/TimeUtil.kt | 11 +++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/frank/ffmpeg/tool/LrcLineTool.kt b/app/src/main/java/com/frank/ffmpeg/tool/LrcLineTool.kt index c8d1ce9..451b305 100644 --- a/app/src/main/java/com/frank/ffmpeg/tool/LrcLineTool.kt +++ b/app/src/main/java/com/frank/ffmpeg/tool/LrcLineTool.kt @@ -1,6 +1,7 @@ package com.frank.ffmpeg.tool import com.frank.ffmpeg.model.LrcLine +import com.frank.ffmpeg.util.TimeUtil import java.util.ArrayList import java.util.Collections @@ -28,7 +29,7 @@ object LrcLineTool { val mLrcLine = LrcLine() mLrcLine.content = content mLrcLine.timeString = temp - val startTime = timeConvert(temp) + val startTime = TimeUtil.timeConvert(temp) mLrcLine.startTime = startTime listTimes.add(mLrcLine) } @@ -40,18 +41,6 @@ object LrcLineTool { } - /** - * string time to milliseconds - */ - private fun timeConvert(timeStr: String): Long { - var timeString = timeStr - timeString = timeString.replace('.', ':') - val times = timeString.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() - return (Integer.valueOf(times[0]) * 60 * 1000 + - Integer.valueOf(times[1]) * 1000 + - Integer.valueOf(times[2])).toLong() - } - fun getLrcLine(line: String?): List? { if (line == null || line.isEmpty()) { return null diff --git a/app/src/main/java/com/frank/ffmpeg/util/TimeUtil.kt b/app/src/main/java/com/frank/ffmpeg/util/TimeUtil.kt index af743b5..7d85562 100644 --- a/app/src/main/java/com/frank/ffmpeg/util/TimeUtil.kt +++ b/app/src/main/java/com/frank/ffmpeg/util/TimeUtil.kt @@ -79,4 +79,15 @@ object TimeUtil { } } + /** + * string time to milliseconds + */ + fun timeConvert(timeStr: String): Long { + var timeString = timeStr + timeString = timeString.replace('.', ':') + val times = timeString.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() + return (Integer.valueOf(times[0]) * 60 * 1000 + + Integer.valueOf(times[1]) * 1000 + + Integer.valueOf(times[2])).toLong() + } }