修复专辑图只显示一个的问题
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())) {
|
|
||||||
Glide.with(getContext()).load(icons.get(data.getFile()))
|
|
||||||
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(25, 3)))
|
|
||||||
.into(holder.icon);
|
|
||||||
} else {
|
|
||||||
showImage(data, holder);
|
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) {
|
||||||
|
@ -277,6 +277,16 @@ public class MusicData {
|
|||||||
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