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
|
local.properties
|
||||||
build/
|
build/
|
||||||
release/
|
release/
|
||||||
|
deps/
|
||||||
|
|
||||||
# Studio
|
# Studio
|
||||||
.idea/
|
.idea/
|
||||||
|
|
|
@ -127,4 +127,4 @@ task ktlintFormat(type: JavaExec, group: "formatting") {
|
||||||
classpath = configurations.ktlint
|
classpath = configurations.ktlint
|
||||||
|
|
||||||
args "-F", "src/**/*.kt"
|
args "-F", "src/**/*.kt"
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,18 +47,17 @@ class ArtistDetailFragment : DetailFragment() {
|
||||||
val detailAdapter = ArtistDetailAdapter(
|
val detailAdapter = ArtistDetailAdapter(
|
||||||
playbackModel, detailModel,
|
playbackModel, detailModel,
|
||||||
doOnClick = { data ->
|
doOnClick = { data ->
|
||||||
if (data is Album) {
|
if (!detailModel.isNavigating) {
|
||||||
if (!detailModel.isNavigating) {
|
detailModel.setNavigating(true)
|
||||||
detailModel.setNavigating(true)
|
|
||||||
|
|
||||||
findNavController().navigate(
|
findNavController().navigate(
|
||||||
ArtistDetailFragmentDirections.actionShowAlbum(data.id)
|
ArtistDetailFragmentDirections.actionShowAlbum(data.id)
|
||||||
)
|
)
|
||||||
}
|
|
||||||
} else if (data is Song) {
|
|
||||||
playbackModel.playSong(data, PlaybackMode.IN_ARTIST)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
doOnSongClick = { data ->
|
||||||
|
playbackModel.playSong(data, PlaybackMode.IN_ARTIST)
|
||||||
|
},
|
||||||
doOnLongClick = { view, data ->
|
doOnLongClick = { view, data ->
|
||||||
newMenu(view, data, ActionMenu.FLAG_IN_ARTIST)
|
newMenu(view, data, ActionMenu.FLAG_IN_ARTIST)
|
||||||
}
|
}
|
||||||
|
@ -84,14 +83,19 @@ class ArtistDetailFragment : DetailFragment() {
|
||||||
pos == 0 || detailAdapter.currentList.getOrNull(pos) is ActionHeader
|
pos == 0 || detailAdapter.currentList.getOrNull(pos) is ActionHeader
|
||||||
}
|
}
|
||||||
|
|
||||||
detailAdapter.submitList(createData(songsHeader, detailModel.artistSortMode.value!!))
|
|
||||||
|
|
||||||
// --- VIEWMODEL SETUP ---
|
// --- VIEWMODEL SETUP ---
|
||||||
|
|
||||||
detailModel.artistSortMode.observe(viewLifecycleOwner) { mode ->
|
detailModel.artistSortMode.observe(viewLifecycleOwner) { mode ->
|
||||||
logD("Updating sort mode to $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 ->
|
detailModel.navToItem.observe(viewLifecycleOwner) { item ->
|
||||||
|
@ -144,15 +148,4 @@ class ArtistDetailFragment : DetailFragment() {
|
||||||
|
|
||||||
return binding.root
|
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?>()
|
private val mCurrentGenre = MutableLiveData<Genre?>()
|
||||||
val currentGenre: LiveData<Genre?> get() = mCurrentGenre
|
val currentGenre: LiveData<Genre?> get() = mCurrentGenre
|
||||||
|
|
||||||
private val mCurrentArtist = MutableLiveData<Artist?>()
|
val mCurrentArtist = MutableLiveData<Artist?>()
|
||||||
val currentArtist: LiveData<Artist?> get() = mCurrentArtist
|
val currentArtist: LiveData<Artist?> get() = mCurrentArtist
|
||||||
|
|
||||||
private val mCurrentAlbum = MutableLiveData<Album?>()
|
private val mCurrentAlbum = MutableLiveData<Album?>()
|
||||||
|
|
|
@ -25,13 +25,15 @@ import org.oxycblt.auxio.ui.inflater
|
||||||
import org.oxycblt.auxio.ui.setTextColorResource
|
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
|
* @author OxygenCobalt
|
||||||
*/
|
*/
|
||||||
class ArtistDetailAdapter(
|
class ArtistDetailAdapter(
|
||||||
private val playbackModel: PlaybackViewModel,
|
private val playbackModel: PlaybackViewModel,
|
||||||
private val detailModel: DetailViewModel,
|
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,
|
private val doOnLongClick: (view: View, data: BaseModel) -> Unit,
|
||||||
) : ListAdapter<BaseModel, RecyclerView.ViewHolder>(DiffCallback()) {
|
) : ListAdapter<BaseModel, RecyclerView.ViewHolder>(DiffCallback()) {
|
||||||
private var currentAlbum: Album? = null
|
private var currentAlbum: Album? = null
|
||||||
|
@ -227,7 +229,7 @@ class ArtistDetailAdapter(
|
||||||
|
|
||||||
inner class ArtistSongViewHolder(
|
inner class ArtistSongViewHolder(
|
||||||
private val binding: ItemArtistSongBinding,
|
private val binding: ItemArtistSongBinding,
|
||||||
) : BaseViewHolder<Song>(binding, doOnClick, doOnLongClick), Highlightable {
|
) : BaseViewHolder<Song>(binding, doOnSongClick, doOnLongClick), Highlightable {
|
||||||
private val normalTextColor = binding.songName.currentTextColor
|
private val normalTextColor = binding.songName.currentTextColor
|
||||||
|
|
||||||
override fun onBind(data: Song) {
|
override fun onBind(data: Song) {
|
||||||
|
|
|
@ -28,10 +28,10 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/song_name"
|
android:id="@+id/song_name"
|
||||||
style="@style/ItemText.Primary"
|
style="@style/ItemText.Primary"
|
||||||
android:layout_marginEnd="@dimen/spacing_medium"
|
|
||||||
android:text="@{song.name}"
|
android:text="@{song.name}"
|
||||||
|
android:layout_marginEnd="@dimen/spacing_medium"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/song_info"
|
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_constraintStart_toEndOf="@+id/album_cover"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintVertical_chainStyle="packed"
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
|
@ -40,13 +40,25 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/song_info"
|
android:id="@+id/song_info"
|
||||||
style="@style/ItemText.Secondary"
|
style="@style/ItemText.Secondary"
|
||||||
android:layout_marginEnd="@dimen/spacing_medium"
|
|
||||||
android:text="@{song.album.name}"
|
android:text="@{song.album.name}"
|
||||||
|
android:layout_marginEnd="@dimen/spacing_medium"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
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_constraintStart_toEndOf="@+id/album_cover"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/song_name"
|
app:layout_constraintTop_toBottomOf="@+id/song_name"
|
||||||
tools:text="Album" />
|
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>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</layout>
|
</layout>
|
|
@ -30,7 +30,7 @@
|
||||||
android:layout_marginEnd="@dimen/spacing_medium"
|
android:layout_marginEnd="@dimen/spacing_medium"
|
||||||
android:text="@{song.name}"
|
android:text="@{song.name}"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/song_info"
|
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_constraintStart_toEndOf="@+id/album_cover"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintVertical_chainStyle="packed"
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
|
@ -42,13 +42,13 @@
|
||||||
android:layout_marginEnd="@dimen/spacing_medium"
|
android:layout_marginEnd="@dimen/spacing_medium"
|
||||||
android:text="@{@string/format_info(song.album.artist.name, song.album.name)}"
|
android:text="@{@string/format_info(song.album.artist.name, song.album.name)}"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
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_constraintStart_toEndOf="@+id/album_cover"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/song_name"
|
app:layout_constraintTop_toBottomOf="@+id/song_name"
|
||||||
tools:text="Artist / Album" />
|
tools:text="Artist / Album" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/duration"
|
android:id="@+id/song_duration"
|
||||||
style="@style/ItemText.Secondary"
|
style="@style/ItemText.Secondary"
|
||||||
android:ellipsize="none"
|
android:ellipsize="none"
|
||||||
android:gravity="end"
|
android:gravity="end"
|
||||||
|
|
|
@ -17,4 +17,4 @@ Here are the music formats that Auxio supports, as per the [Supported ExoPlayer
|
||||||
| WAV | ✅ | |
|
| WAV | ✅ | |
|
||||||
| MPEG | ✅ | |
|
| MPEG | ✅ | |
|
||||||
| AAC | ✅ | |
|
| 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