修复专辑图只显示一个的问题
This commit is contained in:
parent
249568aa11
commit
f38486e59a
@ -52,13 +52,11 @@ public class MusicLibsAdapter extends ArrayAdapter<MusicData> {
|
|||||||
public static final int LIBS_MODEL_PLAY_Collection = 5;
|
public static final int LIBS_MODEL_PLAY_Collection = 5;
|
||||||
KProgressHUD hud;
|
KProgressHUD hud;
|
||||||
List<MusicData> list;
|
List<MusicData> list;
|
||||||
Map<String, Bitmap> icons;
|
|
||||||
Context context;
|
Context context;
|
||||||
|
|
||||||
public MusicLibsAdapter(Context context, int model) {
|
public MusicLibsAdapter(Context context, int model) {
|
||||||
super(context, R.layout.layout_music_libs_item);
|
super(context, R.layout.layout_music_libs_item);
|
||||||
list = new ArrayList<>();
|
list = new ArrayList<>();
|
||||||
icons = new HashMap<>();
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
initData(model, true);
|
initData(model, true);
|
||||||
}
|
}
|
||||||
@ -247,13 +245,7 @@ public class MusicLibsAdapter extends ArrayAdapter<MusicData> {
|
|||||||
holder.artist.setVisibility(View.GONE);
|
holder.artist.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
// holder.icon.setImageBitmap(ThumbnailUtils.extractThumbnail(data.getImg(), 64,64));
|
// holder.icon.setImageBitmap(ThumbnailUtils.extractThumbnail(data.getImg(), 64,64));
|
||||||
if (icons.containsKey(data.getFile())) {
|
showImage(data, holder);
|
||||||
Glide.with(getContext()).load(icons.get(data.getFile()))
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(25, 3)))
|
|
||||||
.into(holder.icon);
|
|
||||||
} else {
|
|
||||||
showImage(data, holder);
|
|
||||||
}
|
|
||||||
holder.icon.setOnClickListener(new View.OnClickListener() {
|
holder.icon.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@ -398,8 +390,7 @@ public class MusicLibsAdapter extends ArrayAdapter<MusicData> {
|
|||||||
musicData.getImg(-1, -1, new NetworkInterface() {
|
musicData.getImg(-1, -1, new NetworkInterface() {
|
||||||
@Override
|
@Override
|
||||||
public void httpGetData(Object data, int state) {
|
public void httpGetData(Object data, int state) {
|
||||||
icons.put(musicData.getFile(), (Bitmap) data);
|
Glide.with(getContext()).load((Bitmap) data)
|
||||||
Glide.with(getContext()).load(icons.get(musicData.getFile()))
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(25, 3)))
|
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(25, 3)))
|
||||||
.into(holder.icon);
|
.into(holder.icon);
|
||||||
System.out.println("展示图片:" + state);
|
System.out.println("展示图片:" + state);
|
||||||
@ -413,10 +404,6 @@ public class MusicLibsAdapter extends ArrayAdapter<MusicData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
for (String integer : icons.keySet()) {
|
|
||||||
Objects.requireNonNull(icons.get(integer)).recycle();
|
|
||||||
}
|
|
||||||
icons.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(List<MusicData> list) {
|
public void setData(List<MusicData> list) {
|
||||||
|
@ -136,10 +136,10 @@ public class MusicData {
|
|||||||
if (StringUtil.isEmpty(track)) {
|
if (StringUtil.isEmpty(track)) {
|
||||||
return "0";
|
return "0";
|
||||||
}
|
}
|
||||||
try{
|
try {
|
||||||
Integer.parseInt(track);
|
Integer.parseInt(track);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
return track.substring(0,1);
|
return track.substring(0, 1);
|
||||||
}
|
}
|
||||||
return track;
|
return track;
|
||||||
}
|
}
|
||||||
@ -152,10 +152,10 @@ public class MusicData {
|
|||||||
if (StringUtil.isEmpty(disc_no)) {
|
if (StringUtil.isEmpty(disc_no)) {
|
||||||
return "0";
|
return "0";
|
||||||
}
|
}
|
||||||
try{
|
try {
|
||||||
Integer.parseInt(disc_no);
|
Integer.parseInt(disc_no);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
return disc_no.substring(0,1);
|
return disc_no.substring(0, 1);
|
||||||
}
|
}
|
||||||
return disc_no;
|
return disc_no;
|
||||||
}
|
}
|
||||||
@ -208,12 +208,12 @@ public class MusicData {
|
|||||||
public String getFileBase64() {
|
public String getFileBase64() {
|
||||||
if (StringUtil.isEmpty(file))
|
if (StringUtil.isEmpty(file))
|
||||||
return null;
|
return null;
|
||||||
return AppTools.getUrlBase64(file);
|
return AppTools.getUrlBase64(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getPlayUrl() {
|
public String getPlayUrl() {
|
||||||
System.out.println("播放地址:"+NetworkTool.NetworkAPI.HOME + NetworkTool.NetworkAPI.MUSIC_PLAY
|
System.out.println("播放地址:" + NetworkTool.NetworkAPI.HOME + NetworkTool.NetworkAPI.MUSIC_PLAY
|
||||||
+ "?random=false&token=" + NetworkTool.NetworkAPI.HTTP_KEY + "&filePath=" + getFileBase64());
|
+ "?random=false&token=" + NetworkTool.NetworkAPI.HTTP_KEY + "&filePath=" + getFileBase64());
|
||||||
return NetworkTool.NetworkAPI.HOME + NetworkTool.NetworkAPI.MUSIC_PLAY
|
return NetworkTool.NetworkAPI.HOME + NetworkTool.NetworkAPI.MUSIC_PLAY
|
||||||
+ "?random=false&token=" + NetworkTool.NetworkAPI.HTTP_KEY + "&filePath=" + getFileBase64();
|
+ "?random=false&token=" + NetworkTool.NetworkAPI.HTTP_KEY + "&filePath=" + getFileBase64();
|
||||||
@ -221,7 +221,7 @@ public class MusicData {
|
|||||||
|
|
||||||
|
|
||||||
public String getImageUrl() {
|
public String getImageUrl() {
|
||||||
return NetworkTool.NetworkAPI.MUSIC_IMAGE + "?fileName=" +getFileBase64();
|
return NetworkTool.NetworkAPI.MUSIC_IMAGE + "?fileName=" + getFileBase64();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Bitmap getImg() {
|
public Bitmap getImg() {
|
||||||
@ -246,11 +246,11 @@ public class MusicData {
|
|||||||
if (isDownloadImg) {
|
if (isDownloadImg) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (StringUtil.isEmpty(file)&&StringUtil.isEmpty(title)&&StringUtil.isEmpty(album)) {
|
if (StringUtil.isEmpty(file) && StringUtil.isEmpty(title) && StringUtil.isEmpty(album)) {
|
||||||
img = BitmapFactory.decodeResource(MyApplication.application.getResources(), R.mipmap.ic_launcher);
|
img = BitmapFactory.decodeResource(MyApplication.application.getResources(), R.mipmap.ic_launcher);
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
String imageSaveName=(StringUtil.isEmpty(album)?title:album)+".png";
|
String imageSaveName = (StringUtil.isEmpty(album) ? title : album) + ".png";
|
||||||
img = AppTools.getSaveBitmap(imageSaveName);
|
img = AppTools.getSaveBitmap(imageSaveName);
|
||||||
if (img != null) {
|
if (img != null) {
|
||||||
if (width == -1 && height == -1) {
|
if (width == -1 && height == -1) {
|
||||||
@ -265,18 +265,28 @@ public class MusicData {
|
|||||||
img = null;
|
img = null;
|
||||||
isDownloadImg = true;
|
isDownloadImg = true;
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
if(StringUtil.isEmpty(getAlbum())) {
|
if (StringUtil.isEmpty(getAlbum())) {
|
||||||
json.put("fileName", getFile());
|
json.put("fileName", getFile());
|
||||||
}else{
|
} else {
|
||||||
json.put("fileName",AppTools.getUrlBase64(getAlbum()));
|
json.put("fileName", AppTools.getUrlBase64(getAlbum()));
|
||||||
json.put("type","album");
|
json.put("type", "album");
|
||||||
}
|
}
|
||||||
System.out.println("下载图片:"+ NetworkTool.NetworkAPI.MUSIC_IMAGE+"?"+NetworkTool.toGetSplice(json));
|
System.out.println("下载图片:" + NetworkTool.NetworkAPI.MUSIC_IMAGE + "?" + NetworkTool.toGetSplice(json));
|
||||||
NetworkTool.init().downloadImage(NetworkTool.NetworkAPI.MUSIC_IMAGE,json, imageSaveName,"post", new DownloadInterface() {
|
NetworkTool.init().downloadImage(NetworkTool.NetworkAPI.MUSIC_IMAGE, json, imageSaveName, "post", new DownloadInterface() {
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadOver(File oldJar) {
|
public void onDownloadOver(File oldJar) {
|
||||||
AppTools.saveBitmap(oldJar,imageSaveName);
|
AppTools.saveBitmap(oldJar, imageSaveName);
|
||||||
img=BitmapFactory.decodeFile(oldJar.getAbsolutePath());
|
img = BitmapFactory.decodeFile(oldJar.getAbsolutePath());
|
||||||
|
AppData.handler.post(() -> {
|
||||||
|
if (width == -1 && height == -1) {
|
||||||
|
if (networkInterface != null)
|
||||||
|
networkInterface.httpGetData(img, 0);
|
||||||
|
} else {
|
||||||
|
if (networkInterface != null)
|
||||||
|
networkInterface.httpGetData(ThumbnailUtils.extractThumbnail(img, width, height), width + height);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -114,9 +114,6 @@ public class NetworkTool {
|
|||||||
connection.setConnectTimeout(50);
|
connection.setConnectTimeout(50);
|
||||||
connection.setReadTimeout(50);
|
connection.setReadTimeout(50);
|
||||||
connection.connect();
|
connection.connect();
|
||||||
InputStream inputStream = connection.getErrorStream();
|
|
||||||
System.out.println(inputStream.read());
|
|
||||||
inputStream.close();
|
|
||||||
System.out.println(connection.getResponseCode());
|
System.out.println(connection.getResponseCode());
|
||||||
networkInterface.httpGetData(null, 0);
|
networkInterface.httpGetData(null, 0);
|
||||||
connection.disconnect();
|
connection.disconnect();
|
||||||
|
@ -8,6 +8,7 @@ import android.annotation.SuppressLint;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.support.v4.media.MediaMetadataCompat;
|
import android.support.v4.media.MediaMetadataCompat;
|
||||||
import android.support.v4.media.session.MediaControllerCompat;
|
import android.support.v4.media.session.MediaControllerCompat;
|
||||||
import android.support.v4.media.session.MediaSessionCompat;
|
import android.support.v4.media.session.MediaSessionCompat;
|
||||||
@ -58,7 +59,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setBarColor(android.R.color.transparent);
|
setBarColor(android.R.color.transparent);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
handler = new Handler();
|
handler = new Handler(Looper.myLooper());
|
||||||
initView();
|
initView();
|
||||||
play.setOnClickListener(new View.OnClickListener() {
|
play.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -7,7 +7,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.0'
|
classpath 'com.android.tools.build:gradle:4.2.1'
|
||||||
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
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
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
|
||||||
|
Loading…
Reference in New Issue
Block a user