parent
b3db46b1ab
commit
a3c4815a07
|
@ -13,23 +13,14 @@ public interface ImageLoader {
|
|||
|
||||
void stopImageLoader();
|
||||
|
||||
void loadAvatarImage(
|
||||
View view,
|
||||
String username,
|
||||
boolean large,
|
||||
int size,
|
||||
boolean crossFade,
|
||||
boolean highQuality
|
||||
);
|
||||
void loadAvatarImage(View view, String username, boolean large, int size, boolean crossFade,
|
||||
boolean highQuality);
|
||||
|
||||
void loadImage(
|
||||
View view,
|
||||
MusicDirectory.Entry entry,
|
||||
boolean large,
|
||||
int size,
|
||||
boolean crossFade,
|
||||
boolean highQuality
|
||||
);
|
||||
void loadImage(View view, MusicDirectory.Entry entry, boolean large, int size,
|
||||
boolean crossFade, boolean highQuality);
|
||||
|
||||
void loadImage(View view, MusicDirectory.Entry entry, boolean large, int size,
|
||||
boolean crossFade, boolean highQuality, int defaultResourceId);
|
||||
|
||||
void cancel(String coverArt);
|
||||
|
||||
|
|
|
@ -167,25 +167,24 @@ public class LegacyImageLoader implements Runnable, ImageLoader {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void loadImage(
|
||||
View view,
|
||||
MusicDirectory.Entry entry,
|
||||
boolean large,
|
||||
int size,
|
||||
boolean crossFade,
|
||||
boolean highQuality
|
||||
) {
|
||||
public void loadImage(View view, MusicDirectory.Entry entry, boolean large, int size,
|
||||
boolean crossFade, boolean highQuality) {
|
||||
loadImage(view, entry, large, size, crossFade, highQuality, -1);
|
||||
}
|
||||
|
||||
public void loadImage(View view, MusicDirectory.Entry entry, boolean large, int size,
|
||||
boolean crossFade, boolean highQuality, int defaultResourceId) {
|
||||
view.invalidate();
|
||||
|
||||
if (entry == null) {
|
||||
setUnknownImage(view, large);
|
||||
setUnknownImage(view, large, defaultResourceId);
|
||||
return;
|
||||
}
|
||||
|
||||
String coverArt = entry.getCoverArt();
|
||||
|
||||
if (TextUtils.isEmpty(coverArt)) {
|
||||
setUnknownImage(view, large);
|
||||
setUnknownImage(view, large, defaultResourceId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -200,7 +199,7 @@ public class LegacyImageLoader implements Runnable, ImageLoader {
|
|||
return;
|
||||
}
|
||||
|
||||
setUnknownImage(view, large);
|
||||
setUnknownImage(view, large, defaultResourceId);
|
||||
|
||||
queue.offer(new Task(view, entry, size, large, crossFade, highQuality));
|
||||
}
|
||||
|
@ -342,13 +341,18 @@ public class LegacyImageLoader implements Runnable, ImageLoader {
|
|||
}
|
||||
|
||||
private void setUnknownImage(View view, boolean large) {
|
||||
setUnknownImage(view, large, -1);
|
||||
}
|
||||
|
||||
private void setUnknownImage(View view, boolean large, int resId) {
|
||||
if (resId == -1) resId = R.drawable.unknown_album;
|
||||
if (large) {
|
||||
setImageBitmap(view, null, largeUnknownImage, false);
|
||||
} else {
|
||||
if (view instanceof TextView) {
|
||||
((TextView) view).setCompoundDrawablesWithIntrinsicBounds(R.drawable.unknown_album, 0, 0, 0);
|
||||
((TextView) view).setCompoundDrawablesWithIntrinsicBounds(resId, 0, 0, 0);
|
||||
} else if (view instanceof ImageView) {
|
||||
((ImageView) view).setImageResource(R.drawable.unknown_album);
|
||||
((ImageView) view).setImageResource(resId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ class ArtistRowAdapter(
|
|||
imageLoader.loadImage(
|
||||
holder.coverArt,
|
||||
MusicDirectory.Entry().apply { coverArt = holder.coverArtId },
|
||||
false, 0, false, true
|
||||
false, 0, false, true, R.drawable.ic_contact_picture
|
||||
)
|
||||
} else if (holder is HeaderViewHolder) {
|
||||
holder.folderName.text = folderName
|
||||
|
|
|
@ -26,18 +26,32 @@ class SubsonicImageLoaderProxy(
|
|||
size: Int,
|
||||
crossFade: Boolean,
|
||||
highQuality: Boolean
|
||||
) {
|
||||
return loadImage(view, entry, large, size, crossFade, highQuality, -1)
|
||||
}
|
||||
|
||||
override fun loadImage(
|
||||
view: View?,
|
||||
entry: MusicDirectory.Entry?,
|
||||
large: Boolean,
|
||||
size: Int,
|
||||
crossFade: Boolean,
|
||||
highQuality: Boolean,
|
||||
defaultResourceId: Int
|
||||
) {
|
||||
val id = entry?.coverArt
|
||||
val unknownImageId =
|
||||
if (defaultResourceId == -1) R.drawable.unknown_album
|
||||
else defaultResourceId
|
||||
|
||||
if (id != null &&
|
||||
view != null &&
|
||||
view is ImageView
|
||||
) {
|
||||
val request = ImageRequest.CoverArt(
|
||||
id,
|
||||
view,
|
||||
placeHolderDrawableRes = R.drawable.unknown_album,
|
||||
errorDrawableRes = R.drawable.unknown_album
|
||||
id, view,
|
||||
placeHolderDrawableRes = unknownImageId,
|
||||
errorDrawableRes = unknownImageId
|
||||
)
|
||||
subsonicImageLoader.load(request)
|
||||
}
|
||||
|
@ -56,8 +70,7 @@ class SubsonicImageLoaderProxy(
|
|||
view is ImageView
|
||||
) {
|
||||
val request = ImageRequest.Avatar(
|
||||
username,
|
||||
view,
|
||||
username, view,
|
||||
placeHolderDrawableRes = R.drawable.ic_contact_picture,
|
||||
errorDrawableRes = R.drawable.ic_contact_picture
|
||||
)
|
||||
|
|
|
@ -13,30 +13,31 @@
|
|||
a:layout_width="wrap_content"
|
||||
a:layout_height="wrap_content"
|
||||
a:gravity="center_horizontal|center_vertical"
|
||||
a:minWidth="72dip"
|
||||
a:minWidth="56dip"
|
||||
a:minHeight="56dip"
|
||||
a:paddingStart="16dip"
|
||||
a:paddingLeft="16dip"
|
||||
a:paddingEnd="16dip"
|
||||
a:paddingRight="16dip"
|
||||
a:paddingStart="8dip"
|
||||
a:paddingLeft="8dip"
|
||||
a:paddingEnd="8dip"
|
||||
a:paddingRight="8dip"
|
||||
a:text="A"
|
||||
a:textAppearance="?android:attr/textAppearanceLarge"
|
||||
a:textColor="@color/cyan" />
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
a:id="@+id/artist_coverart"
|
||||
a:src="@drawable/unknown_album"
|
||||
app:shapeAppearanceOverlay="@style/roundedImageView"
|
||||
a:layout_width="40dp"
|
||||
a:layout_height="40dp"
|
||||
a:layout_toEndOf="@+id/row_section"
|
||||
a:layout_toRightOf="@+id/row_section"
|
||||
a:layout_gravity="center_horizontal|center_vertical"
|
||||
a:layout_marginTop="8dp"
|
||||
a:layout_marginLeft="8dp"
|
||||
a:layout_marginRight="16dp"
|
||||
a:layout_marginStart="8dp"
|
||||
a:layout_marginEnd="16dp" />
|
||||
a:layout_marginStart="2dp"
|
||||
a:layout_marginLeft="2dp"
|
||||
a:layout_marginEnd="10dp"
|
||||
a:layout_marginRight="10dp"
|
||||
a:layout_toEndOf="@+id/row_section"
|
||||
a:layout_toRightOf="@+id/row_section"
|
||||
a:scaleType="fitCenter"
|
||||
a:src="@drawable/ic_contact_picture"
|
||||
app:shapeAppearanceOverlay="@style/roundedImageView" />
|
||||
|
||||
<TextView
|
||||
a:id="@+id/row_artist_name"
|
||||
|
@ -49,5 +50,7 @@
|
|||
a:minHeight="56dip"
|
||||
a:paddingLeft="3dip"
|
||||
a:paddingRight="3dip"
|
||||
a:layout_marginRight="12dp"
|
||||
a:layout_marginEnd="12dp"
|
||||
a:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
</RelativeLayout>
|
Loading…
Reference in New Issue