与服务器通讯由文件名改成MD5
修复专辑界面会闪退的问题
This commit is contained in:
parent
aedda7b297
commit
20b80d380a
@ -13,7 +13,6 @@ android {
|
||||
}
|
||||
}
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.2"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.yutou.nas_music_player"
|
||||
|
@ -223,10 +223,10 @@ public class MusicData {
|
||||
|
||||
|
||||
public String getPlayUrl() {
|
||||
System.out.println("播放地址:" + HttpManager.NetworkAPI.HOME + HttpManager.NetworkAPI.MUSIC_PLAY
|
||||
+ "?random=false&token=" + HttpManager.NetworkAPI.HTTP_KEY + "&filePath=" + getFileBase64());
|
||||
return HttpManager.NetworkAPI.HOME + HttpManager.NetworkAPI.MUSIC_PLAY
|
||||
+ "?random=false&token=" + HttpManager.NetworkAPI.HTTP_KEY + "&filePath=" + getFileBase64();
|
||||
String url= HttpManager.NetworkAPI.HOME + HttpManager.NetworkAPI.MUSIC_PLAY
|
||||
+ "?random=false&token=" + HttpManager.NetworkAPI.HTTP_KEY + "&filePath=" + getMd5();
|
||||
System.out.println("播放地址:" +url);
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ public class PreviousPlayerList {
|
||||
public void add(MusicData musicData){
|
||||
MusicData tmp = null;
|
||||
for (MusicData data : list) {
|
||||
if(data.getFile().equals(musicData.getFile())){
|
||||
if(data.getMd5().equals(musicData.getMd5())){
|
||||
tmp=data;
|
||||
}
|
||||
|
||||
|
@ -304,12 +304,13 @@ public class MusicContainer {
|
||||
}
|
||||
|
||||
private MediaMetadataCompat metadataCompat;
|
||||
private String metaDataFile;
|
||||
private String metaDataFile="";
|
||||
|
||||
public MediaMetadataCompat getMetadataCompat(MusicData data) {
|
||||
if (data.getFile().equals(metaDataFile)) {
|
||||
if (data.getMd5().equals(metaDataFile)) {
|
||||
return metadataCompat;
|
||||
}
|
||||
metaDataFile=data.getMd5();
|
||||
MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
|
||||
builder.putString(MediaMetadataCompat.METADATA_KEY_MEDIA_ID, data.getTitle());
|
||||
builder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, data.getArtist());
|
||||
|
@ -28,6 +28,7 @@ import java.time.Duration;
|
||||
import java.time.temporal.TemporalUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -178,7 +179,11 @@ public class HttpManager {
|
||||
|
||||
@Override
|
||||
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
|
||||
networkInterface.httpGetData(response.body().string(), response.code());
|
||||
String body = response.body().string();
|
||||
int code = response.code();
|
||||
AppData.handler.post(() -> {
|
||||
networkInterface.httpGetData(body, code);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -311,7 +316,9 @@ public class HttpManager {
|
||||
Log.toast(MyApplication.application, "下载完成,重启生效");
|
||||
|
||||
if (downloadInterface != null) {
|
||||
AppData.handler.post(() -> {
|
||||
downloadInterface.onDownloadOver(oldJar);
|
||||
});
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -20,6 +20,7 @@ import com.yutou.nas_music_player.Interfaces.NetworkInterface;
|
||||
import com.yutou.nas_music_player.R;
|
||||
import com.yutou.nas_music_player.containers.MediaBrowserHelper;
|
||||
import com.yutou.nas_music_player.containers.MusicContainer;
|
||||
import com.yutou.nas_music_player.tools.AppData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -34,6 +35,7 @@ public class AlbumsActivity extends AppCompatActivity {
|
||||
private AppBarLayout appBarLayout;
|
||||
private TextView breakApp;
|
||||
private int model;//0 专辑, 1 歌手, 2 收藏
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -100,7 +102,10 @@ public class AlbumsActivity extends AppCompatActivity {
|
||||
public void httpGetData(Object data, int state) {
|
||||
List<MusicData> list = (List<MusicData>) data;
|
||||
adapter.setData(list);
|
||||
AppData.handler.post(() -> {
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
});
|
||||
list.get(0).getImg(-1, -1, new NetworkInterface() {
|
||||
@Override
|
||||
public void httpGetData(Object data, int state) {
|
||||
|
@ -7,7 +7,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.0.3'
|
||||
classpath 'com.android.tools.build:gradle:7.1.1'
|
||||
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||
|
Loading…
Reference in New Issue
Block a user