From da712f45768dca9cd28fe73e94bd79957c1a2b2f Mon Sep 17 00:00:00 2001 From: tva2000hn Date: Tue, 24 Sep 2019 19:56:03 +0700 Subject: [PATCH] Update LrcHelper.java --- .../name/monkey/retromusic/lyrics/LrcHelper.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/code/name/monkey/retromusic/lyrics/LrcHelper.java b/app/src/main/java/code/name/monkey/retromusic/lyrics/LrcHelper.java index e6fb2d7e..d2c05193 100644 --- a/app/src/main/java/code/name/monkey/retromusic/lyrics/LrcHelper.java +++ b/app/src/main/java/code/name/monkey/retromusic/lyrics/LrcHelper.java @@ -42,8 +42,8 @@ public class LrcHelper { private static final String CHARSET = "utf-8"; //[03:56.00][03:18.00][02:06.00][01:07.00]原谅我这一生不羁放纵爱自由 - private static final String LINE_REGEX = "((\\[\\d{2}:\\d{2}\\.\\d{2}])+)(.*)"; - private static final String TIME_REGEX = "\\[(\\d{2}):(\\d{2})\\.(\\d{2})]"; + private static final String LINE_REGEX = "((\\[\\d{2}:\\d{2}\\.\\d{2,3}])+)(.*)"; + private static final String TIME_REGEX = "\\[(\\d{2}):(\\d{2})\\.(\\d{2,3})]"; public static List parseLrcFromAssets(Context context, String fileName) { try { @@ -127,8 +127,14 @@ public class LrcHelper { String mil = timeMatcher.group(3); Lrc lrc = new Lrc(); if (content != null && content.length() != 0) { - lrc.setTime(Long.parseLong(min) * 60 * 1000 + Long.parseLong(sec) * 1000 - + Long.parseLong(mil) * 10); + if(Integer.parseInt(mil)< 100){ + lrc.setTime(Long.parseLong(min) * 60 * 1000 + Long.parseLong(sec) * 1000 + + Long.parseLong(mil) * 10);} + else{ + lrc.setTime(Long.parseLong(min) * 60 * 1000 + Long.parseLong(sec) * 1000 + + Long.parseLong(mil) + ); + } lrc.setText(content); lrcs.add(lrc); } @@ -148,4 +154,4 @@ public class LrcHelper { } return time + ""; } -} \ No newline at end of file +}