修复已知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;
import java.util.ArrayList;
import java.util.Objects;
public class MP3 {
public String id, name, zz;
// 音乐的贴图
// 音乐的贴图
public String picurl;
public MP3(String id, String name, String zz, String picurl) {
this.id = id;
this.name = name;

View File

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

View File

@ -44,8 +44,9 @@ import me.wcy.lrcview.LrcView;
public class bfq extends AppCompatActivity {
@SuppressLint("StaticFieldLeak")
public static ActivityBfqBinding binding;
@SuppressLint("StaticFieldLeak")
public static View view;
public static String lrc;
public static LrcView lrcview;
private void setLrc(){
lrcview = binding.lrcView;
@ -82,12 +83,12 @@ public class bfq extends AppCompatActivity {
binding = ActivityBfqBinding.inflate(getLayoutInflater());
setLrc();
new Media(binding);
LinearLayout root = binding.getRoot();
view = binding.getRoot();
TypedValue typedValue = new TypedValue();
home.appCompatActivity.getTheme().resolveAttribute(android.R.attr.windowBackground, typedValue, true);
// 设置背景颜色
root.setBackgroundColor(typedValue.data);
setContentView(root);
view.setBackgroundColor(typedValue.data);
setContentView(view);
Toolbar toolbar = binding.toolbar;
toolbar.setNavigationOnClickListener(view1 -> finish());
toolbar.setOnMenuItemClickListener(item -> {
@ -108,7 +109,6 @@ public class bfq extends AppCompatActivity {
binding.control.setOnClickListener(new bfq_an.control(binding.control));
if (bfqkz.mt != null && bfqkz.mt.isPlaying()) {
binding.kg.setImageResource(R.drawable.bf);
}
text();
binding.like.setOnClickListener(view1 -> {
@ -208,8 +208,7 @@ public class bfq extends AppCompatActivity {
super.onConfigurationChanged(newConfig);
}
float downY, moveY;
private float downY, moveY;
@SuppressLint("ClickableViewAccessibility")
public void text() {
binding.toolbar.setOnTouchListener((view, motionEvent) -> {
@ -262,4 +261,11 @@ public class bfq extends AppCompatActivity {
binding.like.setImageTintList(ContextCompat.
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;
@SuppressLint("StaticFieldLeak")
public static com.muqingbfq.mq.NotificationManagerCompat notify;
public static int getmti(int s) {
int i = bfqkz.list.indexOf(xm);
if (s == 1) {
@ -51,12 +50,12 @@ public class bfqkz extends Service {
try {
if (TextUtils.isEmpty(id)) {
//针对错误进行相应的处理
if (bfqkz.list.size() < 1) {
/* if (bfqkz.list.size() < 1) {
return;
}
bfqkz.list.remove(bfqkz.xm);
bfqkz.xm = bfqkz.list.get(bfqkz.getmti(bfqkz.ms));
new mp3(id);
new mp3(id);*/
return;
}
if (TextUtils.isEmpty(xm.picurl)) {

View File

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