修复专辑图只显示一个的问题
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;
|
||||
KProgressHUD hud;
|
||||
List<MusicData> list;
|
||||
Map<String, Bitmap> icons;
|
||||
Context context;
|
||||
|
||||
public MusicLibsAdapter(Context context, int model) {
|
||||
super(context, R.layout.layout_music_libs_item);
|
||||
list = new ArrayList<>();
|
||||
icons = new HashMap<>();
|
||||
this.context = context;
|
||||
initData(model, true);
|
||||
}
|
||||
@ -247,13 +245,7 @@ public class MusicLibsAdapter extends ArrayAdapter<MusicData> {
|
||||
holder.artist.setVisibility(View.GONE);
|
||||
}
|
||||
// holder.icon.setImageBitmap(ThumbnailUtils.extractThumbnail(data.getImg(), 64,64));
|
||||
if (icons.containsKey(data.getFile())) {
|
||||
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() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -398,8 +390,7 @@ public class MusicLibsAdapter extends ArrayAdapter<MusicData> {
|
||||
musicData.getImg(-1, -1, new NetworkInterface() {
|
||||
@Override
|
||||
public void httpGetData(Object data, int state) {
|
||||
icons.put(musicData.getFile(), (Bitmap) data);
|
||||
Glide.with(getContext()).load(icons.get(musicData.getFile()))
|
||||
Glide.with(getContext()).load((Bitmap) data)
|
||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(25, 3)))
|
||||
.into(holder.icon);
|
||||
System.out.println("展示图片:" + state);
|
||||
@ -413,10 +404,6 @@ public class MusicLibsAdapter extends ArrayAdapter<MusicData> {
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
for (String integer : icons.keySet()) {
|
||||
Objects.requireNonNull(icons.get(integer)).recycle();
|
||||
}
|
||||
icons.clear();
|
||||
}
|
||||
|
||||
public void setData(List<MusicData> list) {
|
||||
|
@ -277,6 +277,16 @@ public class MusicData {
|
||||
public void onDownloadOver(File oldJar) {
|
||||
AppTools.saveBitmap(oldJar, imageSaveName);
|
||||
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
|
||||
|
@ -114,9 +114,6 @@ public class NetworkTool {
|
||||
connection.setConnectTimeout(50);
|
||||
connection.setReadTimeout(50);
|
||||
connection.connect();
|
||||
InputStream inputStream = connection.getErrorStream();
|
||||
System.out.println(inputStream.read());
|
||||
inputStream.close();
|
||||
System.out.println(connection.getResponseCode());
|
||||
networkInterface.httpGetData(null, 0);
|
||||
connection.disconnect();
|
||||
|
@ -8,6 +8,7 @@ import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.support.v4.media.MediaMetadataCompat;
|
||||
import android.support.v4.media.session.MediaControllerCompat;
|
||||
import android.support.v4.media.session.MediaSessionCompat;
|
||||
@ -58,7 +59,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setBarColor(android.R.color.transparent);
|
||||
setContentView(R.layout.activity_main);
|
||||
handler = new Handler();
|
||||
handler = new Handler(Looper.myLooper());
|
||||
initView();
|
||||
play.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -7,7 +7,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
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"
|
||||
|
||||
|
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-6.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
|
||||
|
Loading…
Reference in New Issue
Block a user