Skip to content

Commit dfa6cd7

Browse files
committed
Add now playing artwork fallback
1 parent fb63346 commit dfa6cd7

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

app/src/main/java/de/maniac103/squeezeclient/extfuncs/ViewExtensions.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import android.view.View
2222
import android.widget.ImageView
2323
import androidx.appcompat.app.AlertDialog
2424
import androidx.constraintlayout.motion.widget.MotionLayout
25-
import androidx.core.content.ContextCompat
2625
import androidx.core.view.ViewCompat
2726
import androidx.core.view.WindowInsetsCompat
2827
import androidx.core.view.updatePadding
@@ -51,7 +50,8 @@ fun ImageView.loadArtworkOrPlaceholder(
5150
item: ArtworkItem?,
5251
builder: ImageRequest.Builder.() -> Unit = {}
5352
) = loadArtwork(item) {
54-
placeholder(ContextCompat.getDrawable(context, R.drawable.ic_disc_24dp))
53+
placeholder(R.drawable.ic_disc_24dp)
54+
fallback(R.drawable.ic_disc_24dp)
5555
builder()
5656
}
5757

app/src/main/java/de/maniac103/squeezeclient/ui/nowplaying/NowPlayingFragment.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,14 +375,15 @@ class NowPlayingFragment :
375375
if (currentSong == null) {
376376
binding.container.transitionToState(R.id.collapsed)
377377
binding.container.isInteractionEnabled = false
378+
binding.artwork.setImageDrawable(null)
378379
} else {
379380
binding.container.isInteractionEnabled = true
381+
binding.artwork.loadArtwork(currentSong) {
382+
fallback(R.drawable.ic_album_placeholder)
383+
size(Size.ORIGINAL)
384+
}
380385
}
381386

382-
binding.artwork.loadArtwork(currentSong) {
383-
// TODO: placeholder?
384-
size(Size.ORIGINAL)
385-
}
386387
listOf(binding.title, binding.titleMinimized).forEach {
387388
it.text = currentSong?.title ?: getString(R.string.nowplaying_empty_playlist)
388389
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ This file is part of Squeeze Client, an Android client for the LMS music server.
4+
~ Copyright (c) 2024 Danny Baumann
5+
~
6+
~ This program is free software: you can redistribute it and/or modify it under the terms of the
7+
~ GNU General Public License as published by the Free Software Foundation,
8+
~ either version 3 of the License, or (at your option) any later version.
9+
~
10+
~ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11+
~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
~ See the GNU General Public License for more details.
13+
~
14+
~ You should have received a copy of the GNU General Public License along with this program.
15+
~ If not, see <http://www.gnu.org/licenses/>.
16+
~
17+
-->
18+
19+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
20+
android:width="96dp"
21+
android:height="96dp"
22+
android:tint="?colorControlActivated"
23+
android:viewportWidth="24"
24+
android:viewportHeight="24">
25+
<path
26+
android:fillColor="#FF000000"
27+
android:pathData="M12,11.05A0.95,0.95 0,0 0,11.05 12,0.95 0.95,0 0,0 12,12.95 0.95,0.95 0,0 0,12.95 12,0.95 0.95,0 0,0 12,11.05m0,5.225c-2.375,0 -4.275,-1.9 -4.275,-4.275 0,-2.375 1.9,-4.275 4.275,-4.275 2.375,0 4.275,1.9 4.275,4.275 0,2.375 -1.9,4.275 -4.275,4.275M12,2.5A9.5,9.5 0,0 0,2.5 12,9.5 9.5,0 0,0 12,21.5 9.5,9.5 0,0 0,21.5 12,9.5 9.5,0 0,0 12,2.5Z" />
28+
<path
29+
android:pathData="M4,1L20,1A3,3 0,0 1,23 4L23,20A3,3 0,0 1,20 23L4,23A3,3 0,0 1,1 20L1,4A3,3 0,0 1,4 1z"
30+
android:strokeWidth="1"
31+
android:strokeColor="#FF000000" />
32+
</vector>

app/src/main/res/layout/fragment_nowplaying.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@
100100
android:padding="4dp"
101101
app:layout_constraintDimensionRatio="1:1"
102102
app:layout_constraintEnd_toEndOf="parent"
103-
app:layout_constraintStart_toStartOf="parent" />
103+
app:layout_constraintStart_toStartOf="parent"
104+
tools:src="@drawable/ic_album_placeholder" />
104105

105106
<TextView
106107
android:id="@+id/title"

0 commit comments

Comments
 (0)