From 549a487148522fa4a459967cd6546e22a315ae52 Mon Sep 17 00:00:00 2001
From: Runt <qingingrunt2010@qq.com>
Date: Mon, 26 Dec 2022 15:17:52 +0000
Subject: [PATCH] 上传歌词
---
app/src/main/java/com/auto/lyric/data/LyricServer.java | 32 +++++++++++++++-----------------
1 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/app/src/main/java/com/auto/lyric/data/LyricServer.java b/app/src/main/java/com/auto/lyric/data/LyricServer.java
index 2741d2c..7b47db2 100644
--- a/app/src/main/java/com/auto/lyric/data/LyricServer.java
+++ b/app/src/main/java/com/auto/lyric/data/LyricServer.java
@@ -6,7 +6,6 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.util.Iterator;
import java.util.List;
import java.util.TreeMap;
import java.util.regex.Matcher;
@@ -69,18 +68,22 @@
// System.out.println("++++++++++++>>"+data);
/*text = text.replace("[","");//将前面的替换成后面的
text = text.replace("]","@");
- String splitdata[] = text.split("@");//分隔*/
+ String splitdata[] = text.split("@");//分隔
String regex = "(?<=\\])";
Pattern compile = Pattern.compile(regex);
- String[] splitdata = compile.split(text,2);//分隔
- if(text.endsWith("]") || splitdata.length == 1){
-
- String str = text;
- str = str.replace("[","");
- str = str.replace("]","");
- str = str.replace(":",".");
- str = str.replace(".","@");
- String timedata[] =str.split("@");
+ String[] splitdata = compile.split(text,2);//分隔*/
+ int index = text.indexOf("]");
+ String[] splitdata;
+ if(text.length()-1 == index){
+ splitdata = new String[]{text};
+ }else{
+ splitdata = new String[]{text.substring(0,index),text.substring(index+1)};
+ }
+ String tmpstr = splitdata[0].replace("[","").replace("]","");
+ if(splitdata.length == 1){
+ tmpstr = tmpstr.replace(":",".");
+ tmpstr = tmpstr.replace(".","@");
+ String timedata[] =tmpstr.split("@");
Matcher matcher = pattern.matcher(timedata[0]);
if(timedata.length==3 && matcher.matches()){
int m = Integer.parseInt(timedata[0]); //分
@@ -94,9 +97,6 @@
}
} else{
String lrcContenet = splitdata[1];
- String tmpstr = splitdata[0];
- tmpstr = tmpstr.replace("[","");
- tmpstr = tmpstr.replace("]","");
tmpstr = tmpstr.replace(":",".");
tmpstr = tmpstr.replace(".","@");
String timedata[] =tmpstr.split("@");
@@ -119,7 +119,6 @@
*/
private static void initLrc(TreeMap<Integer, LyricObject> lrc_read){
lrc_map.clear();
- Iterator<Integer> iterator = lrc_read.keySet().iterator();
LyricObject oldval = null;
int i =0;
for(Integer key : lrc_read.keySet()){
@@ -127,8 +126,7 @@
if (oldval == null) {
oldval = val;
} else {
- LyricObject item1= new LyricObject();
- item1 = oldval;
+ LyricObject item1 = oldval;
item1.timeline = val.begintime-oldval.begintime;
lrc_map.put(new Integer(i), item1);
i++;
--
Gitblit v1.9.1