修复已知BUG

This commit is contained in:
muqing 2023-12-27 11:00:20 +08:00
parent 4dbf60876c
commit b28e67237f
6 changed files with 36 additions and 61 deletions

View File

@ -1,12 +1,10 @@
package com.muqingbfq; package com.muqingbfq;
import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
public class MP3 { public class MP3 {
public String id, name, zz; public String id, name, zz;
// 音乐的贴图 // 音乐的贴图
public String picurl; public String picurl;
public MP3(String id, String name, String zz, String picurl) { public MP3(String id, String name, String zz, String picurl) {
this.id = id; this.id = id;
this.name = name; this.name = name;

View File

@ -56,10 +56,7 @@ public class MediaPlayer extends android.media.MediaPlayer {
if (bfqkz.list.isEmpty()) { if (bfqkz.list.isEmpty()) {
return; return;
} }
int i = bfqkz.getmti(bfqkz.ms); bfq_an.xyq();
bfqkz.xm = bfqkz.list.get(i);
new bfqkz.mp3(com.muqingbfq.api.
url.hq(bfqkz.xm));
}); });
setAudioAttributes(new AudioAttributes setAudioAttributes(new AudioAttributes
.Builder() .Builder()
@ -98,7 +95,7 @@ public class MediaPlayer extends android.media.MediaPlayer {
start(); start();
main.handler.post(() -> { main.handler.post(() -> {
bfui(); bfui();
if (bfq.binding != null) { if (bfq.view != null) {
main.handler.removeCallbacks(updateSeekBar); // 在播放开始时启动更新进度 main.handler.removeCallbacks(updateSeekBar); // 在播放开始时启动更新进度
long duration = getDuration(); long duration = getDuration();
Media.setMax((int) getDuration()); Media.setMax((int) getDuration());
@ -156,7 +153,7 @@ public class MediaPlayer extends android.media.MediaPlayer {
public void bfui() { public void bfui() {
setTX(); setTX();
String name = xm.name, zz = bfqkz.xm.zz; String name = xm.name, zz = bfqkz.xm.zz;
if (bfq.binding != null) { if (bfq.view != null) {
Media.setProgress(0); Media.setProgress(0);
bfq.setname(name); bfq.setname(name);
bfq.setzz(zz); bfq.setzz(zz);

View File

@ -44,8 +44,9 @@ import me.wcy.lrcview.LrcView;
public class bfq extends AppCompatActivity { public class bfq extends AppCompatActivity {
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
public static ActivityBfqBinding binding; public static ActivityBfqBinding binding;
@SuppressLint("StaticFieldLeak")
public static View view;
public static String lrc; public static String lrc;
public static LrcView lrcview; public static LrcView lrcview;
private void setLrc(){ private void setLrc(){
lrcview = binding.lrcView; lrcview = binding.lrcView;
@ -82,12 +83,12 @@ public class bfq extends AppCompatActivity {
binding = ActivityBfqBinding.inflate(getLayoutInflater()); binding = ActivityBfqBinding.inflate(getLayoutInflater());
setLrc(); setLrc();
new Media(binding); new Media(binding);
LinearLayout root = binding.getRoot(); view = binding.getRoot();
TypedValue typedValue = new TypedValue(); TypedValue typedValue = new TypedValue();
home.appCompatActivity.getTheme().resolveAttribute(android.R.attr.windowBackground, typedValue, true); home.appCompatActivity.getTheme().resolveAttribute(android.R.attr.windowBackground, typedValue, true);
// 设置背景颜色 // 设置背景颜色
root.setBackgroundColor(typedValue.data); view.setBackgroundColor(typedValue.data);
setContentView(root); setContentView(view);
Toolbar toolbar = binding.toolbar; Toolbar toolbar = binding.toolbar;
toolbar.setNavigationOnClickListener(view1 -> finish()); toolbar.setNavigationOnClickListener(view1 -> finish());
toolbar.setOnMenuItemClickListener(item -> { toolbar.setOnMenuItemClickListener(item -> {
@ -108,7 +109,6 @@ public class bfq extends AppCompatActivity {
binding.control.setOnClickListener(new bfq_an.control(binding.control)); binding.control.setOnClickListener(new bfq_an.control(binding.control));
if (bfqkz.mt != null && bfqkz.mt.isPlaying()) { if (bfqkz.mt != null && bfqkz.mt.isPlaying()) {
binding.kg.setImageResource(R.drawable.bf); binding.kg.setImageResource(R.drawable.bf);
} }
text(); text();
binding.like.setOnClickListener(view1 -> { binding.like.setOnClickListener(view1 -> {
@ -208,8 +208,7 @@ public class bfq extends AppCompatActivity {
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
} }
float downY, moveY; private float downY, moveY;
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
public void text() { public void text() {
binding.toolbar.setOnTouchListener((view, motionEvent) -> { binding.toolbar.setOnTouchListener((view, motionEvent) -> {
@ -262,4 +261,11 @@ public class bfq extends AppCompatActivity {
binding.like.setImageTintList(ContextCompat. binding.like.setImageTintList(ContextCompat.
getColorStateList(binding.getRoot().getContext(), color)); getColorStateList(binding.getRoot().getContext(), color));
} }
@Override
public void finish() {
super.finish();
view = null;
lrcview = null;
}
} }

View File

@ -32,7 +32,6 @@ public class bfqkz extends Service {
public static boolean like_bool; public static boolean like_bool;
@SuppressLint("StaticFieldLeak") @SuppressLint("StaticFieldLeak")
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);
if (s == 1) { if (s == 1) {
@ -51,12 +50,12 @@ public class bfqkz extends Service {
try { try {
if (TextUtils.isEmpty(id)) { if (TextUtils.isEmpty(id)) {
//针对错误进行相应的处理 //针对错误进行相应的处理
if (bfqkz.list.size() < 1) { /* if (bfqkz.list.size() < 1) {
return; return;
} }
bfqkz.list.remove(bfqkz.xm); bfqkz.list.remove(bfqkz.xm);
bfqkz.xm = bfqkz.list.get(bfqkz.getmti(bfqkz.ms)); bfqkz.xm = bfqkz.list.get(bfqkz.getmti(bfqkz.ms));
new mp3(id); new mp3(id);*/
return; return;
} }
if (TextUtils.isEmpty(xm.picurl)) { if (TextUtils.isEmpty(xm.picurl)) {

View File

@ -1,15 +1,5 @@
package com.muqingbfq.fragment; package com.muqingbfq.fragment;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Configuration;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.SeekBar; import android.widget.SeekBar;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import com.muqingbfq.R; import com.muqingbfq.R;
import com.muqingbfq.bfq; import com.muqingbfq.bfq;
import com.muqingbfq.bfq_an; import com.muqingbfq.bfq_an;
@ -17,38 +7,34 @@ import com.muqingbfq.bfqkz;
import com.muqingbfq.databinding.ActivityBfqBinding; import com.muqingbfq.databinding.ActivityBfqBinding;
import com.muqingbfq.main; import com.muqingbfq.main;
import com.muqingbfq.mq.gj; import com.muqingbfq.mq.gj;
import com.muqingbfq.view.CardImage;
import org.json.JSONObject; import org.json.JSONObject;
import me.wcy.lrcview.LrcView;
public class Media{ public class Media{
@SuppressLint("StaticFieldLeak")
private static TextView time_a, time_b;
@SuppressLint("StaticFieldLeak")
private static SeekBar tdt;
public static void setTime_a(String str) { public static void setTime_a(String str) {
if (time_a == null) { if (bfq.view == null) {
return; return;
} }
time_a.setText(str); bfq.binding.timeA.setText(str);
} }
public static void setTime_b(String str) { public static void setTime_b(String str) {
if (time_b == null) { if (bfq.view == null) {
return; return;
} }
time_b.setText(str); bfq.binding.timeB.setText(str);
} }
public static void setMax(int max) { public static void setMax(int max) {
tdt.setMax(max); if (bfq.view == null) {
return;
}
bfq.binding.tdt.setMax(max);
} }
public static void setProgress(int progress) { public static void setProgress(int progress) {
tdt.setProgress(progress); if (bfq.view == null) {
return;
}
bfq.binding.tdt.setProgress(progress);
bfq.lrcview.updateTime(progress); bfq.lrcview.updateTime(progress);
} }
@ -65,9 +51,7 @@ public class Media{
} }
public Media(ActivityBfqBinding binding) { public Media(ActivityBfqBinding binding) {
imageView = binding.cardview; binding.tdt.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
tdt = binding.tdt;
tdt.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override @Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
setTime_b(bfq_an.getTime(progress)); setTime_b(bfq_an.getTime(progress));
@ -84,15 +68,11 @@ public class Media{
bfqkz.mt.seekTo(seekBar.getProgress()); bfqkz.mt.seekTo(seekBar.getProgress());
} }
}); });
time_a = binding.timeA;
time_b = binding.timeB;
//初始化歌词组件
//初始化播放器列表 //初始化播放器列表
if (bfqkz.xm != null) { if (bfqkz.xm != null) {
// main.handler.removeCallbacks(bfqkz.mt.updateSeekBar); // 在播放开始时启动更新进度 // main.handler.removeCallbacks(bfqkz.mt.updateSeekBar); // 在播放开始时启动更新进度
long duration = bfqkz.mt.getDuration(); long duration = bfqkz.mt.getDuration();
tdt.setMax((int) bfqkz.mt.getDuration()); binding.tdt.setMax((int) bfqkz.mt.getDuration());
setTime_a(bfq_an.getTime(duration)); setTime_a(bfq_an.getTime(duration));
long position = bfqkz.mt.getCurrentPosition(); long position = bfqkz.mt.getCurrentPosition();
// main.handler.post(bfqkz.mt.updateSeekBar); // 在播放开始时启动更新进度 // main.handler.post(bfqkz.mt.updateSeekBar); // 在播放开始时启动更新进度
@ -119,13 +99,10 @@ public class Media{
} }
@SuppressLint("StaticFieldLeak")
public static CardImage imageView;
public static void setImageBitmap() { public static void setImageBitmap() {
if (imageView == null) { if (bfq.view == null) {
return; return;
} }
main.handler.post(() -> imageView.setImage(com.muqingbfq.bfq.bitmap)); main.handler.post(() -> bfq.binding.cardview.setImage(com.muqingbfq.bfq.bitmap));
} }
} }

View File

@ -131,7 +131,6 @@ public class home extends AppCompatActivity {
} }
private static Intent serviceIntent; private static Intent serviceIntent;
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
@ -144,7 +143,6 @@ public class home extends AppCompatActivity {
editor.apply(); editor.apply();
} }
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();