Skip to content

Commit 36ecfb6

Browse files
committed
Display song images in album/artist details page
Signed-off-by: Muntashir Al-Islam <muntashirakon@riseup.net>
1 parent 5e8dba4 commit 36ecfb6

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

app/src/main/java/io/github/muntashirakon/music/adapter/song/SimpleSongAdapter.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class SimpleSongAdapter(
4444
val trackAndTime = (if (fixedTrackNumber > 0) "$fixedTrackNumber | " else "") +
4545
MusicUtil.getReadableDurationString(dataSet[position].duration)
4646

47-
holder.imageText?.visibility = View.GONE
4847
holder.time?.text = trackAndTime
4948
holder.text2?.text = dataSet[position].artistName
5049
}

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

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,46 @@
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="@dimen/item_song_height"
7-
android:layout_marginStart="2dp"
8-
android:layout_marginEnd="2dp"
7+
android:layout_marginVertical="2dp"
8+
android:layout_marginHorizontal="2dp"
99
android:background="?rectSelector"
1010
android:clickable="true"
1111
android:focusable="true"
1212
android:orientation="horizontal">
1313

14-
<FrameLayout
14+
<com.google.android.material.card.MaterialCardView
1515
android:id="@+id/imageContainer"
1616
android:layout_width="wrap_content"
17-
android:layout_height="match_parent"
18-
android:layout_weight="0"
19-
android:paddingStart="8dp"
20-
android:paddingEnd="8dp"
17+
android:layout_height="wrap_content"
18+
android:layout_marginHorizontal="8dp"
19+
android:scaleType="centerCrop"
20+
app:cardCornerRadius="10dp"
21+
app:layout_constraintDimensionRatio="1:1"
2122
app:layout_constraintBottom_toBottomOf="parent"
2223
app:layout_constraintStart_toStartOf="parent"
2324
app:layout_constraintTop_toTopOf="parent">
2425

25-
<com.google.android.material.textview.MaterialTextView
26-
android:id="@+id/imageText"
27-
android:layout_width="40dp"
28-
android:layout_height="match_parent"
29-
android:gravity="center"
30-
android:maxLines="1"
31-
android:minHeight="40dp"
32-
android:textAppearance="@style/TextViewNormal"
33-
android:textColor="?android:attr/textColorSecondary"
34-
tools:text="@tools:sample/us_zipcodes" />
35-
</FrameLayout>
26+
<androidx.appcompat.widget.AppCompatImageView
27+
android:id="@+id/image"
28+
android:layout_width="45dp"
29+
android:layout_height="45dp"
30+
android:layout_gravity="center_vertical"
31+
android:gravity="center_vertical"
32+
android:scaleType="centerCrop"
33+
tools:ignore="ContentDescription"
34+
tools:srcCompat="@tools:sample/backgrounds/scenic" />
35+
36+
</com.google.android.material.card.MaterialCardView>
3637

3738
<com.google.android.material.textview.MaterialTextView
3839
android:id="@+id/title"
3940
android:layout_width="0dp"
4041
android:layout_height="wrap_content"
4142
android:layout_weight="1"
43+
android:layout_marginTop="12dp"
44+
android:layout_marginHorizontal="8dp"
4245
android:singleLine="true"
4346
android:ellipsize="marquee"
44-
android:paddingTop="8dp"
4547
android:textAppearance="@style/TextViewBody2"
4648
app:layout_constraintEnd_toStartOf="@+id/menu"
4749
app:layout_constraintStart_toEndOf="@+id/imageContainer"
@@ -53,6 +55,8 @@
5355
android:layout_width="wrap_content"
5456
android:layout_height="wrap_content"
5557
android:layout_weight="0"
58+
android:layout_marginTop="4dp"
59+
android:layout_marginHorizontal="8dp"
5660
android:maxLines="1"
5761
android:textAppearance="@style/TextViewCaption"
5862
app:layout_constraintStart_toEndOf="@id/imageContainer"
@@ -64,6 +68,8 @@
6468
android:layout_width="wrap_content"
6569
android:layout_height="wrap_content"
6670
android:layout_weight="0"
71+
android:layout_marginTop="4dp"
72+
android:layout_marginHorizontal="8dp"
6773
android:maxLines="1"
6874
android:textAppearance="@style/TextViewCaption"
6975
app:layout_constraintEnd_toStartOf="@id/menu"

0 commit comments

Comments
 (0)