show some extra info at the selected album
This commit is contained in:
parent
7470e67336
commit
e5532a2d7e
7 changed files with 37 additions and 8 deletions
|
@ -27,7 +27,8 @@ class SongsActivity : SimpleActivity() {
|
|||
getSongs(album.id) { songs ->
|
||||
val items = ArrayList<ListItem>()
|
||||
val coverArt = ContentUris.withAppendedId(artworkUri, album.id.toLong()).toString()
|
||||
items.add(AlbumHeader(album.title, coverArt))
|
||||
val header = AlbumHeader(album.title, coverArt, album.year, songs.size, songs.sumBy { it.duration })
|
||||
items.add(header)
|
||||
items.addAll(songs)
|
||||
|
||||
runOnUiThread {
|
||||
|
|
|
@ -101,6 +101,14 @@ class SongsAdapter(activity: SimpleActivity, val items: ArrayList<ListItem>, rec
|
|||
album_title.text = header.title
|
||||
album_title.setTextColor(textColor)
|
||||
|
||||
val tracks = resources.getQuantityString(R.plurals.tracks, header.songCnt, header.songCnt)
|
||||
var year = ""
|
||||
if (header.year != 0) {
|
||||
year = "${header.year} • "
|
||||
}
|
||||
|
||||
album_meta.text = "$year$tracks • ${header.duration.getFormattedDuration(true)}"
|
||||
|
||||
val options = RequestOptions()
|
||||
.error(placeholder)
|
||||
.transform(CenterCrop(), RoundedCorners(16))
|
||||
|
|
|
@ -132,6 +132,7 @@ fun Context.getAlbumsSync(artist: Artist): ArrayList<Album> {
|
|||
val projection = arrayOf(
|
||||
Audio.Albums._ID,
|
||||
Audio.Albums.ARTIST,
|
||||
Audio.Albums.FIRST_YEAR,
|
||||
Audio.Albums.ALBUM)
|
||||
|
||||
var selection = "${Audio.Albums.ARTIST} = ?"
|
||||
|
@ -151,7 +152,8 @@ fun Context.getAlbumsSync(artist: Artist): ArrayList<Album> {
|
|||
val artistName = cursor.getStringValue(Audio.Albums.ARTIST)
|
||||
val title = cursor.getStringValue(Audio.Albums.ALBUM)
|
||||
val coverArt = ContentUris.withAppendedId(artworkUri, id.toLong()).toString()
|
||||
val album = Album(id, artistName, title, coverArt)
|
||||
val year = cursor.getIntValue(Audio.Albums.FIRST_YEAR)
|
||||
val album = Album(id, artistName, title, coverArt, year)
|
||||
albums.add(album)
|
||||
} while (cursor.moveToNext())
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
package com.simplemobiletools.musicplayer.models
|
||||
|
||||
data class Album(val id: Int, val artist: String, val title: String, val coverArt: String): ListItem()
|
||||
data class Album(val id: Int, val artist: String, val title: String, val coverArt: String, val year: Int): ListItem()
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
package com.simplemobiletools.musicplayer.models
|
||||
|
||||
data class AlbumHeader(val title: String, val coverArt: String) : ListItem()
|
||||
data class AlbumHeader(val title: String, val coverArt: String, val year: Int, val songCnt: Int, val duration: Int) : ListItem()
|
||||
|
|
|
@ -18,16 +18,33 @@
|
|||
android:id="@+id/album_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginBottom="@dimen/medium_margin"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:paddingStart="@dimen/normal_margin"
|
||||
android:paddingEnd="@dimen/medium_margin"
|
||||
android:textSize="@dimen/bigger_text_size"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/album_image"
|
||||
android:textSize="@dimen/big_text_size"
|
||||
app:layout_constraintBottom_toTopOf="@+id/album_meta"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/album_image"
|
||||
app:layout_constraintTop_toTopOf="@+id/album_image"
|
||||
tools:text="Album title" />
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
tools:text="2019 • 3 Tracks • 0:35:40" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/album_meta"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:alpha="0.8"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:paddingStart="@dimen/normal_margin"
|
||||
android:paddingEnd="@dimen/medium_margin"
|
||||
android:textSize="@dimen/normal_text_size"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/album_image"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/album_image"
|
||||
app:layout_constraintTop_toBottomOf="@+id/album_title"
|
||||
tools:text="2019 • 3 Tracks • 0:39:25" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
android:id="@+id/song_image"
|
||||
android:layout_width="@dimen/song_image_size"
|
||||
android:layout_height="@dimen/song_image_size"
|
||||
android:layout_marginStart="@dimen/small_margin"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
|
|
Loading…
Reference in a new issue