修复了歌词BUG,优化了播放器随机播放模式
This commit is contained in:
parent
907b52a700
commit
4a502e46f7
|
@ -163,7 +163,8 @@ public class bfq extends AppCompatActivity {
|
||||||
setname(bfqkz.xm.name);
|
setname(bfqkz.xm.name);
|
||||||
setzz(bfqkz.xm.zz);
|
setzz(bfqkz.xm.zz);
|
||||||
bfq_an.islike();
|
bfq_an.islike();
|
||||||
bfqkz.mt.setTX();
|
Media.setImageBitmap();
|
||||||
|
// bfqkz.mt.setTX();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
package com.muqingbfq;
|
package com.muqingbfq;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.muqingbfq.api.url;
|
import com.muqingbfq.api.url;
|
||||||
import com.muqingbfq.fragment.Media;
|
|
||||||
import com.muqingbfq.fragment.gd;
|
|
||||||
import com.muqingbfq.mq.gj;
|
import com.muqingbfq.mq.gj;
|
||||||
import com.muqingbfq.mq.wj;
|
import com.muqingbfq.mq.wj;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -60,43 +58,60 @@ public class bfq_an {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class control implements View.OnClickListener {
|
public static class control implements View.OnClickListener {
|
||||||
|
ImageView imageView;
|
||||||
|
|
||||||
public control(ImageView imageView) {
|
public control(ImageView imageView) {
|
||||||
|
this.imageView = imageView;
|
||||||
|
setImage(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setImage(int i) {
|
||||||
|
gj.sc(bfqkz.ms);
|
||||||
|
|
||||||
|
bfqkz.mt.setLooping(bfqkz.ms == 0);
|
||||||
switch (bfqkz.ms) {
|
switch (bfqkz.ms) {
|
||||||
case 0:
|
case 0:
|
||||||
imageView.setImageResource(R.drawable.mt_xh);
|
imageView.setImageResource(R.drawable.mt_xh);
|
||||||
|
if (i == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!bfqkz.list_baocun.isEmpty()) {
|
||||||
|
bfqkz.list.clear();
|
||||||
|
bfqkz.list.addAll(bfqkz.list_baocun);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
imageView.setImageResource(R.drawable.mt_sx);
|
imageView.setImageResource(R.drawable.mt_sx);
|
||||||
|
if (i == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!bfqkz.list_baocun.isEmpty()) {
|
||||||
|
bfqkz.list.clear();
|
||||||
|
bfqkz.list.addAll(bfqkz.list_baocun);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
imageView.setImageResource(R.drawable.mt_sj);
|
imageView.setImageResource(R.drawable.mt_sj);
|
||||||
|
if (i == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bfqkz.list_baocun.clear();
|
||||||
|
bfqkz.list_baocun.addAll(bfqkz.list);
|
||||||
|
Collections.shuffle(bfqkz.list);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
ImageView imageView = (ImageView) v;
|
if (bfqkz.ms == 2) {
|
||||||
switch (bfqkz.ms) {
|
bfqkz.ms = 0;
|
||||||
case 0:
|
} else {
|
||||||
bfqkz.ms = 1;
|
bfqkz.ms++;
|
||||||
imageView.setImageResource(R.drawable.mt_sx);
|
|
||||||
// 顺序
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
bfqkz.ms = 2;
|
|
||||||
imageView.setImageResource(R.drawable.mt_sj);
|
|
||||||
// 随机
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
bfqkz.ms = 0;
|
|
||||||
imageView.setImageResource(R.drawable.mt_xh);
|
|
||||||
// 循环
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
setImage(bfqkz.ms);
|
||||||
main.edit.putInt("ms", bfqkz.ms);
|
main.edit.putInt("ms", bfqkz.ms);
|
||||||
main.edit.commit();
|
main.edit.commit();
|
||||||
// imageView.setImageDrawable();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,9 @@ import java.util.Random;
|
||||||
public class bfqkz extends MediaBrowserServiceCompat {
|
public class bfqkz extends MediaBrowserServiceCompat {
|
||||||
public static MediaPlayer mt = new MediaPlayer();
|
public static MediaPlayer mt = new MediaPlayer();
|
||||||
public static List<MP3> list = new ArrayList<>();
|
public static List<MP3> list = new ArrayList<>();
|
||||||
|
|
||||||
|
//保存原始list顺序
|
||||||
|
public static List<MP3> list_baocun = new ArrayList<>();
|
||||||
public static List<MP3> lishi_list = new ArrayList<>();
|
public static List<MP3> lishi_list = new ArrayList<>();
|
||||||
public static int ms;
|
public static int ms;
|
||||||
// 0 循环 1 顺序 2 随机
|
// 0 循环 1 顺序 2 随机
|
||||||
|
@ -39,15 +42,10 @@ public class bfqkz extends MediaBrowserServiceCompat {
|
||||||
public static com.muqingbfq.mq.NotificationManagerCompat notify;
|
public static com.muqingbfq.mq.NotificationManagerCompat notify;
|
||||||
|
|
||||||
public static int getmti(int s) {
|
public static int getmti(int s) {
|
||||||
int i = bfqkz.list.indexOf(xm);
|
int i = bfqkz.list.indexOf(xm) + 1;
|
||||||
if (s == 1) {
|
|
||||||
i = bfqkz.list.indexOf(xm) + 1;
|
|
||||||
if (i >= bfqkz.list.size()) {
|
if (i >= bfqkz.list.size()) {
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
} else if (s == 2) {
|
|
||||||
i = new Random().nextInt(bfqkz.list.size());
|
|
||||||
}
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,13 +64,14 @@ public class FloatingLyricsService extends Service implements View.OnClickListen
|
||||||
|
|
||||||
public static class SETUP {
|
public static class SETUP {
|
||||||
//0是关闭 1是打开 2是锁定
|
//0是关闭 1是打开 2是锁定
|
||||||
public int i;
|
public int i = 1;
|
||||||
public float TOP, Alpha;
|
public float Alpha = 0.9f;
|
||||||
public String Color;
|
public String Color = "#0088FF";
|
||||||
public int Y;
|
public int Y = -main.g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SETUP setup = new SETUP();
|
public SETUP setup = new SETUP();
|
||||||
|
|
||||||
public int lock() {
|
public int lock() {
|
||||||
if (setup != null && setup.i == 2) {
|
if (setup != null && setup.i == 2) {
|
||||||
return WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
|
return WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
|
||||||
|
@ -79,6 +80,7 @@ public class FloatingLyricsService extends Service implements View.OnClickListen
|
||||||
return WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
return WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
||||||
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
| WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
@ -91,59 +93,53 @@ public class FloatingLyricsService extends Service implements View.OnClickListen
|
||||||
Type type = new TypeToken<SETUP>() {
|
Type type = new TypeToken<SETUP>() {
|
||||||
}.getType();
|
}.getType();
|
||||||
setup = gson.fromJson(dqwb, type);
|
setup = gson.fromJson(dqwb, type);
|
||||||
} else {
|
|
||||||
setup.i = 1;
|
|
||||||
setup.TOP = 0;
|
|
||||||
setup.Y = -main.g;
|
|
||||||
setup.Alpha = 0.9f;
|
|
||||||
setup.Color = "#0088FF";
|
|
||||||
}
|
}
|
||||||
|
// 创建悬浮窗歌词的 View
|
||||||
|
// FloatLrcviewBinding
|
||||||
|
FloatLrcviewBinding binding = FloatLrcviewBinding.inflate(LayoutInflater.from(this));
|
||||||
|
layout = binding.getRoot();
|
||||||
|
layout.setOnTouchListener(this);
|
||||||
|
// int i = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;FLAG_NOT_TOUCH_MODAL
|
||||||
|
params = new WindowManager.LayoutParams(
|
||||||
|
WindowManager.LayoutParams.MATCH_PARENT,
|
||||||
|
WindowManager.LayoutParams.WRAP_CONTENT,
|
||||||
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ?
|
||||||
|
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY :
|
||||||
|
WindowManager.LayoutParams.TYPE_PHONE,
|
||||||
|
lock(),
|
||||||
|
PixelFormat.TRANSLUCENT
|
||||||
|
);
|
||||||
|
|
||||||
|
params.y = setup.Y;
|
||||||
|
|
||||||
|
lrcView = binding.lrcView;
|
||||||
|
lrcView.setTextColor(setup.Color);
|
||||||
|
bfq_an.kz bfqAn = new bfq_an.kz();
|
||||||
|
binding.kg.setOnClickListener(this);
|
||||||
|
binding.syq.setOnClickListener(bfqAn);
|
||||||
|
binding.xyq.setOnClickListener(bfqAn);
|
||||||
|
binding.lock.setOnClickListener(this);
|
||||||
|
// params.gravity = Gravity.CENTER;
|
||||||
|
|
||||||
|
|
||||||
|
// 获取 WindowManager 并将悬浮窗歌词添加到窗口中
|
||||||
|
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||||
|
if (setup.i == 2) {
|
||||||
|
params.flags = lock();
|
||||||
|
layout.setBackground(null);
|
||||||
|
lrcView.setAlpha(0.5f);
|
||||||
|
layout.findViewById(com.muqingbfq.R.id.controlLayout).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
windowManager.addView(layout, params);
|
||||||
|
if (setup.i == 0) {
|
||||||
|
setup.i = 1;
|
||||||
|
}
|
||||||
|
baocun();
|
||||||
|
handler.post(updateSeekBar); // 在播放开始时启动更新进度
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
wj.sc(file.toString());
|
wj.sc(file.toString());
|
||||||
gj.sc(getClass() + ":" + e);
|
gj.sc(getClass() + ":" + e);
|
||||||
}
|
}
|
||||||
// 创建悬浮窗歌词的 View
|
|
||||||
// FloatLrcviewBinding
|
|
||||||
FloatLrcviewBinding binding = FloatLrcviewBinding.inflate(LayoutInflater.from(this));
|
|
||||||
layout = binding.getRoot();
|
|
||||||
layout.setOnTouchListener(this);
|
|
||||||
// int i = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;FLAG_NOT_TOUCH_MODAL
|
|
||||||
params = new WindowManager.LayoutParams(
|
|
||||||
WindowManager.LayoutParams.MATCH_PARENT,
|
|
||||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ?
|
|
||||||
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY :
|
|
||||||
WindowManager.LayoutParams.TYPE_PHONE,
|
|
||||||
lock(),
|
|
||||||
PixelFormat.TRANSLUCENT
|
|
||||||
);
|
|
||||||
|
|
||||||
params.y = setup.Y;
|
|
||||||
|
|
||||||
lrcView = binding.lrcView;
|
|
||||||
lrcView.setTextColor(setup.Color);
|
|
||||||
bfq_an.kz bfqAn = new bfq_an.kz();
|
|
||||||
binding.kg.setOnClickListener(this);
|
|
||||||
binding.syq.setOnClickListener(bfqAn);
|
|
||||||
binding.xyq.setOnClickListener(bfqAn);
|
|
||||||
binding.lock.setOnClickListener(this);
|
|
||||||
// params.gravity = Gravity.CENTER;
|
|
||||||
|
|
||||||
|
|
||||||
// 获取 WindowManager 并将悬浮窗歌词添加到窗口中
|
|
||||||
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
|
||||||
if (setup.i == 2) {
|
|
||||||
params.flags = lock();
|
|
||||||
layout.setBackground(null);
|
|
||||||
lrcView.setAlpha(0.5f);
|
|
||||||
layout.findViewById(com.muqingbfq.R.id.controlLayout).setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
windowManager.addView(layout, params);
|
|
||||||
if (setup.i == 0) {
|
|
||||||
setup.i = 1;
|
|
||||||
}
|
|
||||||
baocun();
|
|
||||||
handler.post(updateSeekBar); // 在播放开始时启动更新进度
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -211,7 +207,7 @@ public class FloatingLyricsService extends Service implements View.OnClickListen
|
||||||
bfqkz.mt.start();
|
bfqkz.mt.start();
|
||||||
kg.setImageResource(R.drawable.bf);
|
kg.setImageResource(R.drawable.bf);
|
||||||
}
|
}
|
||||||
} else if (id==R.id.lock) {
|
} else if (id == R.id.lock) {
|
||||||
setyc();
|
setyc();
|
||||||
} else if (id == R.id.like) {
|
} else if (id == R.id.like) {
|
||||||
// bfq
|
// bfq
|
||||||
|
@ -222,7 +218,7 @@ public class FloatingLyricsService extends Service implements View.OnClickListen
|
||||||
setup.i = 2;
|
setup.i = 2;
|
||||||
params.flags = lock();
|
params.flags = lock();
|
||||||
layout.setBackground(null);
|
layout.setBackground(null);
|
||||||
lrcView.setAlpha(0.5f);
|
lrcView.setAlpha(setup.Alpha);
|
||||||
layout.findViewById(com.muqingbfq.R.id.controlLayout).setVisibility(View.GONE);
|
layout.findViewById(com.muqingbfq.R.id.controlLayout).setVisibility(View.GONE);
|
||||||
windowManager.updateViewLayout(layout, params);
|
windowManager.updateViewLayout(layout, params);
|
||||||
baocun();
|
baocun();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.muqingbfq.view;
|
package com.muqingbfq.view;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
@ -8,6 +9,9 @@ import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
import com.google.android.material.card.MaterialCardView;
|
import com.google.android.material.card.MaterialCardView;
|
||||||
import com.muqingbfq.R;
|
import com.muqingbfq.R;
|
||||||
|
import com.muqingbfq.bfq;
|
||||||
|
import com.muqingbfq.main;
|
||||||
|
import com.muqingbfq.mq.gj;
|
||||||
|
|
||||||
public class CardImage extends MaterialCardView {
|
public class CardImage extends MaterialCardView {
|
||||||
private ImageView imageView;
|
private ImageView imageView;
|
||||||
|
@ -35,7 +39,7 @@ public class CardImage extends MaterialCardView {
|
||||||
|
|
||||||
|
|
||||||
public void setImage(Object bitmap) {
|
public void setImage(Object bitmap) {
|
||||||
Glide.with(getContext())
|
Glide.with(this)
|
||||||
.load(bitmap)
|
.load(bitmap)
|
||||||
// .apply(new RequestOptions().placeholder(R.drawable.icon))
|
// .apply(new RequestOptions().placeholder(R.drawable.icon))
|
||||||
.into(imageView);
|
.into(imageView);
|
||||||
|
|
|
@ -24,34 +24,45 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.muqingbfq.R;
|
import com.muqingbfq.R;
|
||||||
import com.muqingbfq.mq.gj;
|
import com.muqingbfq.mq.gj;
|
||||||
|
import com.muqingbfq.yc;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class LrcView extends RecyclerView {
|
public class LrcView extends RecyclerView {
|
||||||
|
|
||||||
static List<lrc> lrclist = new ArrayList<>();
|
static List<LRC> lrclist = new ArrayList<>();
|
||||||
|
|
||||||
static class lrc {
|
static class LRC {
|
||||||
String lrc, tlyric;
|
String lrc, tlyric;
|
||||||
long time;
|
long time;
|
||||||
|
|
||||||
public lrc(String lrc, long time) {
|
public LRC(String lrc, long time) {
|
||||||
this.lrc = lrc;
|
this.lrc = lrc;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public lrc(String lrc, String tlyric, long time) {
|
@Override
|
||||||
this.lrc = lrc;
|
public boolean equals(Object obj) {
|
||||||
this.tlyric = tlyric;
|
if (this == obj) {
|
||||||
this.time = time;
|
return true;
|
||||||
|
}
|
||||||
|
if (obj == null || getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
LRC lrc = (LRC) obj;
|
||||||
|
return time == lrc.time;
|
||||||
}
|
}
|
||||||
|
public LRC setTlyric(String str) {
|
||||||
public lrc setTlyric(String str) {
|
|
||||||
this.tlyric = str;
|
this.tlyric = str;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return java.util.Objects.hash(time);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LrcView(Context context) {
|
public LrcView(Context context) {
|
||||||
|
@ -81,8 +92,9 @@ public class LrcView extends RecyclerView {
|
||||||
public void setTextColor(String textColor) {
|
public void setTextColor(String textColor) {
|
||||||
TextColor = Color.parseColor(textColor);
|
TextColor = Color.parseColor(textColor);
|
||||||
}
|
}
|
||||||
|
public void setLrcline(boolean lrcline) {
|
||||||
|
Lrcline = lrcline;
|
||||||
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
if (attrs != null) {
|
if (attrs != null) {
|
||||||
|
@ -145,40 +157,50 @@ public class LrcView extends RecyclerView {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setLrc(String a, String b) {
|
public static void setLrc(String a, String b) {
|
||||||
setLrc(a);
|
try {
|
||||||
if (TextUtils.isEmpty(b)) {
|
lrclist.clear();
|
||||||
return;
|
setLrc(a);
|
||||||
}
|
setLrc(b);
|
||||||
b.trim();
|
if (true) {
|
||||||
String[] lines = b.split("\n");
|
return;
|
||||||
for (String line : lines) {
|
}
|
||||||
String[] parts = line.split("]");
|
if (TextUtils.isEmpty(b)) {
|
||||||
if (parts.length >= 2) {
|
return;
|
||||||
String timeString = parts[0].substring(1);
|
}
|
||||||
String lyric = parts[1].trim();
|
b.trim();
|
||||||
String[] timeParts = timeString.split(":");
|
String[] lines = b.split("\n");
|
||||||
if (timeParts.length >= 2) {
|
for (String line : lines) {
|
||||||
int minute = Integer.parseInt(timeParts[0]);
|
String[] parts = line.split("]");
|
||||||
String[] secondParts = timeParts[1].split("\\.");
|
if (parts.length >= 2) {
|
||||||
if (secondParts.length >= 2) {
|
String timeString = parts[0].substring(1);
|
||||||
int second = Integer.parseInt(secondParts[0]);
|
String lyric = parts[1].trim();
|
||||||
int millisecond = Integer.parseInt(secondParts[1]);
|
String[] timeParts = timeString.split(":");
|
||||||
long time = (long) minute * 60 * 1000 + second * 1000L + millisecond;
|
if (timeParts.length >= 2) {
|
||||||
int currentLineIndex = getCurrentLineIndex(time);
|
int minute = Integer.parseInt(timeParts[0]);
|
||||||
lrclist.set(currentLineIndex, lrclist.get(currentLineIndex).setTlyric(lyric));
|
String[] secondParts = timeParts[1].split("[.\\-]");
|
||||||
|
if (secondParts.length >= 2) {
|
||||||
|
int second = Integer.parseInt(secondParts[0]);
|
||||||
|
int millisecond = Integer.parseInt(secondParts[1]);
|
||||||
|
long time = (long) minute * 60 * 1000 + second * 1000L + millisecond;
|
||||||
|
int currentLineIndex = getCurrentLineIndex(time);
|
||||||
|
lrclist.set(currentLineIndex,
|
||||||
|
lrclist.get(currentLineIndex).setTlyric(lyric));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
yc.start("LrcView setLrc :" + e + a + b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setLrc(String a) {
|
public static void setLrc(String a) {
|
||||||
lrclist.clear();
|
|
||||||
// 去除空格
|
// 去除空格
|
||||||
a.trim();
|
|
||||||
if (TextUtils.isEmpty(a)) {
|
if (TextUtils.isEmpty(a)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
a.trim();
|
||||||
String[] lines = a.split("\n");
|
String[] lines = a.split("\n");
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
String[] parts = line.split("]");
|
String[] parts = line.split("]");
|
||||||
|
@ -188,12 +210,18 @@ public class LrcView extends RecyclerView {
|
||||||
String[] timeParts = timeString.split(":");
|
String[] timeParts = timeString.split(":");
|
||||||
if (timeParts.length >= 2) {
|
if (timeParts.length >= 2) {
|
||||||
int minute = Integer.parseInt(timeParts[0]);
|
int minute = Integer.parseInt(timeParts[0]);
|
||||||
String[] secondParts = timeParts[1].split("\\.");
|
String[] secondParts = timeParts[1].split("[.\\-]");
|
||||||
if (secondParts.length >= 2) {
|
if (secondParts.length >= 2) {
|
||||||
int second = Integer.parseInt(secondParts[0]);
|
int second = Integer.parseInt(secondParts[0]);
|
||||||
int millisecond = Integer.parseInt(secondParts[1]);
|
int millisecond = Integer.parseInt(secondParts[1]);
|
||||||
long time = (long) minute * 60 * 1000 + second * 1000L + millisecond;
|
long time = (long) minute * 60 * 1000 + second * 1000L + millisecond;
|
||||||
lrclist.add(new lrc(lyric, time));
|
LRC lrc = new LRC(lyric, time);
|
||||||
|
if (lrclist.contains(lrc)) {
|
||||||
|
int index = lrclist.indexOf(lrc);
|
||||||
|
lrclist.get(index).setTlyric(lyric);
|
||||||
|
} else {
|
||||||
|
lrclist.add(lrc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,7 +272,7 @@ public class LrcView extends RecyclerView {
|
||||||
|
|
||||||
String text;
|
String text;
|
||||||
if (lrclist.size() <= 3) {
|
if (lrclist.size() <= 3) {
|
||||||
for (lrc a : lrclist) {
|
for (LRC a : lrclist) {
|
||||||
if (a.time == 5940000 && a.lrc.equals("纯音乐,请欣赏")) {
|
if (a.time == 5940000 && a.lrc.equals("纯音乐,请欣赏")) {
|
||||||
text = "纯音乐,请欣赏";
|
text = "纯音乐,请欣赏";
|
||||||
holder.textView.setText(text);
|
holder.textView.setText(text);
|
||||||
|
@ -252,7 +280,7 @@ public class LrcView extends RecyclerView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lrc currentLrc = lrclist.get(currentLineIndex);
|
LRC currentLrc = lrclist.get(currentLineIndex);
|
||||||
text = currentLrc.lrc;
|
text = currentLrc.lrc;
|
||||||
if (currentLrc.tlyric != null) {
|
if (currentLrc.tlyric != null) {
|
||||||
text += "\n" + currentLrc.tlyric;
|
text += "\n" + currentLrc.tlyric;
|
||||||
|
@ -265,7 +293,7 @@ public class LrcView extends RecyclerView {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
lrc lrc = lrclist.get(position);
|
LRC lrc = lrclist.get(position);
|
||||||
StringBuilder stringBuffer = new StringBuilder();
|
StringBuilder stringBuffer = new StringBuilder();
|
||||||
stringBuffer.append(lrc.lrc);
|
stringBuffer.append(lrc.lrc);
|
||||||
if (lrc.tlyric != null) {
|
if (lrc.tlyric != null) {
|
||||||
|
@ -286,7 +314,7 @@ public class LrcView extends RecyclerView {
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
if (lrclist.size() < 3) {
|
if (lrclist.size() < 3) {
|
||||||
for (lrc a : lrclist) {
|
for (LRC a : lrclist) {
|
||||||
if (a.time == 5940000 && a.lrc.equals("纯音乐,请欣赏")) {
|
if (a.time == 5940000 && a.lrc.equals("纯音乐,请欣赏")) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -314,7 +342,7 @@ public class LrcView extends RecyclerView {
|
||||||
private int getCurrentLineIndex() {
|
private int getCurrentLineIndex() {
|
||||||
index = -1;
|
index = -1;
|
||||||
for (int i = 0; i < lrclist.size(); i++) {
|
for (int i = 0; i < lrclist.size(); i++) {
|
||||||
lrc lineLrc = lrclist.get(i);
|
LRC lineLrc = lrclist.get(i);
|
||||||
if (lineLrc.time <= time) {
|
if (lineLrc.time <= time) {
|
||||||
index = i;
|
index = i;
|
||||||
} else {
|
} else {
|
||||||
|
@ -327,7 +355,7 @@ public class LrcView extends RecyclerView {
|
||||||
private static int getCurrentLineIndex(long time) {
|
private static int getCurrentLineIndex(long time) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (int i = 0; i < lrclist.size(); i++) {
|
for (int i = 0; i < lrclist.size(); i++) {
|
||||||
lrc lineLrc = lrclist.get(i);
|
LRC lineLrc = lrclist.get(i);
|
||||||
if (lineLrc.time <= time) {
|
if (lineLrc.time <= time) {
|
||||||
index = i;
|
index = i;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -14,14 +14,17 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
import com.muqingbfq.databinding.ActivityYcBinding;
|
import com.muqingbfq.databinding.ActivityYcBinding;
|
||||||
|
import com.muqingbfq.mq.gj;
|
||||||
|
|
||||||
public class yc extends AppCompatActivity {
|
public class yc extends AppCompatActivity {
|
||||||
public static Object exception;
|
public Object exception;
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
ActivityYcBinding binding = ActivityYcBinding.inflate(getLayoutInflater());
|
ActivityYcBinding binding = ActivityYcBinding.inflate(getLayoutInflater());
|
||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
|
Intent intent = getIntent();
|
||||||
|
exception = intent.getStringExtra("e");
|
||||||
|
|
||||||
String deviceModel = Build.MODEL;
|
String deviceModel = Build.MODEL;
|
||||||
String deviceManufacturer = Build.MANUFACTURER;
|
String deviceManufacturer = Build.MANUFACTURER;
|
||||||
|
@ -52,8 +55,10 @@ public class yc extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void start(Context context, Object e) {
|
public static void start(Context context, Object e) {
|
||||||
yc.exception = e;
|
gj.sc(e);
|
||||||
context.startActivity(new Intent(context, yc.class));
|
Intent intent = new Intent(context, yc.class);
|
||||||
|
intent.putExtra("e",e.toString());
|
||||||
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void tc(Context context, Object exception) {
|
public static void tc(Context context, Object exception) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user