Add duration to artist songs
Add a duration TextView to the artist song item.
This commit is contained in:
parent
e63122ce3e
commit
c5c16dfdce
8 changed files with 44 additions and 36 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,6 +3,7 @@
|
|||
local.properties
|
||||
build/
|
||||
release/
|
||||
deps/
|
||||
|
||||
# Studio
|
||||
.idea/
|
||||
|
|
|
@ -127,4 +127,4 @@ task ktlintFormat(type: JavaExec, group: "formatting") {
|
|||
classpath = configurations.ktlint
|
||||
|
||||
args "-F", "src/**/*.kt"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,18 +47,17 @@ class ArtistDetailFragment : DetailFragment() {
|
|||
val detailAdapter = ArtistDetailAdapter(
|
||||
playbackModel, detailModel,
|
||||
doOnClick = { data ->
|
||||
if (data is Album) {
|
||||
if (!detailModel.isNavigating) {
|
||||
detailModel.setNavigating(true)
|
||||
if (!detailModel.isNavigating) {
|
||||
detailModel.setNavigating(true)
|
||||
|
||||
findNavController().navigate(
|
||||
ArtistDetailFragmentDirections.actionShowAlbum(data.id)
|
||||
)
|
||||
}
|
||||
} else if (data is Song) {
|
||||
playbackModel.playSong(data, PlaybackMode.IN_ARTIST)
|
||||
findNavController().navigate(
|
||||
ArtistDetailFragmentDirections.actionShowAlbum(data.id)
|
||||
)
|
||||
}
|
||||
},
|
||||
doOnSongClick = { data ->
|
||||
playbackModel.playSong(data, PlaybackMode.IN_ARTIST)
|
||||
},
|
||||
doOnLongClick = { view, data ->
|
||||
newMenu(view, data, ActionMenu.FLAG_IN_ARTIST)
|
||||
}
|
||||
|
@ -84,14 +83,19 @@ class ArtistDetailFragment : DetailFragment() {
|
|||
pos == 0 || detailAdapter.currentList.getOrNull(pos) is ActionHeader
|
||||
}
|
||||
|
||||
detailAdapter.submitList(createData(songsHeader, detailModel.artistSortMode.value!!))
|
||||
|
||||
// --- VIEWMODEL SETUP ---
|
||||
|
||||
detailModel.artistSortMode.observe(viewLifecycleOwner) { mode ->
|
||||
logD("Updating sort mode to $mode")
|
||||
|
||||
detailAdapter.submitList(createData(songsHeader, mode))
|
||||
val artist = detailModel.currentArtist.value!!
|
||||
|
||||
val data = mutableListOf<BaseModel>(artist)
|
||||
data.addAll(SortMode.NUMERIC_DOWN.getSortedAlbumList(artist.albums))
|
||||
data.add(songsHeader)
|
||||
data.addAll(mode.getSortedArtistSongList(artist.songs))
|
||||
|
||||
detailAdapter.submitList(data)
|
||||
}
|
||||
|
||||
detailModel.navToItem.observe(viewLifecycleOwner) { item ->
|
||||
|
@ -144,15 +148,4 @@ class ArtistDetailFragment : DetailFragment() {
|
|||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
private fun createData(songHeader: ActionHeader, mode: SortMode): MutableList<BaseModel> {
|
||||
val artist = detailModel.currentArtist.value!!
|
||||
|
||||
val data = mutableListOf<BaseModel>(artist)
|
||||
data.addAll(SortMode.NUMERIC_DOWN.getSortedAlbumList(artist.albums))
|
||||
data.add(songHeader)
|
||||
data.addAll(mode.getSortedArtistSongList(artist.songs))
|
||||
|
||||
return data
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class DetailViewModel : ViewModel() {
|
|||
private val mCurrentGenre = MutableLiveData<Genre?>()
|
||||
val currentGenre: LiveData<Genre?> get() = mCurrentGenre
|
||||
|
||||
private val mCurrentArtist = MutableLiveData<Artist?>()
|
||||
val mCurrentArtist = MutableLiveData<Artist?>()
|
||||
val currentArtist: LiveData<Artist?> get() = mCurrentArtist
|
||||
|
||||
private val mCurrentAlbum = MutableLiveData<Album?>()
|
||||
|
|
|
@ -25,13 +25,15 @@ import org.oxycblt.auxio.ui.inflater
|
|||
import org.oxycblt.auxio.ui.setTextColorResource
|
||||
|
||||
/**
|
||||
* An adapter for displaying the [Album]s of an artist.
|
||||
* An adapter for displaying the [Album]s and [Song]s of an artist.
|
||||
* This isnt the nicest implementation, but it works.
|
||||
* @author OxygenCobalt
|
||||
*/
|
||||
class ArtistDetailAdapter(
|
||||
private val playbackModel: PlaybackViewModel,
|
||||
private val detailModel: DetailViewModel,
|
||||
private val doOnClick: (data: BaseModel) -> Unit,
|
||||
private val doOnClick: (data: Album) -> Unit,
|
||||
private val doOnSongClick: (data: Song) -> Unit,
|
||||
private val doOnLongClick: (view: View, data: BaseModel) -> Unit,
|
||||
) : ListAdapter<BaseModel, RecyclerView.ViewHolder>(DiffCallback()) {
|
||||
private var currentAlbum: Album? = null
|
||||
|
@ -227,7 +229,7 @@ class ArtistDetailAdapter(
|
|||
|
||||
inner class ArtistSongViewHolder(
|
||||
private val binding: ItemArtistSongBinding,
|
||||
) : BaseViewHolder<Song>(binding, doOnClick, doOnLongClick), Highlightable {
|
||||
) : BaseViewHolder<Song>(binding, doOnSongClick, doOnLongClick), Highlightable {
|
||||
private val normalTextColor = binding.songName.currentTextColor
|
||||
|
||||
override fun onBind(data: Song) {
|
||||
|
|
|
@ -28,10 +28,10 @@
|
|||
<TextView
|
||||
android:id="@+id/song_name"
|
||||
style="@style/ItemText.Primary"
|
||||
android:layout_marginEnd="@dimen/spacing_medium"
|
||||
android:text="@{song.name}"
|
||||
android:layout_marginEnd="@dimen/spacing_medium"
|
||||
app:layout_constraintBottom_toTopOf="@+id/song_info"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/song_duration"
|
||||
app:layout_constraintStart_toEndOf="@+id/album_cover"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
|
@ -40,13 +40,25 @@
|
|||
<TextView
|
||||
android:id="@+id/song_info"
|
||||
style="@style/ItemText.Secondary"
|
||||
android:layout_marginEnd="@dimen/spacing_medium"
|
||||
android:text="@{song.album.name}"
|
||||
android:layout_marginEnd="@dimen/spacing_medium"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/song_duration"
|
||||
app:layout_constraintStart_toEndOf="@+id/album_cover"
|
||||
app:layout_constraintTop_toBottomOf="@+id/song_name"
|
||||
tools:text="Album" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/song_duration"
|
||||
style="@style/ItemText.Secondary"
|
||||
android:ellipsize="none"
|
||||
android:gravity="end"
|
||||
android:text="@{song.formattedDuration}"
|
||||
android:textAlignment="viewEnd"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="16:16" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
|
@ -30,7 +30,7 @@
|
|||
android:layout_marginEnd="@dimen/spacing_medium"
|
||||
android:text="@{song.name}"
|
||||
app:layout_constraintBottom_toTopOf="@+id/song_info"
|
||||
app:layout_constraintEnd_toStartOf="@+id/duration"
|
||||
app:layout_constraintEnd_toStartOf="@+id/song_duration"
|
||||
app:layout_constraintStart_toEndOf="@+id/album_cover"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
|
@ -42,13 +42,13 @@
|
|||
android:layout_marginEnd="@dimen/spacing_medium"
|
||||
android:text="@{@string/format_info(song.album.artist.name, song.album.name)}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/duration"
|
||||
app:layout_constraintEnd_toStartOf="@+id/song_duration"
|
||||
app:layout_constraintStart_toEndOf="@+id/album_cover"
|
||||
app:layout_constraintTop_toBottomOf="@+id/song_name"
|
||||
tools:text="Artist / Album" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/duration"
|
||||
android:id="@+id/song_duration"
|
||||
style="@style/ItemText.Secondary"
|
||||
android:ellipsize="none"
|
||||
android:gravity="end"
|
||||
|
|
|
@ -17,4 +17,4 @@ Here are the music formats that Auxio supports, as per the [Supported ExoPlayer
|
|||
| WAV | ✅ | |
|
||||
| MPEG | ✅ | |
|
||||
| AAC | ✅ | |
|
||||
| FLAC | ❌ | Auxio must be patched with the [FLAC Extension](https://github.com/google/ExoPlayer/tree/release-v2/extensions/flac) |
|
||||
| FLAC | ❌ | Auxio must be patched with the [FLAC Extension](https://github.com/google/ExoPlayer/tree/release-v2/extensions/flac). I do plan to roll this myself eventually, but it may take awhile |
|
||||
|
|
Loading…
Reference in a new issue