diff --git a/ultrasonic/src/main/java/org/moire/ultrasonic/util/ImageLoader.java b/ultrasonic/src/main/java/org/moire/ultrasonic/util/ImageLoader.java index 9624301e..d45c67b2 100644 --- a/ultrasonic/src/main/java/org/moire/ultrasonic/util/ImageLoader.java +++ b/ultrasonic/src/main/java/org/moire/ultrasonic/util/ImageLoader.java @@ -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); diff --git a/ultrasonic/src/main/java/org/moire/ultrasonic/util/LegacyImageLoader.java b/ultrasonic/src/main/java/org/moire/ultrasonic/util/LegacyImageLoader.java index 8da92508..e6370f39 100644 --- a/ultrasonic/src/main/java/org/moire/ultrasonic/util/LegacyImageLoader.java +++ b/ultrasonic/src/main/java/org/moire/ultrasonic/util/LegacyImageLoader.java @@ -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); } } } diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/activity/ArtistRowAdapter.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/activity/ArtistRowAdapter.kt index e710c288..4504ea63 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/activity/ArtistRowAdapter.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/activity/ArtistRowAdapter.kt @@ -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 diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/subsonic/SubsonicImageLoaderProxy.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/subsonic/SubsonicImageLoaderProxy.kt index 90f33a17..6d0d2b99 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/subsonic/SubsonicImageLoaderProxy.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/subsonic/SubsonicImageLoaderProxy.kt @@ -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 ) diff --git a/ultrasonic/src/main/res/layout/artist_list_item.xml b/ultrasonic/src/main/res/layout/artist_list_item.xml index fd7009f9..26a4d7a1 100644 --- a/ultrasonic/src/main/res/layout/artist_list_item.xml +++ b/ultrasonic/src/main/res/layout/artist_list_item.xml @@ -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" /> + 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" /> \ No newline at end of file