更新了歌词组件支持更多操作
This commit is contained in:
parent
e223972408
commit
f78e19db08
|
@ -3,20 +3,7 @@
|
|||
<component name="deploymentTargetDropDown">
|
||||
<value>
|
||||
<entry key="app">
|
||||
<State>
|
||||
<runningDeviceTargetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="RUNNING_DEVICE_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="SERIAL_NUMBER" />
|
||||
<value value="MQS0219719035228" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</runningDeviceTargetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2024-01-31T03:55:11.386702400Z" />
|
||||
</State>
|
||||
<State />
|
||||
</entry>
|
||||
</value>
|
||||
</component>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/StatusBarUtil" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
<option value="$PROJECT_DIR$/lrcview" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveExternalAnnotations" value="false" />
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AndroidLintHardcodedText" enabled="true" level="WARNING" enabled_by_default="true" editorAttributes="WARNING_ATTRIBUTES" />
|
||||
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,android.content.res.Resources.Theme,obtainStyledAttributes" />
|
||||
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,android.content.res.Resources.Theme,obtainStyledAttributes,android.content.Context,obtainStyledAttributes,okhttp3.Call,execute" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="DataFlowIssue" enabled="false" level="WARNING" enabled_by_default="false">
|
||||
<option name="SUGGEST_NULLABLE_ANNOTATIONS" value="false" />
|
||||
|
@ -16,5 +16,6 @@
|
|||
<option name="processLiterals" value="true" />
|
||||
<option name="processComments" value="true" />
|
||||
</inspection_tool>
|
||||
<inspection_tool class="UnusedSymbol" enabled="true" level="INFORMATION" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
|
@ -1,4 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="NullableNotNullManager">
|
||||
<option name="myDefaultNullable" value="androidx.annotation.Nullable" />
|
||||
<option name="myDefaultNotNull" value="android.annotation.NonNull" />
|
||||
<option name="myNullables">
|
||||
<value>
|
||||
<list size="15">
|
||||
<item index="0" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
|
||||
<item index="1" class="java.lang.String" itemvalue="org.jspecify.nullness.Nullable" />
|
||||
<item index="2" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
|
||||
<item index="3" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
|
||||
<item index="4" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
|
||||
<item index="6" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.Nullable" />
|
||||
<item index="7" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||
<item index="8" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||
<item index="9" class="java.lang.String" itemvalue="jakarta.annotation.Nullable" />
|
||||
<item index="10" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||
<item index="11" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||
<item index="12" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
|
||||
<item index="13" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
|
||||
<item index="14" class="java.lang.String" itemvalue="android.annotation.Nullable" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
<option name="myNotNulls">
|
||||
<value>
|
||||
<list size="14">
|
||||
<item index="0" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
|
||||
<item index="1" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
|
||||
<item index="2" class="java.lang.String" itemvalue="jakarta.annotation.Nonnull" />
|
||||
<item index="3" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
|
||||
<item index="4" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
|
||||
<item index="5" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||
<item index="6" class="java.lang.String" itemvalue="org.jspecify.nullness.NonNull" />
|
||||
<item index="7" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
|
||||
<item index="8" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
|
||||
<item index="10" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||
<item index="11" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||
<item index="12" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.NonNull" />
|
||||
<item index="13" class="java.lang.String" itemvalue="android.annotation.NonNull" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK" />
|
||||
</project>
|
|
@ -5,7 +5,7 @@ android {
|
|||
compileSdk 34
|
||||
resourcePrefix "statusbarutil_"
|
||||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
minSdkVersion 23
|
||||
//noinspection ExpiredTargetSdkVersion
|
||||
targetSdk 31
|
||||
versionCode 1
|
||||
|
|
17
StatusBarUtil/proguard-rules.pro
vendored
17
StatusBarUtil/proguard-rules.pro
vendored
|
@ -1,17 +0,0 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Users/Jaeger/Develop/android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
|
@ -63,4 +63,5 @@ dependencies {
|
|||
|
||||
// 沉浸式状态栏
|
||||
api project(path: ':StatusBarUtil')
|
||||
api project(path: ':lrcview')
|
||||
}
|
|
@ -6,9 +6,11 @@
|
|||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<!-- 存储权限 -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><!--外部存储的写权限-->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><!--外部存储的读权限-->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
|
||||
<uses-permission
|
||||
android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
|
||||
tools:ignore="ScopedStorage" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" /> <!-- 网络权限 -->
|
||||
|
@ -24,6 +26,7 @@
|
|||
<!--悬浮窗权限-->
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
|
||||
|
||||
<application
|
||||
android:name=".main"
|
||||
android:allowBackup="true"
|
||||
|
@ -35,6 +38,8 @@
|
|||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.muqing"
|
||||
android:usesCleartextTraffic="true"
|
||||
android:preserveLegacyExternalStorage="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
tools:targetApi="s">
|
||||
<activity
|
||||
android:name=".home"
|
||||
|
@ -74,6 +79,7 @@
|
|||
</service>
|
||||
<service android:name=".mq.floating" />
|
||||
<service android:name=".mq.FloatingLyricsService" />
|
||||
|
||||
<receiver
|
||||
android:name=".MyButtonClickReceiver"
|
||||
android:enabled="true"
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
package com.muqingbfq;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
public class MP3 {
|
||||
public String id, name, zz;
|
||||
public class MP3 implements Serializable {
|
||||
public String id, name, zz, url;
|
||||
// 音乐的贴图
|
||||
public String picurl;
|
||||
public Object picurl;
|
||||
|
||||
public MP3(String id, String name, String zz, String picurl) {
|
||||
|
||||
public MP3(String id, String name, String zz, Object picurl) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.zz = zz;
|
||||
|
@ -19,6 +23,9 @@ public class MP3 {
|
|||
if (this == o) return true;
|
||||
if (!(o instanceof MP3)) return false;
|
||||
MP3 mp3 = (MP3) o;
|
||||
if (id.equals(mp3.id)) {
|
||||
return true;
|
||||
}
|
||||
return Objects.equals(id, mp3.id) &&
|
||||
Objects.equals(name, mp3.name) &&
|
||||
Objects.equals(zz, mp3.zz) &&
|
||||
|
@ -29,4 +36,15 @@ public class MP3 {
|
|||
public int hashCode() {
|
||||
return Objects.hash(id, name, zz, picurl);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MP3{" +
|
||||
"id='" + id + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", zz='" + zz + '\'' +
|
||||
", picurl=" + picurl +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -1,16 +1,11 @@
|
|||
package com.muqingbfq;
|
||||
|
||||
import static com.muqingbfq.bfqkz.xm;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.AudioManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.engine.GlideException;
|
||||
|
@ -18,29 +13,16 @@ import com.bumptech.glide.request.RequestListener;
|
|||
import com.bumptech.glide.request.target.Target;
|
||||
import com.mpatric.mp3agic.ID3v2;
|
||||
import com.mpatric.mp3agic.Mp3File;
|
||||
import com.muqingbfq.fragment.Media;
|
||||
import com.muqingbfq.fragment.bflb_db;
|
||||
import com.muqingbfq.fragment.bfq_db;
|
||||
import com.muqingbfq.fragment.mp3;
|
||||
import com.muqingbfq.fragment.search;
|
||||
import com.muqingbfq.mq.gj;
|
||||
import com.muqingbfq.mq.wj;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class MediaPlayer extends android.media.MediaPlayer {
|
||||
// 每秒更新一次进度
|
||||
public Runnable updateSeekBar = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isPlaying() && bfq.lrcView != null) {
|
||||
long position = getCurrentPosition();
|
||||
// gj.sc(position);
|
||||
Media.setProgress((int) position);
|
||||
}
|
||||
main.handler.postDelayed(this, 1000); // 每秒更新一次进度
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressLint("UnsafeOptInUsageError")
|
||||
public MediaPlayer() {
|
||||
|
@ -52,7 +34,7 @@ public class MediaPlayer extends android.media.MediaPlayer {
|
|||
bfqkz.list.remove(bfqkz.xm);
|
||||
bfqkz.xm = bfqkz.list.get(bfqkz.getmti());
|
||||
new bfqkz.mp3(com.muqingbfq.api.
|
||||
url.hq(bfqkz.xm));
|
||||
url.hq(bfqkz.xm));
|
||||
return false;
|
||||
});
|
||||
setOnCompletionListener(mediaPlayer -> {
|
||||
|
@ -72,7 +54,7 @@ public class MediaPlayer extends android.media.MediaPlayer {
|
|||
public void pause() throws IllegalStateException {
|
||||
if (isPlaying()) {
|
||||
super.pause();
|
||||
Media.setbf(false);
|
||||
// bfq.isPlaying = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,28 +67,21 @@ public class MediaPlayer extends android.media.MediaPlayer {
|
|||
return;
|
||||
}
|
||||
super.start();
|
||||
Media.setbf(true);
|
||||
// bfq.isPlaying = true;
|
||||
}
|
||||
@Override
|
||||
public void setDataSource(String path) throws IOException {
|
||||
|
||||
|
||||
public void setDataSource(MP3 mp3) throws IOException {
|
||||
reset();
|
||||
super.setDataSource(path);
|
||||
super.setDataSource(mp3.url);
|
||||
prepare();
|
||||
start();
|
||||
bfqkz.xm = mp3;
|
||||
main.handler.post(() -> {
|
||||
bfui();
|
||||
if (bfq.view != null) {
|
||||
main.handler.removeCallbacks(updateSeekBar); // 在播放开始时启动更新进度
|
||||
long duration = getDuration();
|
||||
Media.setMax(getDuration());
|
||||
Media.setTime_a(bfq_an.getTime(duration));
|
||||
long position = getCurrentPosition();
|
||||
Media.setProgress((int) position);
|
||||
main.handler.post(updateSeekBar); // 在播放开始时启动更新进度
|
||||
}
|
||||
// 在这里将进度更新到UI上
|
||||
bfqkz.notify.tzl();
|
||||
});
|
||||
new Thread(){
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
|
@ -123,12 +98,13 @@ public class MediaPlayer extends android.media.MediaPlayer {
|
|||
}.start();
|
||||
}
|
||||
|
||||
public void DataSource(String path) throws Exception {
|
||||
public void DataSource(MP3 path) throws Exception {
|
||||
reset();
|
||||
super.setDataSource(path);
|
||||
super.setDataSource(path.url);
|
||||
prepare();
|
||||
setTX();
|
||||
}
|
||||
|
||||
public void setTX() {
|
||||
Glide.with(main.application)
|
||||
.asBitmap()
|
||||
|
@ -138,13 +114,13 @@ public class MediaPlayer extends android.media.MediaPlayer {
|
|||
public boolean onLoadFailed(@Nullable GlideException e, Object model,
|
||||
@NonNull Target<Bitmap> target,
|
||||
boolean isFirstResource) {
|
||||
bfq.bitmap = null;
|
||||
Bitmap bitmap = null;
|
||||
try {
|
||||
Mp3File mp3file = new Mp3File(wj.mp3 + bfqkz.xm.id);
|
||||
if (mp3file.hasId3v2Tag()) {
|
||||
ID3v2 id3v2Tag = mp3file.getId3v2Tag();
|
||||
byte[] albumImage = id3v2Tag.getAlbumImage();
|
||||
bfq.bitmap=
|
||||
bitmap =
|
||||
BitmapFactory.decodeByteArray(albumImage, 0, albumImage.length);
|
||||
|
||||
}
|
||||
|
@ -152,9 +128,8 @@ public class MediaPlayer extends android.media.MediaPlayer {
|
|||
gj.sc(getClass() + " yc:" + a);
|
||||
}
|
||||
if (bfqkz.notify != null) {
|
||||
bfqkz.notify.tzl();
|
||||
bfqkz.notify.setbitmap(bitmap);
|
||||
}
|
||||
Media.setImageBitmap();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -162,35 +137,28 @@ public class MediaPlayer extends android.media.MediaPlayer {
|
|||
public boolean onResourceReady(@NonNull Bitmap bitmap, @NonNull Object model, Target<Bitmap> target,
|
||||
@NonNull DataSource dataSource,
|
||||
boolean isFirstResource) {
|
||||
bfq.bitmap = bitmap;
|
||||
if (bfqkz.notify != null) {
|
||||
bfqkz.notify.tzl();
|
||||
bfqkz.notify.setbitmap(bitmap);
|
||||
}
|
||||
Media.setImageBitmap();
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.submit();
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void bfui() {
|
||||
String name = xm.name, zz = bfqkz.xm.zz;
|
||||
setTX();
|
||||
bfq_db.setname(name + "/" + zz);
|
||||
if (bflb_db.adapter != null) {
|
||||
bflb_db.adapter.notifyDataSetChanged();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.submit();
|
||||
}
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void bfui() {
|
||||
String name = xm.name, zz = bfqkz.xm.zz;
|
||||
setTX();
|
||||
if (bfq.view != null) {
|
||||
Media.setProgress(0);
|
||||
bfq.setname(name);
|
||||
bfq.setzz(zz);
|
||||
bfq_an.islike();
|
||||
}
|
||||
bfq_db.setname(name + "/" + zz);
|
||||
if (com.muqingbfq.fragment.mp3.lbspq != null) {
|
||||
new mp3.lbspq_sx();
|
||||
}
|
||||
if (search.lbspq != null) {
|
||||
search.lbspq.notifyDataSetChanged();
|
||||
search.lbspq.notifyDataSetChanged();
|
||||
}
|
||||
if (mp3.adapter != null) {
|
||||
mp3.adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,12 +8,9 @@ import android.net.Uri;
|
|||
import android.provider.Settings;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.muqingbfq.mq.FloatingLyricsService;
|
||||
import com.muqingbfq.mq.gj;
|
||||
import com.muqingbfq.mq.wj;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
@ -118,14 +115,13 @@ public class MyButtonClickReceiver extends BroadcastReceiver {
|
|||
}
|
||||
if (bfqkz.like_bool) {
|
||||
list.remove(bfqkz.xm);
|
||||
bfq.setlike(false);
|
||||
bfqkz.like_bool = false;
|
||||
} else {
|
||||
if (!list.contains(bfqkz.xm)) {
|
||||
list.add(bfqkz.xm);
|
||||
bfq.setlike(true);
|
||||
bfqkz.like_bool = true;
|
||||
}
|
||||
}
|
||||
bfqkz.like_bool = !bfqkz.like_bool;
|
||||
wj.xrwb(wj.gd + "mp3_like.json", gson.toJson(list));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -292,6 +292,10 @@ public class activity_search extends FragmentActivity {
|
|||
}
|
||||
|
||||
private void end() {
|
||||
if (binding.searchRecycler.getVisibility() == View.VISIBLE) {
|
||||
binding.searchRecycler.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
search search = (com.muqingbfq.fragment.search) getSupportFragmentManager().
|
||||
findFragmentById(R.id.search_fragment);
|
||||
if (search.isVisible()) {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package com.muqingbfq.api;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -13,7 +13,6 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|||
import com.mpatric.mp3agic.ID3v2;
|
||||
import com.mpatric.mp3agic.Mp3File;
|
||||
import com.muqingbfq.MP3;
|
||||
import com.muqingbfq.bfq;
|
||||
import com.muqingbfq.main;
|
||||
import com.muqingbfq.mq.gj;
|
||||
import com.muqingbfq.mq.wj;
|
||||
|
@ -27,7 +26,6 @@ import java.io.File;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
|
@ -102,6 +100,7 @@ public class FileDownloader {
|
|||
// 下载失败处理
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
|
||||
if (!response.isSuccessful()) {
|
||||
|
@ -145,11 +144,17 @@ public class FileDownloader {
|
|||
id3v2Tag.setAlbum(x.zz);
|
||||
id3v2Tag.setLyrics(com.muqingbfq.api.url.Lrc(x.id));
|
||||
ByteArrayOutputStream o = new ByteArrayOutputStream();
|
||||
Request build = new Request.Builder().url(x.picurl)
|
||||
.build();
|
||||
Response execute = client.newCall(build).execute();
|
||||
if (execute.isSuccessful()) {
|
||||
id3v2Tag.setAlbumImage(execute.body().bytes(), "image/jpeg");
|
||||
if (x.picurl instanceof String) {
|
||||
Request build = new Request.Builder().url(x.picurl.toString())
|
||||
.build();
|
||||
Response execute = client.newCall(build).execute();
|
||||
if (execute.isSuccessful()) {
|
||||
id3v2Tag.setAlbumImage(execute.body().bytes()
|
||||
, "image/jpeg");
|
||||
}
|
||||
} else if (x.picurl instanceof Bitmap) {
|
||||
id3v2Tag.setAlbumImage(((Bitmap) x.picurl).getNinePatchChunk()
|
||||
, "image/jpeg");
|
||||
}
|
||||
o.close();
|
||||
mp3file.save(file_url + x.id);
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package com.muqingbfq.api;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Environment;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.mpatric.mp3agic.ID3v2;
|
||||
import com.mpatric.mp3agic.Mp3File;
|
||||
import com.muqingbfq.MP3;
|
||||
import com.muqingbfq.fragment.gd;
|
||||
import com.muqingbfq.mq.gj;
|
||||
import com.muqingbfq.mq.wj;
|
||||
import com.muqingbfq.mq.wl;
|
||||
|
@ -17,7 +19,6 @@ import org.json.JSONObject;
|
|||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class playlist extends Thread {
|
||||
|
@ -31,7 +32,7 @@ public class playlist extends Thread {
|
|||
return wl.hq(api + uid + "&limit=100");
|
||||
}
|
||||
}
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
|
||||
public static boolean hq(List<MP3> list, String uid) {
|
||||
switch (uid) {
|
||||
case "mp3_xz.json":
|
||||
|
@ -106,20 +107,17 @@ public class playlist extends Thread {
|
|||
try {
|
||||
File file = new File(wj.filesdri + "mp3");
|
||||
File[] files = file.listFiles();
|
||||
int i = 0;
|
||||
for (File value : files) {
|
||||
ID3v2 mp3File = new Mp3File(value).getId3v2Tag();
|
||||
String id = value.getName();
|
||||
String name = mp3File.getTitle();
|
||||
String zz = mp3File.getArtist();
|
||||
String picUrl = mp3File.getUrl();
|
||||
list.add(new MP3(id, name, zz.toString(), picUrl));
|
||||
i++;
|
||||
list.add(new MP3(id, name, zz, picUrl));
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
gj.sc("失败的错误 " + e);
|
||||
wj.sc(wj.mp3_xz);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -138,8 +136,54 @@ public class playlist extends Thread {
|
|||
return true;
|
||||
} catch (Exception e) {
|
||||
gj.sc("失败的错误 " + e);
|
||||
wj.sc(wj.mp3_xz);
|
||||
wj.sc(wj.gd + "mp3_hc.json");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static void hq_cd(Context context, List<MP3> list) {
|
||||
boolean cd = wj.isCD(context);
|
||||
if (!cd) {
|
||||
return;
|
||||
}
|
||||
list.clear();
|
||||
try {
|
||||
String absolutePath = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
CD(new File(absolutePath), list);
|
||||
} catch (Exception e) {
|
||||
gj.sc("失败的错误 " + e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void CD(File file, List<MP3> list) {
|
||||
for (File a : file.listFiles()) {
|
||||
if (a.isFile()) {
|
||||
try {
|
||||
// 创建一个 Mp3File 对象,用于读取 MP3 文件
|
||||
Mp3File mp3file = new Mp3File(a);
|
||||
// 检查是否存在 ID3v2 标签
|
||||
if (mp3file.hasId3v2Tag()) {
|
||||
// 获取 ID3v2 标签实例
|
||||
ID3v2 id3v2tag = mp3file.getId3v2Tag();
|
||||
byte[] albumImage = id3v2tag.getAlbumImage();
|
||||
Bitmap bitmap = BitmapFactory.decodeByteArray(albumImage,
|
||||
0, albumImage.length);
|
||||
MP3 mp3 = new MP3(a.toString(), id3v2tag.getTitle(),
|
||||
id3v2tag.getArtist()
|
||||
, bitmap);
|
||||
list.add(mp3);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (a.isDirectory()) {
|
||||
/* String string = a.getName();
|
||||
if (string.startsWith(".") || string.equals("Android") || string.equals("data")) {
|
||||
continue;
|
||||
}
|
||||
CD(a, list);*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,15 +28,18 @@ public class url extends Thread {
|
|||
start();
|
||||
}
|
||||
|
||||
public static String hq(MP3 x) {
|
||||
public static MP3 hq(MP3 x) {
|
||||
// gj.sc(x.id);
|
||||
getLrc(x.id);
|
||||
Media.loadLyric();
|
||||
try {
|
||||
if (wj.cz(wj.mp3 + x.id)) {
|
||||
return wj.mp3 + x.id;
|
||||
}
|
||||
if (wj.cz(wj.filesdri + "hc/" + x.id)) {
|
||||
return wj.filesdri + "hc/" + x.id;
|
||||
if (wj.cz(x.id)) {
|
||||
return x;
|
||||
} else if (wj.cz(wj.mp3 + x.id)) {
|
||||
x.url = wj.mp3 + x.id;
|
||||
return x;
|
||||
} else if (wj.cz(wj.filesdri + "hc/" + x.id)) {
|
||||
x.url = wj.filesdri + "hc/" + x.id;
|
||||
return x;
|
||||
}
|
||||
String level = "standard";
|
||||
boolean wiFiConnected = gj.isWiFiConnected();
|
||||
|
@ -61,8 +64,9 @@ public class url extends Thread {
|
|||
}
|
||||
JSONArray data = json.getJSONArray("data");
|
||||
JSONObject jsonObject = data.getJSONObject(0);
|
||||
gj.sc(jsonObject.getString("url"));
|
||||
return jsonObject.getString("url");
|
||||
// gj.sc(jsonObject.getString("url"));
|
||||
x.url = jsonObject.getString("url");
|
||||
return x;
|
||||
} catch (JSONException e) {
|
||||
yc.start("url hq :" + e);
|
||||
}
|
||||
|
@ -78,21 +82,25 @@ public class url extends Thread {
|
|||
|
||||
public static void getLrc(String id) {
|
||||
String file = wj.mp3 + id;
|
||||
if (wj.cz(file)) {
|
||||
boolean cz = wj.cz(id);
|
||||
if (cz) {
|
||||
file = id;
|
||||
}
|
||||
if (cz || wj.cz(file)) {
|
||||
try {
|
||||
Mp3File mp3file = new Mp3File(file);
|
||||
if (mp3file.hasId3v2Tag()) {
|
||||
ID3v2 id3v2Tag = mp3file.getId3v2Tag();
|
||||
bfq.lrc = id3v2Tag.getLyrics();
|
||||
com.muqingbfq.bfqkz.lrc = id3v2Tag.getLyrics();
|
||||
}
|
||||
if (bfq.lrc == null) {
|
||||
bfq.lrc = wl.hq("/lyric?id=" + id);
|
||||
if (com.muqingbfq.bfqkz.lrc == null) {
|
||||
com.muqingbfq.bfqkz.lrc = wl.hq("/lyric?id=" + id);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
gj.sc(e);
|
||||
}
|
||||
} else {
|
||||
bfq.lrc = wl.hq("/lyric?id=" + id);
|
||||
com.muqingbfq.bfqkz.lrc = wl.hq("/lyric?id=" + id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,14 +7,11 @@ import android.annotation.SuppressLint;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
@ -22,37 +19,31 @@ import androidx.annotation.Nullable;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.google.android.material.slider.Slider;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.muqingbfq.api.FileDownloader;
|
||||
import com.muqingbfq.api.url;
|
||||
import com.muqingbfq.databinding.ActivityBfqBinding;
|
||||
import com.muqingbfq.fragment.Media;
|
||||
import com.muqingbfq.login.user_logs;
|
||||
import com.muqingbfq.fragment.bfq_db;
|
||||
import com.muqingbfq.mq.gj;
|
||||
import com.muqingbfq.mq.wj;
|
||||
import com.muqingbfq.mq.wl;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
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 com.muqingbfq.view.LrcView lrcView;
|
||||
public ActivityBfqBinding binding;
|
||||
public String lrc;
|
||||
public MP3 mp3;
|
||||
public boolean isplay = true;
|
||||
|
||||
private void setLrc() {
|
||||
lrcView = binding.lrcView;
|
||||
ViewGroup.LayoutParams layoutParams = binding.cardview.getLayoutParams();
|
||||
|
||||
DisplayMetrics dm = getResources().getDisplayMetrics();
|
||||
main.k = dm.widthPixels;
|
||||
main.g = dm.heightPixels;
|
||||
|
@ -61,34 +52,73 @@ public class bfq extends AppCompatActivity {
|
|||
binding.cardview.setLayoutParams(layoutParams);
|
||||
// bfqkz.mt.seekTo(Math.toIntExact(time));
|
||||
if (!gj.isTablet(this)) {
|
||||
lrcView.setOnClickListener((view) -> {
|
||||
binding.lrcView.setOnClickListener((view) -> {
|
||||
View kp = binding.kp1;
|
||||
if (kp.getVisibility() == View.VISIBLE) {
|
||||
kp.setVisibility(View.GONE);
|
||||
} else {
|
||||
kp.setVisibility(View.VISIBLE);
|
||||
}
|
||||
lrcView.setLrcline(kp.getVisibility() == View.VISIBLE);
|
||||
// binding.lrcView.setLrcline(kp.getVisibility() == View.VISIBLE);
|
||||
});
|
||||
binding.lrcView.setOnTapListener((view, x, y) -> {
|
||||
View kp = binding.kp1;
|
||||
if (kp.getVisibility() == View.VISIBLE) {
|
||||
kp.setVisibility(View.GONE);
|
||||
binding.lrcView.
|
||||
setDraggable(true, (a, time) -> {
|
||||
bfqkz.mt.seekTo((int) time);
|
||||
return false;
|
||||
});
|
||||
} else {
|
||||
kp.setVisibility(View.VISIBLE);
|
||||
binding.lrcView.
|
||||
setDraggable(false,null);
|
||||
}
|
||||
});
|
||||
binding.lrcView.
|
||||
setDraggable(false, null);
|
||||
} else {
|
||||
lrcView.setOnClickListener(null);
|
||||
binding.lrcView.setOnClickListener(null);
|
||||
binding.lrcView.
|
||||
setDraggable(false, null);
|
||||
}
|
||||
|
||||
|
||||
binding.tdt.addOnChangeListener((slider, value, fromUser) ->
|
||||
setTime_b(bfq_an.getTime((long) value)));
|
||||
binding.tdt.addOnSliderTouchListener(new Slider.OnSliderTouchListener() {
|
||||
@Override
|
||||
public void onStartTrackingTouch(@NonNull Slider slider) {
|
||||
// 拖动条移动中
|
||||
isplay = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(@NonNull Slider slider) {
|
||||
// 播放音乐到指定位置
|
||||
isplay = true;
|
||||
bfqkz.mt.seekTo((int) slider.getValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void startactivity(Context context, MP3 mp3) {
|
||||
gj.sc(mp3.toString());
|
||||
Intent intent = new Intent(context, bfq.class);
|
||||
intent.putExtra("MP3", mp3);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
||||
super.onCreate(savedInstanceState);/*getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);*/
|
||||
binding = ActivityBfqBinding.inflate(getLayoutInflater());
|
||||
view = binding.getRoot();
|
||||
Intent intent = getIntent();
|
||||
setLrc();
|
||||
new Media(binding);
|
||||
TypedValue typedValue = new TypedValue();
|
||||
home.appCompatActivity.getTheme().resolveAttribute(android.R.attr.windowBackground, typedValue, true);
|
||||
// 设置背景颜色
|
||||
view.setBackgroundColor(typedValue.data);
|
||||
setContentView(view);
|
||||
setContentView(binding.getRoot());
|
||||
binding.toolbar.setNavigationOnClickListener(view1 -> finish());
|
||||
binding.toolbar.setOnMenuItemClickListener(item -> {
|
||||
if (item.getItemId() == R.id.fx && bfqkz.xm != null) {
|
||||
|
@ -99,18 +129,21 @@ public class bfq extends AppCompatActivity {
|
|||
}
|
||||
return false;
|
||||
});
|
||||
bfq_an.kz kz = new bfq_an.kz();
|
||||
binding.kg.setOnClickListener(kz);
|
||||
binding.xyq.setOnClickListener(kz);
|
||||
binding.syq.setOnClickListener(kz);
|
||||
binding.kg.setOnClickListener(v -> {
|
||||
if (bfqkz.mt.isPlaying()) {
|
||||
bfqkz.mt.pause();
|
||||
} else {
|
||||
bfqkz.mt.start();
|
||||
}
|
||||
});
|
||||
binding.xyq.setOnClickListener(v -> bfq_an.xyq());
|
||||
binding.syq.setOnClickListener(v -> bfq_an.syq());
|
||||
binding.bfqListMp3.
|
||||
setOnClickListener(view1 -> com.muqingbfq.fragment.bflb_db.start(this));
|
||||
binding.control.setOnClickListener(new bfq_an.control(binding.control));
|
||||
if (bfqkz.mt != null && bfqkz.mt.isPlaying()) {
|
||||
binding.kg.setImageResource(R.drawable.bf);
|
||||
}
|
||||
|
||||
binding.toolbar.setOnTouchListener(new Touch());
|
||||
view.setOnTouchListener(new Touch());
|
||||
binding.getRoot().setOnTouchListener(new Touch());
|
||||
|
||||
binding.like.setOnClickListener(view1 -> {
|
||||
try {
|
||||
|
@ -142,71 +175,60 @@ public class bfq extends AppCompatActivity {
|
|||
return;
|
||||
}
|
||||
if (bfqkz.xm != null) {
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
MP3 x = bfqkz.xm;
|
||||
String hq = wl.hq(url.api + "?id=" + x.id + "&level=exhigh" + "&cookie=" + wl.Cookie);
|
||||
if (hq == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
JSONObject json = new JSONObject(hq);
|
||||
JSONArray data = json.getJSONArray("data");
|
||||
if (json.getInt("code") == -460) {
|
||||
String message = json.getString("message");
|
||||
main.handler.post(() -> {
|
||||
gj.ts(home.appCompatActivity, message);
|
||||
home.appCompatActivity.startActivity(new Intent(home.appCompatActivity
|
||||
, user_logs.class));
|
||||
|
||||
});
|
||||
return;
|
||||
}
|
||||
JSONObject jsonObject = data.getJSONObject(0);
|
||||
String url = jsonObject.getString("url");
|
||||
new FileDownloader(bfq.this).downloadFile(url, bfqkz.xm);
|
||||
} catch (JSONException e) {
|
||||
gj.sc(e);
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
new FileDownloader(bfq.this).downloadFile(bfqkz.xm);
|
||||
}
|
||||
});
|
||||
if (bfqkz.xm != null) {
|
||||
setname(bfqkz.xm.name);
|
||||
setzz(bfqkz.xm.zz);
|
||||
bfq_an.islike();
|
||||
Media.setImageBitmap();
|
||||
// bfqkz.mt.setTX();
|
||||
}
|
||||
mp3 = (MP3) intent.getSerializableExtra("MP3");
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
if (mp3 != null) {
|
||||
if (bfqkz.xm == null || !bfqkz.xm.equals(mp3)) {
|
||||
bfqkz.xm = mp3;
|
||||
bfqkz.mp3(com.muqingbfq.api.url.hq(mp3));
|
||||
}
|
||||
}
|
||||
main.handler.post(() -> {
|
||||
if (mp3 != null) {
|
||||
UI();
|
||||
}
|
||||
if (bfqkz.mt != null && bfqkz.mt.isPlaying()) {
|
||||
binding.kg.setImageResource(R.drawable.bf);
|
||||
}
|
||||
});
|
||||
main.handler.post(runnable);
|
||||
}
|
||||
}.start();
|
||||
// UI();
|
||||
}
|
||||
|
||||
public static void setname(String str) {
|
||||
if (binding == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
public void UI() {
|
||||
setname(mp3.name);
|
||||
setzz(mp3.zz);
|
||||
bfq_an.islike();
|
||||
int duration = bfqkz.mt.getDuration();
|
||||
setMax(duration);
|
||||
gj.sc(duration);
|
||||
setTime_a(bfq_an.getTime(duration));
|
||||
int position = bfqkz.mt.getCurrentPosition();
|
||||
Progress(position);
|
||||
setImageBitmap();
|
||||
}
|
||||
|
||||
public void setname(String str) {
|
||||
binding.name.setText(str);
|
||||
}
|
||||
|
||||
public static void setzz(String str) {
|
||||
public void setzz(String str) {
|
||||
if (binding == null) {
|
||||
return;
|
||||
}
|
||||
binding.zz.setText(str);
|
||||
}
|
||||
|
||||
public static Bitmap bitmap;
|
||||
|
||||
public static void start(Context context) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(context, bfq.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void kgsetImageResource(int a) {
|
||||
public void kgsetImageResource(int a) {
|
||||
if (binding == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -264,23 +286,103 @@ public class bfq extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
public static void setlike(boolean bool) {
|
||||
if (binding == null) {
|
||||
return;
|
||||
}
|
||||
public void setlike(boolean bool) {
|
||||
int color = R.color.text;
|
||||
if (bool) {
|
||||
color = android.R.color.holo_red_dark;
|
||||
}
|
||||
binding.like.setImageTintList(ContextCompat.
|
||||
getColorStateList(binding.getRoot().getContext(), color));
|
||||
islike = bool;
|
||||
}
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isplay) {
|
||||
int position = bfqkz.mt.getCurrentPosition();
|
||||
Progress(position);
|
||||
}
|
||||
if (!mp3.equals(bfqkz.xm)) {
|
||||
mp3 = bfqkz.xm;
|
||||
setname(mp3.name);
|
||||
setzz(mp3.zz);
|
||||
bfq_an.islike();
|
||||
int duration = bfqkz.mt.getDuration();
|
||||
setMax(duration);
|
||||
gj.sc(duration);
|
||||
setTime_a(bfq_an.getTime(duration));
|
||||
int position = bfqkz.mt.getCurrentPosition();
|
||||
Progress(position);
|
||||
setImageBitmap();
|
||||
}
|
||||
if (bfqkz.mt.isPlaying() != isPlaying) {
|
||||
setbf(bfqkz.mt.isPlaying());
|
||||
}
|
||||
if (bfqkz.like_bool != islike) {
|
||||
setlike(bfqkz.like_bool);
|
||||
}
|
||||
if (!Objects.equals(bfqkz.lrc, lrc)) {
|
||||
lrc = bfqkz.lrc;
|
||||
String[] strings = Media.loadLyric();
|
||||
binding.lrcView.loadLrc(strings[0], strings[1]);
|
||||
}
|
||||
main.handler.postDelayed(this, 1000); // 每秒更新一次进度
|
||||
}
|
||||
};
|
||||
|
||||
public boolean islike = false;
|
||||
public boolean isPlaying = false;
|
||||
|
||||
public void setbf(boolean bool) {
|
||||
if (bool) {
|
||||
//开始
|
||||
kgsetImageResource(R.drawable.bf);
|
||||
} else {
|
||||
//暂停
|
||||
kgsetImageResource(R.drawable.zt);
|
||||
}
|
||||
bfq_db.setkg(bool);
|
||||
if (bfqkz.notify != null) {
|
||||
bfqkz.notify.tzl_button();
|
||||
}
|
||||
isPlaying = bool;
|
||||
}
|
||||
|
||||
public void setImageBitmap() {
|
||||
binding.cardview.setImage(bfqkz.xm.picurl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
view = null;
|
||||
lrcView = null;
|
||||
main.handler.removeCallbacks(bfqkz.mt.updateSeekBar); // 在播放开始时启动更新进度
|
||||
binding = null;
|
||||
main.handler.removeCallbacks(runnable); // 在播放开始时启动更新进度
|
||||
}
|
||||
|
||||
|
||||
public void setTime_a(String str) {
|
||||
binding.timeA.setText(str);
|
||||
}
|
||||
|
||||
public void setTime_b(String str) {
|
||||
binding.timeB.setText(str);
|
||||
}
|
||||
|
||||
public void setMax(int max) {
|
||||
if (max > 0) {
|
||||
binding.tdt.setValueTo(max);
|
||||
}
|
||||
}
|
||||
|
||||
public void Progress(int progress) {
|
||||
// gj.sc(progress);
|
||||
if (binding.tdt.getValueTo() < progress) {
|
||||
return;
|
||||
// 处理超出范围的情况
|
||||
}
|
||||
binding.tdt.setValue(progress);
|
||||
binding.lrcView.updateTime(progress);
|
||||
}
|
||||
|
||||
}
|
|
@ -49,8 +49,7 @@ public class bfq_an {
|
|||
return;
|
||||
}
|
||||
bfqkz.mt.pause();
|
||||
bfqkz.xm = bfqkz.list.get(bfqkz.getmti());
|
||||
new url(bfqkz.xm);
|
||||
new url(bfqkz.list.get(bfqkz.getmti()));
|
||||
}
|
||||
|
||||
public static class control implements View.OnClickListener {
|
||||
|
@ -118,7 +117,7 @@ public class bfq_an {
|
|||
return simpleDateFormat.format(new Date(time));
|
||||
}
|
||||
|
||||
public static void islike() {
|
||||
public static boolean islike() {
|
||||
boolean contains = false;
|
||||
String dqwb = wj.dqwb(wj.gd + "mp3_like.json");
|
||||
if (dqwb != null) {
|
||||
|
@ -133,8 +132,7 @@ public class bfq_an {
|
|||
wj.sc(wj.gd + "mp3_like.json");
|
||||
}
|
||||
}
|
||||
bfqkz.like_bool = contains;
|
||||
bfq.setlike(contains);
|
||||
return bfqkz.like_bool = contains;
|
||||
}
|
||||
|
||||
public static boolean getlike(MP3 xm) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
|
|||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
|
@ -34,6 +35,7 @@ public class bfqkz extends MediaBrowserServiceCompat {
|
|||
// 0 循环 1 顺序 2 随机
|
||||
public static MP3 xm;
|
||||
public static boolean like_bool;
|
||||
public static String lrc;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
public static com.muqingbfq.mq.NotificationManagerCompat notify;
|
||||
|
||||
|
@ -45,39 +47,40 @@ public class bfqkz extends MediaBrowserServiceCompat {
|
|||
return i;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public static void mp3(String id) {
|
||||
public static void mp3(MP3 mp3) {
|
||||
try {
|
||||
if (id == null) {
|
||||
if (mp3 == null) {
|
||||
return;
|
||||
}
|
||||
if (TextUtils.isEmpty(id)) {
|
||||
if (TextUtils.isEmpty(mp3.url)) {
|
||||
//针对错误进行相应的处理
|
||||
bfqkz.list.remove(bfqkz.xm);
|
||||
bfq_an.xyq();
|
||||
return;
|
||||
}
|
||||
if (TextUtils.isEmpty(xm.picurl)) {
|
||||
xm.picurl = url.picurl(xm.id);
|
||||
if (xm.picurl instanceof String) {
|
||||
if (TextUtils.isEmpty(xm.picurl.toString())) {
|
||||
xm.picurl = url.picurl(xm.id);
|
||||
}
|
||||
}
|
||||
mt.setDataSource(id);
|
||||
mt.setDataSource(mp3);
|
||||
} catch (Exception e) {
|
||||
yc.start(home.appCompatActivity, "bfqkz mp3(" + id + ") :" + e);
|
||||
yc.start(home.appCompatActivity, "bfqkz mp3(" + mp3.toString() + ") :" + e);
|
||||
}
|
||||
}
|
||||
|
||||
public static class mp3 extends Thread {
|
||||
String id;
|
||||
MP3 mp3;
|
||||
|
||||
public mp3(String id) {
|
||||
this.id = id;
|
||||
public mp3(MP3 mp3) {
|
||||
this.mp3 = mp3;
|
||||
start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
mp3(id);
|
||||
mp3(mp3);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,141 +1,28 @@
|
|||
package com.muqingbfq.fragment;
|
||||
|
||||
import android.graphics.BitmapFactory;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.android.material.slider.Slider;
|
||||
import com.muqingbfq.R;
|
||||
import com.muqingbfq.bfq;
|
||||
import com.muqingbfq.bfq_an;
|
||||
import com.muqingbfq.bfqkz;
|
||||
import com.muqingbfq.databinding.ActivityBfqBinding;
|
||||
import com.muqingbfq.main;
|
||||
import com.muqingbfq.mq.gj;
|
||||
import com.muqingbfq.view.LrcView;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class Media {
|
||||
public static void setTime_a(String str) {
|
||||
if (bfq.view == null) {
|
||||
return;
|
||||
}
|
||||
bfq.binding.timeA.setText(str);
|
||||
}
|
||||
|
||||
public static void setTime_b(String str) {
|
||||
if (bfq.view == null) {
|
||||
return;
|
||||
}
|
||||
bfq.binding.timeB.setText(str);
|
||||
}
|
||||
|
||||
public static void setMax(int max) {
|
||||
if (bfq.view == null) {
|
||||
return;
|
||||
}
|
||||
bfq.binding.tdt.setValueTo(max);
|
||||
}
|
||||
|
||||
public static void setProgress(int progress) {
|
||||
if (bfq.view == null) {
|
||||
return;
|
||||
}
|
||||
// gj.sc(progress);
|
||||
bfq.binding.tdt.setValue(progress);
|
||||
// bfq.lrcview.updateTime(progress);
|
||||
bfq.lrcView.setTimeLrc(progress);
|
||||
}
|
||||
|
||||
public static void setbf(boolean bool) {
|
||||
if (bool) {
|
||||
//开始
|
||||
bfq.kgsetImageResource(R.drawable.bf);
|
||||
} else {
|
||||
//暂停
|
||||
bfq.kgsetImageResource(R.drawable.zt);
|
||||
}
|
||||
bfq_db.setkg(bool);
|
||||
if (bfqkz.notify != null) {
|
||||
bfqkz.notify.tzl_button();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Media(ActivityBfqBinding binding) {
|
||||
binding.tdt.addOnChangeListener((slider, value, fromUser) -> setTime_b(bfq_an.getTime((long) value)));
|
||||
binding.tdt.addOnSliderTouchListener(new Slider.OnSliderTouchListener() {
|
||||
@Override
|
||||
public void onStartTrackingTouch(@NonNull Slider slider) {
|
||||
|
||||
// 拖动条移动中
|
||||
main.handler.removeCallbacks(bfqkz.mt.updateSeekBar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(@NonNull Slider slider) {
|
||||
// 播放音乐到指定位置
|
||||
main.handler.post(bfqkz.mt.updateSeekBar);
|
||||
bfqkz.mt.seekTo((int) slider.getValue());
|
||||
}
|
||||
});
|
||||
/*
|
||||
binding.tdt.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
setTime_b(bfq_an.getTime(progress));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
// 拖动条移动中
|
||||
main.handler.removeCallbacks(bfqkz.mt.updateSeekBar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
// 播放音乐到指定位置
|
||||
main.handler.post(bfqkz.mt.updateSeekBar);
|
||||
bfqkz.mt.seekTo(seekBar.getProgress());
|
||||
}
|
||||
});*/
|
||||
//初始化播放器列表
|
||||
if (bfqkz.xm != null) {
|
||||
long duration = bfqkz.mt.getDuration();
|
||||
binding.tdt.setValueTo(bfqkz.mt.getDuration());
|
||||
setTime_a(bfq_an.getTime(duration));
|
||||
long position = bfqkz.mt.getCurrentPosition();
|
||||
main.handler.post(bfqkz.mt.updateSeekBar); // 在播放开始时启动更新进度
|
||||
loadLyric();
|
||||
setProgress((int) position);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void loadLyric() {
|
||||
if (com.muqingbfq.bfq.lrc == null) {
|
||||
return;
|
||||
public static String[] loadLyric() {
|
||||
if (com.muqingbfq.bfqkz.lrc == null) {
|
||||
return null;
|
||||
}
|
||||
JSONObject jsonObject;
|
||||
String a = null, b = null;
|
||||
try {
|
||||
jsonObject = new JSONObject(com.muqingbfq.bfq.lrc);
|
||||
jsonObject = new JSONObject(com.muqingbfq.bfqkz.lrc);
|
||||
a = jsonObject.getJSONObject("lrc").getString("lyric");
|
||||
b = jsonObject.getJSONObject("tlyric").getString("lyric");
|
||||
} catch (Exception e) {
|
||||
gj.sc("Media loadLyric "+e);
|
||||
}
|
||||
LrcView.setLrc(a, b);
|
||||
return new String[]{a, b};
|
||||
// LrcView.setLrc(a, b);
|
||||
// bfq.lrcView.getLrc();
|
||||
// bfq.lrcView.loadLrc(a, b);
|
||||
}
|
||||
|
||||
|
||||
public static void setImageBitmap() {
|
||||
if (bfq.view == null) {
|
||||
return;
|
||||
}
|
||||
main.handler.post(() -> bfq.binding.cardview.setImage(com.muqingbfq.bfq.bitmap));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,12 +20,11 @@ import androidx.fragment.app.Fragment;
|
|||
import com.google.gson.reflect.TypeToken;
|
||||
import com.muqingbfq.MP3;
|
||||
import com.muqingbfq.R;
|
||||
import com.muqingbfq.api.url;
|
||||
import com.muqingbfq.bfq;
|
||||
import com.muqingbfq.bfq_an;
|
||||
import com.muqingbfq.bfqkz;
|
||||
import com.muqingbfq.databinding.FragmentBfqDbBinding;
|
||||
import com.muqingbfq.main;
|
||||
import com.muqingbfq.mq.gj;
|
||||
import com.muqingbfq.mq.wj;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
@ -34,10 +33,9 @@ import java.util.List;
|
|||
public class bfq_db extends Fragment implements GestureDetector.OnGestureListener {
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
public static View view;
|
||||
|
||||
private GestureDetector gestureDetector;
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@SuppressLint({"ClickableViewAccessibility", "SetTextI18n"})
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
@ -57,42 +55,52 @@ public class bfq_db extends Fragment implements GestureDetector.OnGestureListene
|
|||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
String hq = url.hq(bfqkz.xm);
|
||||
MP3 hq = com.muqingbfq.api.url.hq(bfqkz.xm);
|
||||
if (hq == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
bfqkz.mt.DataSource(hq);
|
||||
} catch (Exception e) {
|
||||
gj.sc(e);
|
||||
com.muqingbfq.mq.gj.sc(e);
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
}
|
||||
view = inflater.inflate(R.layout.fragment_bfq_db, container, false);
|
||||
|
||||
TextView name = view.findViewById(R.id.name);
|
||||
view.findViewById(R.id.kg).setOnClickListener(new bfq_an.kz());
|
||||
view.findViewById(R.id.txb).setOnClickListener(view -> bflb_db.start(getContext()));
|
||||
FragmentBfqDbBinding binding = FragmentBfqDbBinding.inflate(getLayoutInflater(),
|
||||
container, false);
|
||||
view = binding.getRoot();
|
||||
binding.kg.setOnClickListener(v -> {
|
||||
if (bfqkz.mt == null) {
|
||||
return;
|
||||
}
|
||||
// gj.sc(isMusicServiceBound);播放/暂停按钮点击事件 if (isMusicServiceBound)
|
||||
if (bfqkz.mt.isPlaying()) {
|
||||
bfqkz.mt.pause();
|
||||
} else {
|
||||
bfqkz.mt.start();
|
||||
}
|
||||
setkg(bfqkz.mt.isPlaying());
|
||||
});
|
||||
|
||||
binding.txb.setOnClickListener(view -> bflb_db.start(getContext()));
|
||||
// view.setOnClickListener(vw -> bfq.start(getContext()));
|
||||
gestureDetector = new GestureDetector(getContext(), this);
|
||||
|
||||
view.setOnTouchListener((view, motionEvent) -> {
|
||||
/* if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
|
||||
view.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.bj));
|
||||
return true;
|
||||
}*/
|
||||
return gestureDetector.onTouchEvent(motionEvent);
|
||||
|
||||
});
|
||||
|
||||
// 恢复列表数据
|
||||
if (bfqkz.xm != null) {
|
||||
name.setText(bfqkz.xm.name + "/" + bfqkz.xm.zz);
|
||||
binding.name.setText(bfqkz.xm.name + "/" + bfqkz.xm.zz);
|
||||
}
|
||||
if (bfqkz.mt != null) {
|
||||
Media.setbf(bfqkz.mt.isPlaying());
|
||||
setkg(bfqkz.mt.isPlaying());
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
@ -118,6 +126,7 @@ public class bfq_db extends Fragment implements GestureDetector.OnGestureListene
|
|||
textView.setText(str);
|
||||
}
|
||||
}
|
||||
|
||||
public static TextView getname() {
|
||||
if (view != null) {
|
||||
return findViewById(R.id.name);
|
||||
|
@ -137,8 +146,8 @@ public class bfq_db extends Fragment implements GestureDetector.OnGestureListene
|
|||
|
||||
@Override
|
||||
public boolean onSingleTapUp(@NonNull MotionEvent motionEvent) {
|
||||
bfq.start(getContext());
|
||||
view.setBackgroundColor(ContextCompat.getColor(getContext(),R.color.bj));
|
||||
bfq.startactivity(getContext(), bfqkz.xm);
|
||||
// view.setBackgroundColor(ContextCompat.getColor(getContext(),R.color.bj));
|
||||
// view.setBackgroundColor(ContextCompat.getColor(getContext(),R.color.bj));
|
||||
return true;
|
||||
}
|
||||
|
@ -147,7 +156,7 @@ public class bfq_db extends Fragment implements GestureDetector.OnGestureListene
|
|||
public boolean onScroll(@Nullable MotionEvent motionEvent, @NonNull MotionEvent motionEvent1,
|
||||
float v, float v1) {
|
||||
getname().setTranslationX(view.getTranslationX() - v);
|
||||
view.setBackgroundColor(ContextCompat.getColor(getContext(),R.color.bj));
|
||||
view.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.bj));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -159,7 +168,7 @@ public class bfq_db extends Fragment implements GestureDetector.OnGestureListene
|
|||
@Override
|
||||
public boolean onFling(@Nullable MotionEvent e1,
|
||||
@NonNull MotionEvent e2, float v, float v1) {
|
||||
view.setBackgroundColor(ContextCompat.getColor(getContext(),R.color.bj));
|
||||
view.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.bj));
|
||||
float distance = e1.getX() - e2.getX();
|
||||
float threshold = main.k / 2.0f;
|
||||
// 判断手势方向并限制滑动距离
|
||||
|
@ -173,7 +182,6 @@ public class bfq_db extends Fragment implements GestureDetector.OnGestureListene
|
|||
bfq_an.syq();
|
||||
}
|
||||
getname().setTranslationX(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -46,11 +46,12 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
|
|||
private final List<XM> list = new ArrayList<>();
|
||||
public static RecyclerView.Adapter<VH> adapter;
|
||||
int k;
|
||||
FragmentMp3Binding binding;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
FragmentMp3Binding binding = FragmentMp3Binding.inflate(getLayoutInflater());
|
||||
binding = FragmentMp3Binding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
|
||||
Intent intent = getIntent();
|
||||
|
@ -69,9 +70,9 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
|
|||
String id;
|
||||
|
||||
public start(String id) {
|
||||
binding.recyclerview1Bar.setVisibility(View.VISIBLE);
|
||||
this.id = id;
|
||||
list.clear();
|
||||
adapter.notifyDataSetChanged();
|
||||
start();
|
||||
}
|
||||
|
||||
|
@ -97,7 +98,16 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
|
|||
gj.sc(e);
|
||||
}
|
||||
}
|
||||
main.handler.post(new lbspq_sx());
|
||||
main.handler.post(() -> {
|
||||
adapter.notifyDataSetChanged();
|
||||
binding.recyclerview1Bar.setVisibility(View.GONE);
|
||||
if (list.isEmpty()) {
|
||||
binding.recyclerview1Text.setVisibility(View.VISIBLE);
|
||||
binding.recyclerview1Text.setOnClickListener(v -> new start(id));
|
||||
} else {
|
||||
binding.recyclerview1Text.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -283,13 +293,4 @@ public class gd extends com.muqingbfq.mq.FragmentActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private class lbspq_sx implements Runnable {
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@Override
|
||||
public void run() {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -28,7 +28,6 @@ import com.muqingbfq.MP3;
|
|||
import com.muqingbfq.R;
|
||||
import com.muqingbfq.api.FileDownloader;
|
||||
import com.muqingbfq.api.playlist;
|
||||
import com.muqingbfq.api.url;
|
||||
import com.muqingbfq.bfq;
|
||||
import com.muqingbfq.bfq_an;
|
||||
import com.muqingbfq.bfqkz;
|
||||
|
@ -47,7 +46,7 @@ import java.util.List;
|
|||
public class mp3 extends FragmentActivity {
|
||||
private List<MP3> list = new ArrayList<>();
|
||||
private List<MP3> list_ys = new ArrayList<>();
|
||||
public static adaper lbspq;
|
||||
public static Adapter adapter;
|
||||
FragmentMp3Binding binding;
|
||||
|
||||
// private static String id;
|
||||
|
@ -59,11 +58,11 @@ public class mp3 extends FragmentActivity {
|
|||
binding.title.setText(intent.getStringExtra("name"));
|
||||
String id = intent.getStringExtra("id");
|
||||
setContentView(binding.getRoot());
|
||||
lbspq = new adaper(list);
|
||||
adapter = new Adapter(list);
|
||||
binding.lb.setLayoutManager(new LinearLayoutManager(this));
|
||||
binding.lb.setAdapter(lbspq);
|
||||
binding.lb.setAdapter(adapter);
|
||||
new start(id);
|
||||
binding.edittext.addTextChangedListener(new TextWatcher() {
|
||||
binding.edittext.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
|
@ -72,7 +71,7 @@ public class mp3 extends FragmentActivity {
|
|||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
if (binding.edittext.getVisibility() == View.VISIBLE) {
|
||||
lbspq.getFilter().filter(charSequence);
|
||||
adapter.getFilter().filter(charSequence);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,11 +101,11 @@ public class mp3 extends FragmentActivity {
|
|||
if (binding.edittext.getVisibility() == View.VISIBLE) {
|
||||
binding.title.setVisibility(View.VISIBLE);
|
||||
binding.edittext.setVisibility(View.GONE);
|
||||
gj.ycjp(binding.edittext);
|
||||
adapter.getFilter().filter("");
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
gj.ycjp(binding.edittext);
|
||||
lbspq.getFilter().filter("");
|
||||
} else if (itemId == 0) {
|
||||
binding.title.setVisibility(View.GONE);
|
||||
binding.edittext.setVisibility(View.VISIBLE);
|
||||
|
@ -120,11 +119,12 @@ public class mp3 extends FragmentActivity {
|
|||
if (binding.edittext.getVisibility() == View.VISIBLE) {
|
||||
binding.title.setVisibility(View.VISIBLE);
|
||||
binding.edittext.setVisibility(View.GONE);
|
||||
gj.ycjp(binding.edittext);
|
||||
adapter.getFilter().filter("");
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
gj.ycjp(binding.edittext);
|
||||
lbspq.getFilter().filter("");
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
|
@ -142,40 +142,39 @@ public class mp3 extends FragmentActivity {
|
|||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
if (id.equals("mp3_xz.json")) {
|
||||
playlist.hq_xz(list);
|
||||
} else if (id.equals("mp3_like.json")) {
|
||||
playlist.hq_like(list);
|
||||
} else {
|
||||
playlist.hq(list, id);
|
||||
switch (id) {
|
||||
case "mp3_xz.json":
|
||||
playlist.hq_xz(list);
|
||||
break;
|
||||
case "mp3_like.json":
|
||||
playlist.hq_like(list);
|
||||
break;
|
||||
case "cd.json":
|
||||
playlist.hq_cd(mp3.this, list);
|
||||
break;
|
||||
default:
|
||||
playlist.hq(list, id);
|
||||
break;
|
||||
}
|
||||
list_ys = list;
|
||||
main.handler.post(() -> {
|
||||
lbspq.notifyDataSetChanged();
|
||||
binding.lb.getAdapter().notifyDataSetChanged();
|
||||
binding.recyclerview1Bar.setVisibility(View.GONE);
|
||||
if (list.isEmpty()) {
|
||||
binding.recyclerview1Text.setVisibility(View.VISIBLE);
|
||||
binding.recyclerview1Text.setOnClickListener(v -> new start(id));
|
||||
} else {
|
||||
binding.recyclerview1Text.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static class lbspq_sx implements Runnable {
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@Override
|
||||
public void run() {
|
||||
lbspq.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public static class adaper extends RecyclerView.Adapter<MyViewHoder> implements Filterable {
|
||||
public static class Adapter extends RecyclerView.Adapter<MyViewHoder> implements Filterable {
|
||||
|
||||
private List<MP3> list;
|
||||
private List<MP3> list_ys;
|
||||
|
||||
public adaper(List list) {
|
||||
public Adapter(List list) {
|
||||
this.list = list;
|
||||
list_ys = list;
|
||||
}
|
||||
|
@ -201,13 +200,11 @@ public class mp3 extends FragmentActivity {
|
|||
holder.binding.name.setTextColor(color);
|
||||
holder.binding.zz.setTextColor(color);
|
||||
holder.itemView.setOnClickListener(view -> {
|
||||
if (bfqkz.xm == null || !bfqkz.xm.id.equals(x.id)) {
|
||||
bfqkz.xm = x;
|
||||
new url(x);
|
||||
if (bfqkz.list!=list) {
|
||||
bfqkz.list.clear();
|
||||
bfqkz.list.addAll(list);
|
||||
}
|
||||
bfqkz.list.clear();
|
||||
bfqkz.list.addAll(list);
|
||||
bfq.start(holder.getContext());
|
||||
bfq.startactivity(holder.getContext(), x);
|
||||
});
|
||||
holder.itemView.setOnLongClickListener(view -> {
|
||||
List<String> stringList = new ArrayList<>();
|
||||
|
@ -217,7 +214,9 @@ public class mp3 extends FragmentActivity {
|
|||
} else {
|
||||
stringList.add("喜欢歌曲");
|
||||
}
|
||||
if (!wj.cz(wj.mp3 + x.id)) {
|
||||
if (wj.cz(wj.mp3 + x.id)) {
|
||||
stringList.add("删除下载");
|
||||
} else {
|
||||
stringList.add("下载歌曲");
|
||||
}
|
||||
stringList.add("复制名字");
|
||||
|
@ -228,6 +227,13 @@ public class mp3 extends FragmentActivity {
|
|||
case "下载歌曲":
|
||||
new FileDownloader(view.getContext()).downloadFile(x);
|
||||
break;
|
||||
case "删除下载":
|
||||
wj.sc(wj.mp3 + x.id);
|
||||
/* if (sc&&) {
|
||||
list.remove(position);
|
||||
notifyItemRemoved(position);
|
||||
}*/
|
||||
break;
|
||||
case "喜欢歌曲":
|
||||
case "取消喜欢":
|
||||
try {
|
||||
|
@ -303,4 +309,10 @@ public class mp3 extends FragmentActivity {
|
|||
public static void startactivity(Context context, String id) {
|
||||
context.startActivity(new Intent(context, mp3.class).putExtra("id", id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
adapter = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class search extends Fragment {
|
|||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
binding = FragmentSearchBinding.inflate(inflater, container, false);
|
||||
lbspq = new mp3.adaper(list);
|
||||
lbspq = new mp3.Adapter(list);
|
||||
binding.tablayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
|
@ -79,7 +79,7 @@ public class search extends Fragment {
|
|||
|
||||
public void setStart(String name) {
|
||||
if (i == 0) {
|
||||
new mp3.adaper(list);
|
||||
new mp3.Adapter(list);
|
||||
binding.recyclerview.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
binding.recyclerview.setAdapter(lbspq);
|
||||
} else if (i == 1) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muqingbfq.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
|
@ -10,6 +11,8 @@ import android.view.ViewGroup;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
|
@ -51,24 +54,23 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
public class wode extends Fragment {
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
public static TextView name, jieshao;
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
public static ImageView imageView;
|
||||
public TextView name, jieshao;
|
||||
public ImageView imageView;
|
||||
FragmentWdBinding binding;
|
||||
private final Object[][] lista = {
|
||||
{R.drawable.bf, "最近播放", "mp3_hc.json"},
|
||||
{R.drawable.download, "下载音乐", "mp3_xz.json"},
|
||||
{R.drawable.like, "喜欢音乐", "mp3_like.json"},
|
||||
{R.drawable.icon, "本地搜索", ""},
|
||||
{R.drawable.icon, "本地搜索", "cd.json"},
|
||||
{R.drawable.fuwuzhongxing, "更换接口", "API"},
|
||||
{R.drawable.gd, "导入歌单", "gd"},
|
||||
{R.drawable.paihangbang, "排行榜", "排行榜"},
|
||||
{R.drawable.icon, "开发中", ""}
|
||||
};
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
public static baseadapter adaper;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
|
@ -137,6 +139,7 @@ public class wode extends Fragment {
|
|||
String data = lista[position][2].toString();
|
||||
holder.itemView.setOnClickListener(view -> {
|
||||
switch (data) {
|
||||
case "cd.json":
|
||||
case "mp3_hc.json":
|
||||
case "mp3_xz.json":
|
||||
case "mp3_like.json":
|
||||
|
@ -208,10 +211,10 @@ public class wode extends Fragment {
|
|||
editViewDialog1.dismiss();
|
||||
}).show();
|
||||
break;
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return lista.length;
|
||||
|
@ -231,11 +234,23 @@ public class wode extends Fragment {
|
|||
return binding.getRoot();
|
||||
}
|
||||
|
||||
class dl implements View.OnClickListener {
|
||||
ActivityResultLauncher<Intent> dlintent = registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
if (result.getResultCode() == Activity.RESULT_OK) {
|
||||
// 处理返回结果
|
||||
Intent data = result.getData();
|
||||
boolean bool = data.getBooleanExtra("bool", false);
|
||||
if (bool) {
|
||||
denglu();
|
||||
}
|
||||
// ...
|
||||
}
|
||||
});
|
||||
|
||||
class dl implements View.OnClickListener {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
File file = new File(wj.filesdri, "user.mq");
|
||||
if (file.exists()) {
|
||||
String[] a = new String[]{"退出登录"};
|
||||
|
@ -251,7 +266,7 @@ public class wode extends Fragment {
|
|||
}
|
||||
}).show();
|
||||
} else {
|
||||
startActivity(new Intent(getContext(), user_logs.class));
|
||||
dlintent.launch(new Intent(getContext(), user_logs.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -271,7 +286,7 @@ public class wode extends Fragment {
|
|||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void sx() {
|
||||
adaper.list.clear();
|
||||
new Thread(){
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
|
@ -291,7 +306,7 @@ public class wode extends Fragment {
|
|||
String message = jsonObject.getString("message");
|
||||
adaper.list.add(new XM(id, name, message, picUrl));
|
||||
}
|
||||
main.handler.post(() ->{
|
||||
main.handler.post(() -> {
|
||||
adaper.notifyDataSetChanged();
|
||||
if (adaper.list.isEmpty()) {
|
||||
binding.recyclerview2Text.setVisibility(View.VISIBLE);
|
||||
|
@ -323,11 +338,11 @@ public class wode extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
public static void setname(String string) {
|
||||
public void setname(String string) {
|
||||
main.handler.post(() -> name.setText(string));
|
||||
}
|
||||
|
||||
public static void setqianming(String string) {
|
||||
public void setqianming(String string) {
|
||||
main.handler.post(() -> {
|
||||
if (string == null) {
|
||||
jieshao.setText("");
|
||||
|
@ -350,9 +365,9 @@ public class wode extends Fragment {
|
|||
.error(R.drawable.ic_launcher_foreground)
|
||||
.into(binding.imageView);
|
||||
}
|
||||
|
||||
class baseadapter extends RecyclerView.Adapter<gd.VH> {
|
||||
public List<XM> list = new ArrayList<>();
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public gd.VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
|
@ -459,6 +474,4 @@ public class wode extends Fragment {
|
|||
return list.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -150,9 +150,6 @@ public class user_editing extends FragmentActivity {
|
|||
binding.userEnd.setOnClickListener(view ->{
|
||||
finish();
|
||||
// main.settoken(null, null);
|
||||
com.muqingbfq.fragment.wode.setname("未登录");
|
||||
com.muqingbfq.fragment.wode.setqianming(null);
|
||||
com.muqingbfq.fragment.wode.imageView.setImageResource(R.drawable.icon);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muqingbfq.login;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
|
@ -64,14 +65,21 @@ public class user_logs extends AppCompatActivity {
|
|||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
finish();
|
||||
finish(false);
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public void finish(boolean aBoolean) {
|
||||
Intent resultIntent = new Intent();
|
||||
resultIntent.putExtra("bool", aBoolean);
|
||||
setResult(RESULT_OK, resultIntent);
|
||||
super.finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
public void onBackPressed() {
|
||||
finish(false);
|
||||
}
|
||||
|
||||
public static Bitmap stringToBitmap(String string) {
|
||||
|
@ -118,7 +126,7 @@ public class user_logs extends AppCompatActivity {
|
|||
gj.xcts(user_logs.this, "登录成功");
|
||||
wl.setcookie(cookie);
|
||||
new user_message(nickname, signature, avatarUrl);
|
||||
user_logs.this.finish();
|
||||
user_logs.this.finish(true);
|
||||
} else if (code == 502) {
|
||||
gj.xcts(user_logs.this, jsonObject.getString("message"));
|
||||
} else {
|
||||
|
@ -130,7 +138,6 @@ public class user_logs extends AppCompatActivity {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class erweima extends Thread {
|
||||
int code = 800;
|
||||
String unikey, qrimg, hq;
|
||||
|
@ -166,7 +173,7 @@ public class user_logs extends AppCompatActivity {
|
|||
setwb("登录成功");
|
||||
wl.setcookie(json.getString("cookie"));
|
||||
code = 0;
|
||||
user_logs.this.finish();
|
||||
user_logs.this.finish(true);
|
||||
break;
|
||||
default:
|
||||
code = 0;
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.muqingbfq.main;
|
|||
import com.muqingbfq.mq.gj;
|
||||
import com.muqingbfq.mq.wj;
|
||||
|
||||
public class user_message extends Thread {
|
||||
public class user_message{
|
||||
public String name,qiangming, picurl;
|
||||
|
||||
public user_message() {
|
||||
|
@ -18,31 +18,8 @@ public class user_message extends Thread {
|
|||
picurl = avatarUrl;
|
||||
String s = new Gson().toJson(new user_logs.USER(name, qiangming, picurl));
|
||||
wj.xrwb(wj.filesdri + "user.mq", s);
|
||||
start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
super.run();
|
||||
try {
|
||||
string strings = get();
|
||||
main.handler.post(() -> {
|
||||
com.muqingbfq.fragment.
|
||||
wode.setname(strings.userName());
|
||||
com.muqingbfq.fragment.
|
||||
wode.setqianming(strings.qianming());
|
||||
com.bumptech.glide.Glide.with(com.muqingbfq.fragment.
|
||||
wode.imageView)
|
||||
.load(strings.picurl())
|
||||
.placeholder(R.drawable.icon)//图片加载出来前,显示的图片
|
||||
.error(R.drawable.icon)//图片加载失败后,显示的图片
|
||||
.into(com.muqingbfq.fragment.
|
||||
wode.imageView);
|
||||
});
|
||||
} catch (Exception e) {
|
||||
gj.sc(e);
|
||||
}
|
||||
}
|
||||
|
||||
public string get() throws Exception {
|
||||
/* JSONObject post = wl.jsonpost("/php/user.php?action=getSpaceInfo",
|
||||
|
@ -73,7 +50,7 @@ public class user_message extends Thread {
|
|||
});
|
||||
}
|
||||
|
||||
static class string {
|
||||
public static class string {
|
||||
private final String[] strings;
|
||||
public string(String[] strings) {
|
||||
this.strings = strings;
|
||||
|
|
|
@ -24,11 +24,13 @@ import com.muqingbfq.bfq_an;
|
|||
import com.muqingbfq.bfqkz;
|
||||
import com.muqingbfq.databinding.FloatLrcviewBinding;
|
||||
import com.muqingbfq.main;
|
||||
import com.muqingbfq.view.LrcView;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import me.wcy.lrcview.LrcEntry;
|
||||
import me.wcy.lrcview.LrcView;
|
||||
|
||||
public class FloatingLyricsService extends Service implements View.OnClickListener, View.OnTouchListener {
|
||||
private WindowManager windowManager;
|
||||
private View layout;
|
||||
|
@ -36,36 +38,33 @@ public class FloatingLyricsService extends Service implements View.OnClickListen
|
|||
public Runnable updateSeekBar = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (bfqkz.mt.isPlaying()) {
|
||||
int index = 0;
|
||||
for (int i = 0; i < LrcView.lrclist.size(); i++) {
|
||||
LrcView.LRC lineLrc = LrcView.lrclist.get(i);
|
||||
if (lineLrc.time <= bfqkz.mt.getCurrentPosition()) {
|
||||
index = i;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index < LrcView.lrclist.size()) {
|
||||
String text;
|
||||
if (LrcView.lrclist.size() <= 3) {
|
||||
for (LrcView.LRC a : LrcView.lrclist) {
|
||||
if (a.time == 5940000 && a.lrc.equals("纯音乐,请欣赏")) {
|
||||
text = "纯音乐,请欣赏";
|
||||
binding.lrcView.setText(text);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
LrcView.LRC currentLrc = LrcView.lrclist.get(index);
|
||||
text = currentLrc.lrc;
|
||||
if (currentLrc.tlyric != null) {
|
||||
text += "\n" + currentLrc.tlyric;
|
||||
}
|
||||
binding.lrcView.setText(text);
|
||||
int index = 0;
|
||||
for (int i = 0; i < LrcView.mLrcEntryList.size(); i++) {
|
||||
LrcEntry lineLrc = LrcView.mLrcEntryList.get(i);
|
||||
if (lineLrc.time <= bfqkz.mt.getCurrentPosition()) {
|
||||
index = i;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// gj.sc(getClass()+"执行");
|
||||
if (index < LrcView.mLrcEntryList.size()) {
|
||||
String text;
|
||||
if (LrcView.mLrcEntryList.size() <= 3) {
|
||||
for (LrcEntry a : LrcView.mLrcEntryList) {
|
||||
if (a.time == 5940000 && a.text.equals("纯音乐,请欣赏")) {
|
||||
text = "纯音乐,请欣赏";
|
||||
binding.lrcView.setText(text);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
LrcEntry currentLrc = LrcView.mLrcEntryList.get(index);
|
||||
text = currentLrc.text;
|
||||
if (currentLrc.secondText != null) {
|
||||
text += "\n" + currentLrc.secondText;
|
||||
}
|
||||
binding.lrcView.setText(text);
|
||||
}
|
||||
handler.postDelayed(this, 1000); // 每秒更新一次进度
|
||||
}
|
||||
};
|
||||
|
@ -181,7 +180,7 @@ public class FloatingLyricsService extends Service implements View.OnClickListen
|
|||
// 在 Service 销毁时移除悬浮窗歌词
|
||||
if (windowManager != null && layout != null) {
|
||||
windowManager.removeView(layout);
|
||||
handler.removeCallbacks(bfqkz.mt.updateSeekBar); // 在播放开始时启动更新进度
|
||||
handler.removeCallbacks(updateSeekBar); // 在播放开始时启动更新进度
|
||||
}
|
||||
lei = null;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.app.PendingIntent;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.support.v4.media.MediaMetadataCompat;
|
||||
|
||||
|
@ -91,6 +92,20 @@ public class NotificationManagerCompat {
|
|||
notificationManager_notify();
|
||||
}
|
||||
|
||||
public void setbitmap(Bitmap bitmap) {
|
||||
notificationBuilder
|
||||
.setLargeIcon(bitmap);
|
||||
|
||||
context.builder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, name)
|
||||
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, zz)
|
||||
.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, zz)
|
||||
.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, bitmap)
|
||||
.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, 100);
|
||||
|
||||
context.mSession.setMetadata(context.builder.build());
|
||||
notificationManager_notify();
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
public void tzl() {
|
||||
if (notificationBuilder == null) {
|
||||
|
@ -102,7 +117,6 @@ public class NotificationManagerCompat {
|
|||
}
|
||||
notificationBuilder.mActions.clear();
|
||||
notificationBuilder
|
||||
.setLargeIcon(bfq.bitmap)
|
||||
.addAction(R.drawable.like, "like", pendingIntent_like) // #0
|
||||
.addAction(R.drawable.syq, "syq", pendingIntent_syq) // #0
|
||||
.addAction(bfqkz.mt.isPlaying() ? R.drawable.bf : R.drawable.zt
|
||||
|
@ -113,11 +127,6 @@ public class NotificationManagerCompat {
|
|||
.setContentText(zz)
|
||||
.setOngoing(bfqkz.mt.isPlaying());
|
||||
|
||||
context.builder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, name)
|
||||
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, zz)
|
||||
.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, zz)
|
||||
.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, bfq.bitmap)
|
||||
.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, 100);
|
||||
|
||||
context.mSession.setMetadata(context.builder.build());
|
||||
notificationManager_notify();
|
||||
|
|
|
@ -1,9 +1,21 @@
|
|||
package com.muqingbfq.mq;
|
||||
|
||||
import static androidx.core.content.ContextCompat.startActivity;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.muqingbfq.MP3;
|
||||
import com.muqingbfq.home;
|
||||
import com.muqingbfq.yc;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
@ -14,8 +26,6 @@ import java.io.FileReader;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.security.MessageDigest;
|
||||
|
@ -27,7 +37,7 @@ public class wj {
|
|||
public static String lishi_json = "lishi.json";
|
||||
public static String gd = "gd/";
|
||||
public static String tx = "image/";
|
||||
public static String gd_json = "gd.json", mp3_xz = "mp3_xz.json", gd_xz = "gd_xz.json",
|
||||
public static String gd_json = "gd.json", gd_xz = "gd_xz.json",
|
||||
gd_phb = "gd_phb.json", mp3_like = "mp3_like.json";
|
||||
|
||||
public wj(Context context) {
|
||||
|
@ -39,7 +49,6 @@ public class wj {
|
|||
gd = filesdri + gd;
|
||||
gd_xz = filesdri + gd_xz;
|
||||
gd_phb = filesdri + gd_phb;
|
||||
mp3_xz = gd + mp3_xz;
|
||||
mp3_like = gd + mp3_like;
|
||||
tx = filesdri + tx;
|
||||
} catch (Exception e) {
|
||||
|
@ -188,4 +197,40 @@ public class wj {
|
|||
}
|
||||
return mp3;
|
||||
}
|
||||
|
||||
|
||||
private static final int REQUEST_EXTERNAL_STORAGE = 1;
|
||||
private static String[] PERMISSIONS_STORAGE = {
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
};
|
||||
|
||||
public static boolean isCD(Context context) {
|
||||
//检查权限(NEED_PERMISSION)是否被授权 PackageManager.PERMISSION_GRANTED表示同意授权
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
if (!Environment.isExternalStorageManager()) {
|
||||
Intent intent = new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
|
||||
context.startActivity(intent);
|
||||
} else {
|
||||
Log.i("swyLog", "Android 11以上,当前已有权限");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
|
||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.WRITE_EXTERNAL_STORAGE) !=
|
||||
PackageManager.PERMISSION_GRANTED) {
|
||||
//申请权限
|
||||
ActivityCompat.requestPermissions(home.appCompatActivity
|
||||
, PERMISSIONS_STORAGE, REQUEST_EXTERNAL_STORAGE);
|
||||
} else {
|
||||
Log.i("swyLog", "Android 6.0以上,11以下,当前已有权限");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
Log.i("swyLog", "Android 6.0以下,已获取权限");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,12 +31,14 @@ import com.google.gson.reflect.TypeToken;
|
|||
import com.muqingbfq.databinding.ActivitySzSetlrcBinding;
|
||||
import com.muqingbfq.mq.FloatingLyricsService;
|
||||
import com.muqingbfq.mq.wj;
|
||||
import com.muqingbfq.view.LrcView;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Locale;
|
||||
|
||||
import me.wcy.lrcview.LrcEntry;
|
||||
import me.wcy.lrcview.LrcView;
|
||||
|
||||
public class sz extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -140,29 +142,29 @@ public class sz extends AppCompatActivity {
|
|||
public void run() {
|
||||
if (bfqkz.mt.isPlaying()) {
|
||||
int index = 0;
|
||||
for (int i = 0; i < LrcView.lrclist.size(); i++) {
|
||||
LrcView.LRC lineLrc = LrcView.lrclist.get(i);
|
||||
for (int i = 0; i < LrcView.mLrcEntryList.size(); i++) {
|
||||
LrcEntry lineLrc = LrcView.mLrcEntryList.get(i);
|
||||
if (lineLrc.time <= bfqkz.mt.getCurrentPosition()) {
|
||||
index = i;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index < LrcView.lrclist.size()) {
|
||||
if (index < LrcView.mLrcEntryList.size()) {
|
||||
String text;
|
||||
if (LrcView.lrclist.size() <= 3) {
|
||||
for (LrcView.LRC a : LrcView.lrclist) {
|
||||
if (a.time == 5940000 && a.lrc.equals("纯音乐,请欣赏")) {
|
||||
if (LrcView.mLrcEntryList.size() <= 3) {
|
||||
for (LrcEntry a : LrcView.mLrcEntryList) {
|
||||
if (a.time == 5940000 && a.text.equals("纯音乐,请欣赏")) {
|
||||
text = "纯音乐,请欣赏";
|
||||
binding.lrctext.setText(text);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
LrcView.LRC currentLrc = LrcView.lrclist.get(index);
|
||||
text = currentLrc.lrc;
|
||||
if (currentLrc.tlyric != null) {
|
||||
text += "\n" + currentLrc.tlyric;
|
||||
LrcEntry currentLrc = LrcView.mLrcEntryList.get(index);
|
||||
text = currentLrc.text;
|
||||
if (currentLrc.secondText != null) {
|
||||
text += "\n" + currentLrc.secondText;
|
||||
}
|
||||
binding.lrctext.setText(text);
|
||||
}
|
||||
|
|
|
@ -1,449 +0,0 @@
|
|||
package com.muqingbfq.view;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearSmoothScroller;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.muqingbfq.R;
|
||||
import com.muqingbfq.databinding.ViewLrcBinding;
|
||||
import com.muqingbfq.main;
|
||||
import com.muqingbfq.mq.gj;
|
||||
import com.muqingbfq.yc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LrcView extends RecyclerView {
|
||||
|
||||
public static List<LRC> lrclist = new ArrayList<>();
|
||||
|
||||
View.OnClickListener onClickListener;
|
||||
|
||||
@Override
|
||||
public void setOnClickListener(@Nullable OnClickListener l) {
|
||||
onClickListener = l;
|
||||
super.setOnClickListener(l);
|
||||
}
|
||||
|
||||
public static class LRC {
|
||||
public String lrc, tlyric;
|
||||
public long time;
|
||||
|
||||
public LRC(String lrc, long time) {
|
||||
this.lrc = lrc;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
LRC lrc = (LRC) obj;
|
||||
return time == lrc.time;
|
||||
}
|
||||
|
||||
public LRC setTlyric(String str) {
|
||||
this.tlyric = str;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return java.util.Objects.hash(time);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public LrcView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
AttributeSet attrs;
|
||||
boolean Lrcline;
|
||||
LinearLayoutManager linearLayoutManager;
|
||||
|
||||
public LrcView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
this.attrs = attrs;
|
||||
init();
|
||||
}
|
||||
|
||||
public LrcView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
this.attrs = attrs;
|
||||
init();
|
||||
}
|
||||
|
||||
public void setTextColor(int textColor) {
|
||||
TextColor = textColor;
|
||||
}
|
||||
|
||||
public void setTextColor(String textColor) {
|
||||
TextColor = Color.parseColor(textColor);
|
||||
}
|
||||
|
||||
public void setLrcline(boolean lrcline) {
|
||||
Lrcline = lrcline;
|
||||
if (lrcline) {
|
||||
removeItemDecoration(ItemDecoration);
|
||||
/* addItemDecoration(new ItemDecoration() {
|
||||
@Override
|
||||
public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull State state) {
|
||||
super.onDraw(c, parent, state);
|
||||
}
|
||||
});*/
|
||||
} else {
|
||||
addItemDecoration(ItemDecoration);
|
||||
}
|
||||
}
|
||||
|
||||
private final RecyclerView.ItemDecoration ItemDecoration = new ItemDecoration() {
|
||||
@Override
|
||||
public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
view.setOnClickListener(onClickListener);
|
||||
|
||||
int parentHeight = parent.getHeight();
|
||||
int childHeight = view.getHeight();
|
||||
|
||||
int topMargin = (parentHeight - childHeight) / 2;
|
||||
|
||||
// 设置第一项的顶部间距
|
||||
if (parent.getChildAdapterPosition(view) == 0) {
|
||||
outRect.top = topMargin;
|
||||
}
|
||||
}
|
||||
};
|
||||
public android.os.Handler handler = new Handler(Looper.getMainLooper());
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private void init() {
|
||||
if (attrs != null) {
|
||||
TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.LrcView);
|
||||
TextColor = ta.getColor(R.styleable.LrcView_TextColor,
|
||||
ContextCompat.getColor(getContext(), R.color.text));
|
||||
Lrcline = ta.getBoolean(R.styleable.LrcView_Lrcline, true);
|
||||
addOnGlobalLayoutListener = ta.
|
||||
getBoolean(R.styleable.LrcView_addOnGlobalLayoutListener, false);
|
||||
ta.recycle();
|
||||
}
|
||||
linearLayoutManager = new LinearLayoutManager(getContext()) {
|
||||
@Override
|
||||
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
|
||||
RecyclerView.SmoothScroller smoothScroller = new CenterSmoothScroller(recyclerView.getContext());
|
||||
smoothScroller.setTargetPosition(position);
|
||||
startSmoothScroll(smoothScroller);
|
||||
}
|
||||
|
||||
};
|
||||
setLayoutManager(linearLayoutManager);
|
||||
setAdapter(new adaper());
|
||||
setForeground(null);
|
||||
setOverScrollMode(RecyclerView.OVER_SCROLL_NEVER);
|
||||
setLrcline(Lrcline);
|
||||
addOnScrollListener(new OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
// 判断滚动状态
|
||||
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
|
||||
// 正在拖动中
|
||||
// 执行相应的操作
|
||||
tuodong = true;
|
||||
} else if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
// 停止拖动
|
||||
// 执行相应的操作
|
||||
main.handler.postDelayed(() -> tuodong = false, 3000);
|
||||
}
|
||||
}
|
||||
});
|
||||
// setItemAnimator(null);
|
||||
}
|
||||
|
||||
private static class CenterSmoothScroller extends LinearSmoothScroller {
|
||||
|
||||
CenterSmoothScroller(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculateDtToFit(int viewStart, int viewEnd, int boxStart, int boxEnd, int snapPreference) {
|
||||
return (boxStart + (boxEnd - boxStart) / 2) - (viewStart + (viewEnd - viewStart) / 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float calculateSpeedPerPixel(DisplayMetrics displayMetrics) {
|
||||
return 50f / displayMetrics.densityDpi;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setLrc(String a, String b) {
|
||||
try {
|
||||
lrclist.clear();
|
||||
setLrc(a);
|
||||
setLrc(b);
|
||||
} catch (Exception e) {
|
||||
yc.start("LrcView setLrc :" + e + a + b);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setLrc(String a) {
|
||||
// 去除空格
|
||||
if (TextUtils.isEmpty(a)) {
|
||||
return;
|
||||
}
|
||||
a.trim();
|
||||
String[] lines = a.split("\n");
|
||||
for (String line : lines) {
|
||||
String[] parts = line.split("]");
|
||||
if (parts.length >= 2) {
|
||||
String timeString = parts[0].substring(1);
|
||||
String lyric = parts[1].trim();
|
||||
String[] timeParts = timeString.split(":");
|
||||
if (timeParts.length >= 2) {
|
||||
int minute = Integer.parseInt(timeParts[0]);
|
||||
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;
|
||||
LRC lrc = new LRC(lyric, time);
|
||||
if (lrclist.contains(lrc)) {
|
||||
int index = lrclist.indexOf(lrc);
|
||||
lrclist.get(index).setTlyric(lyric);
|
||||
} else {
|
||||
lrclist.add(lrc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent e) {
|
||||
if (!Lrcline) {
|
||||
return super.onTouchEvent(e);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int index = -1;
|
||||
int size = 20;
|
||||
|
||||
public void setSize(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
float alpha = 1.0f;
|
||||
|
||||
@Override
|
||||
public void setAlpha(float alpha) {
|
||||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
boolean addOnGlobalLayoutListener;
|
||||
|
||||
class adaper extends RecyclerView.Adapter<VH> {
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View inflate = LayoutInflater.from(getContext()).inflate(R.layout.view_lrc, parent, false);
|
||||
return new VH(ViewLrcBinding.bind(inflate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull VH holder, int position) {
|
||||
TextView textView = holder.binding.text;
|
||||
textView.setTextColor(TextColor);
|
||||
textView.setTextSize(
|
||||
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, size,
|
||||
getResources().getDisplayMetrics()));
|
||||
textView.setAlpha(alpha);
|
||||
holder.itemView.setOnClickListener(LrcView.this.onClickListener);
|
||||
if (Lrcline) {
|
||||
if (addOnGlobalLayoutListener) {
|
||||
// 注册布局监听器
|
||||
textView.getViewTreeObserver().addOnGlobalLayoutListener(
|
||||
new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
int height = textView.getHeight();
|
||||
ViewGroup.LayoutParams layoutParams = LrcView.this.getLayoutParams();
|
||||
layoutParams.height = height * 5;
|
||||
LrcView.this.setLayoutParams(layoutParams);
|
||||
// 移除布局监听器
|
||||
textView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (lrclist.isEmpty()) {
|
||||
textView.setText("纯音乐,请欣赏");
|
||||
return;
|
||||
}
|
||||
int currentLineIndex = getCurrentLineIndex();
|
||||
if (currentLineIndex < lrclist.size()) {
|
||||
|
||||
String text;
|
||||
if (lrclist.size() <= 5) {
|
||||
for (LRC a : lrclist) {
|
||||
if (a.time == 5940000 && a.lrc.equals("纯音乐,请欣赏")) {
|
||||
text = "纯音乐,请欣赏";
|
||||
textView.setText(text);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
LRC currentLrc = lrclist.get(currentLineIndex);
|
||||
text = currentLrc.lrc;
|
||||
if (currentLrc.tlyric != null) {
|
||||
text += "\n" + currentLrc.tlyric;
|
||||
}
|
||||
textView.setText(text);
|
||||
}
|
||||
} else {
|
||||
if (lrclist.isEmpty()) {
|
||||
textView.setText("纯音乐,请欣赏");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
LRC lrc = lrclist.get(position);
|
||||
StringBuilder stringBuffer = new StringBuilder();
|
||||
stringBuffer.append(lrc.lrc);
|
||||
if (lrc.tlyric != null) {
|
||||
stringBuffer.append("\n").append(lrc.tlyric);
|
||||
}
|
||||
stringBuffer.append("\n");
|
||||
textView.setAlpha(0.1f);
|
||||
if (getCurrentLineIndex(time) == position) {
|
||||
textView.setAlpha(1.0f);
|
||||
}
|
||||
textView.setText(stringBuffer.toString());
|
||||
} catch (Exception e) {
|
||||
gj.sc("LrcView.ADAPER.onBindViewHolder" + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (lrclist.size() < 3) {
|
||||
for (LRC a : lrclist) {
|
||||
if (a.time == 5940000 && a.lrc.equals("纯音乐,请欣赏")) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Lrcline) {
|
||||
return 1;
|
||||
}
|
||||
if (lrclist.isEmpty()) {
|
||||
return 1;
|
||||
}
|
||||
return lrclist.size();
|
||||
}
|
||||
}
|
||||
|
||||
class VH extends RecyclerView.ViewHolder {
|
||||
ViewLrcBinding binding;
|
||||
|
||||
public VH(@NonNull ViewLrcBinding itemView) {
|
||||
super(itemView.getRoot());
|
||||
binding = itemView;
|
||||
}
|
||||
}
|
||||
|
||||
private int getCurrentLineIndex() {
|
||||
index = 0;
|
||||
for (int i = 0; i < lrclist.size(); i++) {
|
||||
LRC lineLrc = lrclist.get(i);
|
||||
if (lineLrc.time <= time) {
|
||||
index = i;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
private static int getCurrentLineIndex(long time) {
|
||||
int index = 0;
|
||||
for (int i = 0; i < lrclist.size(); i++) {
|
||||
LRC lineLrc = lrclist.get(i);
|
||||
if (lineLrc.time <= time) {
|
||||
index = i;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
int TextColor;
|
||||
long time;
|
||||
|
||||
//是否在拖动
|
||||
boolean tuodong = false;
|
||||
|
||||
Runnable runnable = () -> {
|
||||
|
||||
};
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void setTimeLrc(long a) {
|
||||
if (tuodong) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.time = a;
|
||||
int index = getCurrentLineIndex(a);
|
||||
if (this.index == index) {
|
||||
return;
|
||||
}
|
||||
if (!Lrcline) {
|
||||
getAdapter().notifyDataSetChanged();
|
||||
// smoothScrollToPosition(getCurrentLineIndex(a));
|
||||
linearLayoutManager.smoothScrollToPosition(this,
|
||||
new RecyclerView.State(), index);
|
||||
return;
|
||||
}
|
||||
getAdapter().notifyDataSetChanged();
|
||||
} catch (Exception e) {
|
||||
gj.sc(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static long getTime(String min, String sec, String mills) {
|
||||
return Long.parseLong(min) * 60 * 1000 + Long.parseLong(sec) * 1000 + Long.parseLong(mills);
|
||||
}
|
||||
}
|
|
@ -66,11 +66,10 @@
|
|||
app:cardCornerRadius="16dp"
|
||||
app:cardUseCompatPadding="true" />
|
||||
</RelativeLayout>
|
||||
<com.muqingbfq.view.LrcView
|
||||
<me.wcy.lrcview.LrcView
|
||||
android:id="@+id/lrcView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:Lrcline="false"
|
||||
android:layout_weight="1"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:background="?android:colorBackground"
|
||||
android:orientation="vertical">
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
|
@ -65,11 +66,10 @@
|
|||
app:cardUseCompatPadding="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
<com.muqingbfq.view.LrcView
|
||||
<me.wcy.lrcview.LrcView
|
||||
android:id="@+id/lrcView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:addOnGlobalLayoutListener="true"
|
||||
android:layout_weight="2"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@drawable/background">
|
||||
android:background="@color/bj">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -17,3 +17,4 @@ dependencyResolutionManagement {
|
|||
rootProject.name = "Cloud_music"
|
||||
include ':app'
|
||||
include(':StatusBarUtil')
|
||||
include(":lrcview")
|
Loading…
Reference in New Issue
Block a user