修复播放时的bfqkz.list为空null的闪退BUG
This commit is contained in:
parent
9b7de6544d
commit
4dbf60876c
|
@ -1,5 +1,6 @@
|
||||||
package com.muqingbfq;
|
package com.muqingbfq;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class MP3 {
|
public class MP3 {
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class MediaPlayer extends android.media.MediaPlayer {
|
||||||
public Runnable updateSeekBar = new Runnable() {
|
public Runnable updateSeekBar = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (isPlaying() && Media.lrcview != null) {
|
if (isPlaying() && bfq.lrcview != null) {
|
||||||
long position = getCurrentPosition();
|
long position = getCurrentPosition();
|
||||||
Media.setProgress((int) position);
|
Media.setProgress((int) position);
|
||||||
}
|
}
|
||||||
|
@ -41,37 +41,25 @@ public class MediaPlayer extends android.media.MediaPlayer {
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
@SuppressLint("UnsafeOptInUsageError")
|
||||||
public MediaPlayer() {
|
public MediaPlayer() {
|
||||||
setOnErrorListener(new OnErrorListener() {
|
setOnErrorListener((mediaPlayer, i, i1) -> {
|
||||||
@Override
|
if (bfqkz.list.isEmpty()) {
|
||||||
public boolean onError(android.media.MediaPlayer mediaPlayer, int i, int i1) {
|
|
||||||
//针对错误进行相应的处理
|
|
||||||
bfqkz.list.remove(bfqkz.xm);
|
|
||||||
bfqkz.xm = bfqkz.list.get(bfqkz.getmti(bfqkz.ms));
|
|
||||||
new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
super.run();
|
|
||||||
bfqkz.mp3(com.muqingbfq.api.
|
|
||||||
url.hq(bfqkz.xm));
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
//针对错误进行相应的处理
|
||||||
|
bfqkz.list.remove(bfqkz.xm);
|
||||||
|
bfqkz.xm = bfqkz.list.get(bfqkz.getmti(bfqkz.ms));
|
||||||
|
new bfqkz.mp3(com.muqingbfq.api.
|
||||||
|
url.hq(bfqkz.xm));
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
setOnCompletionListener(new OnCompletionListener() {
|
setOnCompletionListener(mediaPlayer -> {
|
||||||
@Override
|
if (bfqkz.list.isEmpty()) {
|
||||||
public void onCompletion(android.media.MediaPlayer mediaPlayer) {
|
return;
|
||||||
int i = bfqkz.getmti(bfqkz.ms);
|
|
||||||
bfqkz.xm = bfqkz.list.get(i);
|
|
||||||
new Thread() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
super.run();
|
|
||||||
bfqkz.mp3(com.muqingbfq.api.
|
|
||||||
url.hq(bfqkz.xm));
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
}
|
}
|
||||||
|
int i = bfqkz.getmti(bfqkz.ms);
|
||||||
|
bfqkz.xm = bfqkz.list.get(i);
|
||||||
|
new bfqkz.mp3(com.muqingbfq.api.
|
||||||
|
url.hq(bfqkz.xm));
|
||||||
});
|
});
|
||||||
setAudioAttributes(new AudioAttributes
|
setAudioAttributes(new AudioAttributes
|
||||||
.Builder()
|
.Builder()
|
||||||
|
@ -110,7 +98,7 @@ public class MediaPlayer extends android.media.MediaPlayer {
|
||||||
start();
|
start();
|
||||||
main.handler.post(() -> {
|
main.handler.post(() -> {
|
||||||
bfui();
|
bfui();
|
||||||
if (bfq.inflate != null) {
|
if (bfq.binding != null) {
|
||||||
main.handler.removeCallbacks(updateSeekBar); // 在播放开始时启动更新进度
|
main.handler.removeCallbacks(updateSeekBar); // 在播放开始时启动更新进度
|
||||||
long duration = getDuration();
|
long duration = getDuration();
|
||||||
Media.setMax((int) getDuration());
|
Media.setMax((int) getDuration());
|
||||||
|
@ -121,6 +109,7 @@ public class MediaPlayer extends android.media.MediaPlayer {
|
||||||
}
|
}
|
||||||
// 在这里将进度更新到UI上
|
// 在这里将进度更新到UI上
|
||||||
});
|
});
|
||||||
|
wj.setMP3ToFile(bfqkz.xm);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DataSource(String path) throws Exception {
|
public void DataSource(String path) throws Exception {
|
||||||
|
@ -167,7 +156,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.inflate != null) {
|
if (bfq.binding != null) {
|
||||||
Media.setProgress(0);
|
Media.setProgress(0);
|
||||||
bfq.setname(name);
|
bfq.setname(name);
|
||||||
bfq.setzz(zz);
|
bfq.setzz(zz);
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class url extends Thread {
|
||||||
|
|
||||||
public static String hq(MP3 x) {
|
public static String hq(MP3 x) {
|
||||||
getLrc(x.id);
|
getLrc(x.id);
|
||||||
if (Media.lrcview != null) {
|
if (bfq.lrcview != null) {
|
||||||
Media.loadLyric();
|
Media.loadLyric();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.graphics.Bitmap;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
@ -38,32 +39,56 @@ import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import me.wcy.lrcview.LrcView;
|
||||||
|
|
||||||
public class bfq extends AppCompatActivity {
|
public class bfq extends AppCompatActivity {
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
public static ActivityBfqBinding inflate;
|
public static ActivityBfqBinding binding;
|
||||||
public static String lrc;
|
public static String lrc;
|
||||||
|
|
||||||
|
public static LrcView lrcview;
|
||||||
|
private void setLrc(){
|
||||||
|
lrcview = binding.lrcView;
|
||||||
|
lrcview.setCurrentColor(ContextCompat.getColor(this,R.color.text));
|
||||||
|
lrcview.setLabel(getString(R.string.app_name));
|
||||||
|
lrcview.setCurrentTextSize(TypedValue.applyDimension(
|
||||||
|
TypedValue.COMPLEX_UNIT_SP, 16, getResources().getDisplayMetrics()));
|
||||||
|
// lrcView.setLrcPadding(16);
|
||||||
|
lrcview.setCurrentTextSize(TypedValue.applyDimension(
|
||||||
|
TypedValue.COMPLEX_UNIT_SP, 20, getResources().getDisplayMetrics()));
|
||||||
|
lrcview.setTimelineTextColor(ContextCompat.getColor(this,R.color.text_tm));
|
||||||
|
lrcview.setDraggable(true, (view, time) -> {
|
||||||
|
bfqkz.mt.seekTo(Math.toIntExact(time));
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
if (!gj.isTablet(this)) {
|
||||||
|
lrcview.setOnTapListener((view, x, y) -> {
|
||||||
|
View kp = binding.kp1;
|
||||||
|
if (kp.getVisibility() == View.VISIBLE) {
|
||||||
|
kp.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
kp.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
lrcview.setOnTapListener((view, x, y) -> {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
||||||
inflate = ActivityBfqBinding.inflate(getLayoutInflater());
|
binding = ActivityBfqBinding.inflate(getLayoutInflater());
|
||||||
new Media(inflate);
|
setLrc();
|
||||||
Media.lrcview.setCurrentColor(ContextCompat.getColor(this,R.color.text));
|
new Media(binding);
|
||||||
Media.lrcview.setLabel(getString(R.string.app_name));
|
LinearLayout root = binding.getRoot();
|
||||||
Media.lrcview.setCurrentTextSize(TypedValue.applyDimension(
|
|
||||||
TypedValue.COMPLEX_UNIT_SP, 16, getResources().getDisplayMetrics()));
|
|
||||||
// lrcView.setLrcPadding(16);
|
|
||||||
Media.lrcview.setCurrentTextSize(TypedValue.applyDimension(
|
|
||||||
TypedValue.COMPLEX_UNIT_SP, 20, getResources().getDisplayMetrics()));
|
|
||||||
Media.lrcview.setTimelineTextColor(ContextCompat.getColor(this,R.color.text_tm));
|
|
||||||
|
|
||||||
LinearLayout root = inflate.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);
|
root.setBackgroundColor(typedValue.data);
|
||||||
setContentView(root);
|
setContentView(root);
|
||||||
Toolbar toolbar = inflate.toolbar;
|
Toolbar toolbar = binding.toolbar;
|
||||||
toolbar.setNavigationOnClickListener(view1 -> finish());
|
toolbar.setNavigationOnClickListener(view1 -> finish());
|
||||||
toolbar.setOnMenuItemClickListener(item -> {
|
toolbar.setOnMenuItemClickListener(item -> {
|
||||||
if (item.getItemId() == R.id.fx && bfqkz.xm != null) {
|
if (item.getItemId() == R.id.fx && bfqkz.xm != null) {
|
||||||
|
@ -75,18 +100,18 @@ public class bfq extends AppCompatActivity {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
bfq_an.kz kz = new bfq_an.kz();
|
bfq_an.kz kz = new bfq_an.kz();
|
||||||
inflate.kg.setOnClickListener(kz);
|
binding.kg.setOnClickListener(kz);
|
||||||
inflate.xyq.setOnClickListener(kz);
|
binding.xyq.setOnClickListener(kz);
|
||||||
inflate.syq.setOnClickListener(kz);
|
binding.syq.setOnClickListener(kz);
|
||||||
inflate.bfqListMp3.
|
binding.bfqListMp3.
|
||||||
setOnClickListener(view1 -> com.muqingbfq.fragment.bflb_db.start(this));
|
setOnClickListener(view1 -> com.muqingbfq.fragment.bflb_db.start(this));
|
||||||
inflate.control.setOnClickListener(new bfq_an.control(inflate.control));
|
binding.control.setOnClickListener(new bfq_an.control(binding.control));
|
||||||
if (bfqkz.mt != null && bfqkz.mt.isPlaying()) {
|
if (bfqkz.mt != null && bfqkz.mt.isPlaying()) {
|
||||||
inflate.kg.setImageResource(R.drawable.bf);
|
binding.kg.setImageResource(R.drawable.bf);
|
||||||
|
|
||||||
}
|
}
|
||||||
text();
|
text();
|
||||||
inflate.like.setOnClickListener(view1 -> {
|
binding.like.setOnClickListener(view1 -> {
|
||||||
try {
|
try {
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
Type type = new TypeToken<List<MP3>>() {
|
Type type = new TypeToken<List<MP3>>() {
|
||||||
|
@ -97,12 +122,12 @@ public class bfq extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
if (bfqkz.like_bool) {
|
if (bfqkz.like_bool) {
|
||||||
list.remove(bfqkz.xm);
|
list.remove(bfqkz.xm);
|
||||||
inflate.like
|
binding.like
|
||||||
.setImageTintList(ContextCompat.getColorStateList(bfq.this, R.color.text));
|
.setImageTintList(ContextCompat.getColorStateList(bfq.this, R.color.text));
|
||||||
} else {
|
} else {
|
||||||
if (!list.contains(bfqkz.xm)) {
|
if (!list.contains(bfqkz.xm)) {
|
||||||
list.add(bfqkz.xm);
|
list.add(bfqkz.xm);
|
||||||
inflate.like.setImageTintList(ContextCompat.
|
binding.like.setImageTintList(ContextCompat.
|
||||||
getColorStateList(bfq.this, android.R.color.holo_red_dark));
|
getColorStateList(bfq.this, android.R.color.holo_red_dark));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +137,7 @@ public class bfq extends AppCompatActivity {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
inflate.download.setOnClickListener(view -> {
|
binding.download.setOnClickListener(view -> {
|
||||||
if (wj.cz(wj.mp3 + bfqkz.xm.id)) {
|
if (wj.cz(wj.mp3 + bfqkz.xm.id)) {
|
||||||
gj.ts(this, "你已经下载过这首歌曲了");
|
gj.ts(this, "你已经下载过这首歌曲了");
|
||||||
return;
|
return;
|
||||||
|
@ -149,17 +174,17 @@ public class bfq extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setname(String str) {
|
public static void setname(String str) {
|
||||||
if (inflate == null) {
|
if (binding == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
inflate.name.setText(str);
|
binding.name.setText(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setzz(String str) {
|
public static void setzz(String str) {
|
||||||
if (inflate == null) {
|
if (binding == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
inflate.zz.setText(str);
|
binding.zz.setText(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bitmap bitmap;
|
public static Bitmap bitmap;
|
||||||
|
@ -172,10 +197,10 @@ public class bfq extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void kgsetImageResource(int a) {
|
public static void kgsetImageResource(int a) {
|
||||||
if (inflate == null) {
|
if (binding == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
inflate.kg.setImageResource(a);
|
binding.kg.setImageResource(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -187,8 +212,8 @@ public class bfq extends AppCompatActivity {
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
public void text() {
|
public void text() {
|
||||||
inflate.toolbar.setOnTouchListener((view, motionEvent) -> {
|
binding.toolbar.setOnTouchListener((view, motionEvent) -> {
|
||||||
LinearLayout root = inflate.getRoot();
|
LinearLayout root = binding.getRoot();
|
||||||
switch (motionEvent.getAction()) {
|
switch (motionEvent.getAction()) {
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN:
|
||||||
downY = motionEvent.getRawY();
|
downY = motionEvent.getRawY();
|
||||||
|
@ -208,7 +233,7 @@ public class bfq extends AppCompatActivity {
|
||||||
root.setTranslationY(dy);
|
root.setTranslationY(dy);
|
||||||
break;
|
break;
|
||||||
case MotionEvent.ACTION_UP:
|
case MotionEvent.ACTION_UP:
|
||||||
if (inflate.getRoot().getY() > main.g - main.g / 1.5) {
|
if (binding.getRoot().getY() > main.g - main.g / 1.5) {
|
||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -227,14 +252,14 @@ public class bfq extends AppCompatActivity {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public static void setlike(boolean bool) {
|
public static void setlike(boolean bool) {
|
||||||
if (inflate == null) {
|
if (binding == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int color = R.color.text;
|
int color = R.color.text;
|
||||||
if (bool) {
|
if (bool) {
|
||||||
color = android.R.color.holo_red_dark;
|
color = android.R.color.holo_red_dark;
|
||||||
}
|
}
|
||||||
inflate.like.setImageTintList(ContextCompat.
|
binding.like.setImageTintList(ContextCompat.
|
||||||
getColorStateList(inflate.getRoot().getContext(), color));
|
getColorStateList(binding.getRoot().getContext(), color));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,6 +34,9 @@ public class bfq_an {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void syq() {
|
public static void syq() {
|
||||||
|
if (bfqkz.list.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
bfqkz.mt.pause();
|
bfqkz.mt.pause();
|
||||||
int i = bfqkz.list.indexOf(bfqkz.xm) - 1;
|
int i = bfqkz.list.indexOf(bfqkz.xm) - 1;
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
|
@ -44,7 +47,7 @@ public class bfq_an {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void xyq() {
|
public static void xyq() {
|
||||||
if (bfqkz.list == null) {
|
if (bfqkz.list.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bfqkz.mt.pause();
|
bfqkz.mt.pause();
|
||||||
|
|
|
@ -4,14 +4,12 @@ import android.annotation.SuppressLint;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Binder;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.support.v4.media.MediaMetadataCompat;
|
import android.support.v4.media.MediaMetadataCompat;
|
||||||
import android.support.v4.media.session.MediaSessionCompat;
|
import android.support.v4.media.session.MediaSessionCompat;
|
||||||
import android.support.v4.media.session.PlaybackStateCompat;
|
import android.support.v4.media.session.PlaybackStateCompat;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.KeyEvent;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -67,8 +65,8 @@ public class bfqkz extends Service {
|
||||||
if (bfqkz.lishi_list.size() >= 100) {
|
if (bfqkz.lishi_list.size() >= 100) {
|
||||||
bfqkz.lishi_list.remove(0);
|
bfqkz.lishi_list.remove(0);
|
||||||
}
|
}
|
||||||
if (bfqkz.lishi_list.size() > 0) {
|
bfqkz.lishi_list.remove(bfqkz.xm);
|
||||||
bfqkz.lishi_list.remove(bfqkz.xm);
|
if (!bfqkz.lishi_list.contains(bfqkz.xm)) {
|
||||||
bfqkz.lishi_list.add(0, bfqkz.xm);
|
bfqkz.lishi_list.add(0, bfqkz.xm);
|
||||||
wj.xrwb(wj.gd + "mp3_hc.json", new com.google.gson.Gson().toJson(bfqkz.lishi_list));
|
wj.xrwb(wj.gd + "mp3_hc.json", new com.google.gson.Gson().toJson(bfqkz.lishi_list));
|
||||||
}
|
}
|
||||||
|
@ -116,7 +114,7 @@ public class bfqkz extends Service {
|
||||||
class callback extends MediaSessionCompat.Callback {
|
class callback extends MediaSessionCompat.Callback {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMediaButtonEvent(Intent mediaButtonEvent) {
|
public boolean onMediaButtonEvent(Intent mediaButtonEvent) {
|
||||||
KeyEvent event = (KeyEvent) mediaButtonEvent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
|
mediaButtonEvent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +142,7 @@ public class bfqkz extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SwitchIntDef")
|
||||||
@Override
|
@Override
|
||||||
public void onPlayFromUri(Uri uri, Bundle extras) {
|
public void onPlayFromUri(Uri uri, Bundle extras) {
|
||||||
try {
|
try {
|
||||||
|
@ -174,12 +173,14 @@ public class bfqkz extends Service {
|
||||||
public IBinder onBind(Intent intent) {
|
public IBinder onBind(Intent intent) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
|
||||||
public class MyBinder extends Binder {
|
public class MyBinder extends Binder {
|
||||||
bfqkz getService() {
|
bfqkz getService() {
|
||||||
return bfqkz.this;
|
return bfqkz.this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public static void updateNotification() {
|
public static void updateNotification() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -28,7 +28,6 @@ public class Media{
|
||||||
private static TextView time_a, time_b;
|
private static TextView time_a, time_b;
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
private static SeekBar tdt;
|
private static SeekBar tdt;
|
||||||
public static LrcView lrcview;
|
|
||||||
|
|
||||||
public static void setTime_a(String str) {
|
public static void setTime_a(String str) {
|
||||||
if (time_a == null) {
|
if (time_a == null) {
|
||||||
|
@ -50,7 +49,7 @@ public class Media{
|
||||||
|
|
||||||
public static void setProgress(int progress) {
|
public static void setProgress(int progress) {
|
||||||
tdt.setProgress(progress);
|
tdt.setProgress(progress);
|
||||||
lrcview.updateTime(progress);
|
bfq.lrcview.updateTime(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setbf(boolean bool) {
|
public static void setbf(boolean bool) {
|
||||||
|
@ -67,20 +66,17 @@ public class Media{
|
||||||
|
|
||||||
public Media(ActivityBfqBinding binding) {
|
public Media(ActivityBfqBinding binding) {
|
||||||
imageView = binding.cardview;
|
imageView = binding.cardview;
|
||||||
lrcview = binding.lrcView;
|
|
||||||
tdt = binding.tdt;
|
tdt = binding.tdt;
|
||||||
tdt.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||||
// 拖动条移动中
|
// 拖动条移动中
|
||||||
main.handler.removeCallbacks(bfqkz.mt.updateSeekBar);
|
main.handler.removeCallbacks(bfqkz.mt.updateSeekBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
// 播放音乐到指定位置
|
// 播放音乐到指定位置
|
||||||
|
@ -91,20 +87,7 @@ public class Media{
|
||||||
time_a = binding.timeA;
|
time_a = binding.timeA;
|
||||||
time_b = binding.timeB;
|
time_b = binding.timeB;
|
||||||
//初始化歌词组件
|
//初始化歌词组件
|
||||||
lrcview.setDraggable(true, (view, time) -> {
|
|
||||||
bfqkz.mt.seekTo(Math.toIntExact(time));
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
if (!isTablet(binding.getRoot().getContext())) {
|
|
||||||
lrcview.setOnTapListener((view, x, y) -> {
|
|
||||||
View kp = binding.kp1;
|
|
||||||
if (kp.getVisibility() == View.VISIBLE) {
|
|
||||||
kp.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
kp.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
//初始化播放器列表
|
//初始化播放器列表
|
||||||
if (bfqkz.xm != null) {
|
if (bfqkz.xm != null) {
|
||||||
// main.handler.removeCallbacks(bfqkz.mt.updateSeekBar); // 在播放开始时启动更新进度
|
// main.handler.removeCallbacks(bfqkz.mt.updateSeekBar); // 在播放开始时启动更新进度
|
||||||
|
@ -118,14 +101,9 @@ public class Media{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isTablet(Context context) {
|
|
||||||
return (context.getResources().
|
|
||||||
getConfiguration().screenLayout &
|
|
||||||
Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadLyric() {
|
public static void loadLyric() {
|
||||||
if (lrcview == null || com.muqingbfq.bfq.lrc == null) {
|
if (bfq.lrcview == null || com.muqingbfq.bfq.lrc == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JSONObject jsonObject;
|
JSONObject jsonObject;
|
||||||
|
@ -137,7 +115,7 @@ public class Media{
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
gj.sc(e);
|
gj.sc(e);
|
||||||
}
|
}
|
||||||
lrcview.loadLrc(a, b);
|
bfq.lrcview.loadLrc(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,12 @@ import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.TypedValue;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.drawerlayout.widget.DrawerLayout;
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
@ -22,19 +19,14 @@ import androidx.viewpager2.adapter.FragmentStateAdapter;
|
||||||
import androidx.viewpager2.widget.ViewPager2;
|
import androidx.viewpager2.widget.ViewPager2;
|
||||||
|
|
||||||
import com.muqingbfq.databinding.ActivityHomeBinding;
|
import com.muqingbfq.databinding.ActivityHomeBinding;
|
||||||
import com.muqingbfq.fragment.Media;
|
|
||||||
import com.muqingbfq.fragment.bfq_db;
|
import com.muqingbfq.fragment.bfq_db;
|
||||||
import com.muqingbfq.fragment.gd;
|
|
||||||
import com.muqingbfq.fragment.gd_adapter;
|
import com.muqingbfq.fragment.gd_adapter;
|
||||||
import com.muqingbfq.fragment.wode;
|
import com.muqingbfq.fragment.wode;
|
||||||
import com.muqingbfq.mq.gj;
|
import com.muqingbfq.mq.gj;
|
||||||
import com.muqingbfq.mq.wj;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import me.wcy.lrcview.LrcView;
|
|
||||||
|
|
||||||
public class home extends AppCompatActivity {
|
public class home extends AppCompatActivity {
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
public static AppCompatActivity appCompatActivity;
|
public static AppCompatActivity appCompatActivity;
|
||||||
|
@ -150,7 +142,6 @@ public class home extends AppCompatActivity {
|
||||||
String jsonList = new com.google.gson.Gson().toJson(bfqkz.list);
|
String jsonList = new com.google.gson.Gson().toJson(bfqkz.list);
|
||||||
editor.putString("listData", jsonList);
|
editor.putString("listData", jsonList);
|
||||||
editor.apply();
|
editor.apply();
|
||||||
wj.setMP3ToFile(bfqkz.xm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -29,6 +30,18 @@ public class gj {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isTablet(Context context) {
|
||||||
|
boolean b;
|
||||||
|
DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
||||||
|
main.k = dm.widthPixels;
|
||||||
|
main.g = dm.heightPixels;
|
||||||
|
if (main.k > main.g) {
|
||||||
|
b = true;
|
||||||
|
} else {
|
||||||
|
b = false;
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
public static void sc(Object a) {
|
public static void sc(Object a) {
|
||||||
if (a == null) {
|
if (a == null) {
|
||||||
a = "null";
|
a = "null";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user