Add navigation to LibraryFragment
Add navigiation to LibraryFragment. This navigation is nested so that one can still move through the ViewPager, which will certainly have no problems later on. /s
This commit is contained in:
parent
49248f98d9
commit
f7e25d3fa8
21 changed files with 419 additions and 43 deletions
|
|
@ -0,0 +1,37 @@
|
|||
package org.oxycblt.auxio.detail
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.databinding.FragmentArtistDetailBinding
|
||||
import org.oxycblt.auxio.music.MusicViewModel
|
||||
|
||||
class ArtistDetailFragment : Fragment() {
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
val binding = DataBindingUtil.inflate<FragmentArtistDetailBinding>(
|
||||
inflater, R.layout.fragment_artist_detail, container, false
|
||||
)
|
||||
|
||||
// I honestly don't want to turn of the any data classes into a parcelables due to how
|
||||
// many lists they store, so just pick up the artist id and find it from musicModel.
|
||||
val musicModel: MusicViewModel by activityViewModels()
|
||||
val artistId = ArtistDetailFragmentArgs.fromBundle(requireArguments()).artistId
|
||||
|
||||
binding.artist = musicModel.artists.value?.find { it.id == artistId }
|
||||
|
||||
Log.d(this::class.simpleName, "Fragment created.")
|
||||
|
||||
return binding.root
|
||||
}
|
||||
}
|
||||
|
|
@ -5,21 +5,17 @@ import android.util.Log
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.databinding.FragmentLibraryBinding
|
||||
import org.oxycblt.auxio.library.adapters.ArtistAdapter
|
||||
import org.oxycblt.auxio.music.MusicViewModel
|
||||
import org.oxycblt.auxio.recycler.ClickListener
|
||||
import org.oxycblt.auxio.recycler.applyDivider
|
||||
|
||||
class LibraryFragment : Fragment() {
|
||||
|
||||
private val musicModel: MusicViewModel by activityViewModels {
|
||||
MusicViewModel.Factory(requireActivity().application)
|
||||
}
|
||||
private var navController: NavController? = null
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
|
|
@ -30,17 +26,44 @@ class LibraryFragment : Fragment() {
|
|||
inflater, R.layout.fragment_library, container, false
|
||||
)
|
||||
|
||||
binding.libraryRecycler.adapter = ArtistAdapter(
|
||||
musicModel.artists.value!!,
|
||||
ClickListener { artist ->
|
||||
Log.d(this::class.simpleName, artist.name)
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(
|
||||
viewLifecycleOwner, callback
|
||||
)
|
||||
binding.libraryRecycler.applyDivider()
|
||||
binding.libraryRecycler.setHasFixedSize(true)
|
||||
|
||||
val navHost = childFragmentManager.findFragmentById(R.id.nav_host) as? NavHostFragment
|
||||
navController = navHost?.navController
|
||||
|
||||
Log.d(this::class.simpleName, "Fragment created.")
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
callback.isEnabled = true
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
callback.isEnabled = false
|
||||
}
|
||||
|
||||
val callback = object : OnBackPressedCallback(false) {
|
||||
|
||||
override fun handleOnBackPressed() {
|
||||
|
||||
// If at the root of the navigation, perform onBackPressed from the main activity.
|
||||
if (navController?.currentDestination?.id == navController?.graph?.startDestination) {
|
||||
// Disable the callback as it will get caught in an infinite loop otherwise.
|
||||
isEnabled = false
|
||||
|
||||
requireActivity().onBackPressed()
|
||||
|
||||
isEnabled = true
|
||||
} else {
|
||||
navController?.navigateUp()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
package org.oxycblt.auxio.library
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.databinding.FragmentLibraryListBinding
|
||||
import org.oxycblt.auxio.library.adapters.ArtistAdapter
|
||||
import org.oxycblt.auxio.music.MusicViewModel
|
||||
import org.oxycblt.auxio.recycler.ClickListener
|
||||
import org.oxycblt.auxio.recycler.applyDivider
|
||||
|
||||
class LibraryListFragment : Fragment() {
|
||||
|
||||
private val musicModel: MusicViewModel by activityViewModels {
|
||||
MusicViewModel.Factory(requireActivity().application)
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
val binding = DataBindingUtil.inflate<FragmentLibraryListBinding>(
|
||||
inflater, R.layout.fragment_library_list, container, false
|
||||
)
|
||||
|
||||
binding.libraryRecycler.adapter = ArtistAdapter(
|
||||
musicModel.artists.value!!,
|
||||
ClickListener { artist ->
|
||||
findNavController().navigate(
|
||||
LibraryListFragmentDirections.actionShowArtist(artist.id)
|
||||
)
|
||||
}
|
||||
)
|
||||
binding.libraryRecycler.applyDivider()
|
||||
binding.libraryRecycler.setHasFixedSize(true)
|
||||
|
||||
Log.d(this::class.simpleName, "Fragment created.")
|
||||
|
||||
return binding.root
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package org.oxycblt.auxio.library.adapters
|
|||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.oxycblt.auxio.databinding.AlbumItemBinding
|
||||
import org.oxycblt.auxio.databinding.ItemAlbumBinding
|
||||
import org.oxycblt.auxio.music.models.Album
|
||||
import org.oxycblt.auxio.recycler.ClickListener
|
||||
import org.oxycblt.auxio.recycler.viewholders.AlbumViewHolder
|
||||
|
|
@ -16,7 +16,7 @@ class AlbumAdapter(
|
|||
override fun getItemCount(): Int = data.size
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AlbumViewHolder {
|
||||
val binding = AlbumItemBinding.inflate(LayoutInflater.from(parent.context))
|
||||
val binding = ItemAlbumBinding.inflate(LayoutInflater.from(parent.context))
|
||||
|
||||
// Force the item to *actually* be the screen width so ellipsizing can work.
|
||||
binding.root.layoutParams = RecyclerView.LayoutParams(
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package org.oxycblt.auxio.library.adapters
|
|||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.oxycblt.auxio.databinding.ArtistItemBinding
|
||||
import org.oxycblt.auxio.databinding.ItemArtistBinding
|
||||
import org.oxycblt.auxio.music.models.Artist
|
||||
import org.oxycblt.auxio.recycler.ClickListener
|
||||
import org.oxycblt.auxio.recycler.viewholders.ArtistViewHolder
|
||||
|
|
@ -16,7 +16,7 @@ class ArtistAdapter(
|
|||
override fun getItemCount(): Int = data.size
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ArtistViewHolder {
|
||||
val binding = ArtistItemBinding.inflate(LayoutInflater.from(parent.context))
|
||||
val binding = ItemArtistBinding.inflate(LayoutInflater.from(parent.context))
|
||||
|
||||
// Force the item to *actually* be the screen width so ellipsizing can work.
|
||||
binding.root.layoutParams = RecyclerView.LayoutParams(
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import org.oxycblt.auxio.music.processing.MusicLoader
|
|||
import org.oxycblt.auxio.music.processing.MusicLoaderResponse
|
||||
import org.oxycblt.auxio.music.processing.MusicSorter
|
||||
|
||||
// Storage for music data.
|
||||
// ViewModel for music storage. May also be a god object.
|
||||
class MusicViewModel(private val app: Application) : ViewModel() {
|
||||
|
||||
// Coroutine
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package org.oxycblt.auxio.music.models
|
||||
|
||||
// Abstraction for mAlbums
|
||||
// Abstraction for albums
|
||||
data class Artist(
|
||||
val id: Long = 0,
|
||||
var name: String = "",
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package org.oxycblt.auxio.recycler.viewholders
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.oxycblt.auxio.databinding.AlbumItemBinding
|
||||
import org.oxycblt.auxio.databinding.ItemAlbumBinding
|
||||
import org.oxycblt.auxio.music.models.Album
|
||||
|
||||
// Generic ViewHolder for an album
|
||||
class AlbumViewHolder(
|
||||
private val binding: AlbumItemBinding
|
||||
private val binding: ItemAlbumBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
// Bind the view w/new data
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package org.oxycblt.auxio.recycler.viewholders
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.oxycblt.auxio.databinding.ArtistItemBinding
|
||||
import org.oxycblt.auxio.databinding.ItemArtistBinding
|
||||
import org.oxycblt.auxio.music.models.Artist
|
||||
|
||||
// Generic ViewHolder for an album
|
||||
class ArtistViewHolder(
|
||||
private val binding: ArtistItemBinding
|
||||
private val binding: ItemArtistBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
// Bind the view w/new data
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package org.oxycblt.auxio.recycler.viewholders
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.oxycblt.auxio.databinding.SongItemBinding
|
||||
import org.oxycblt.auxio.databinding.ItemSongBinding
|
||||
import org.oxycblt.auxio.music.models.Song
|
||||
|
||||
// Generic ViewHolder for a song
|
||||
class SongViewHolder(
|
||||
private val binding: SongItemBinding
|
||||
private val binding: ItemSongBinding
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
// Bind the view w/new data
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package org.oxycblt.auxio.songs
|
|||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.oxycblt.auxio.databinding.SongItemBinding
|
||||
import org.oxycblt.auxio.databinding.ItemSongBinding
|
||||
import org.oxycblt.auxio.music.models.Song
|
||||
import org.oxycblt.auxio.recycler.ClickListener
|
||||
import org.oxycblt.auxio.recycler.viewholders.SongViewHolder
|
||||
|
|
@ -16,7 +16,7 @@ class SongAdapter(
|
|||
override fun getItemCount(): Int = data.size
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SongViewHolder {
|
||||
val binding = SongItemBinding.inflate(LayoutInflater.from(parent.context))
|
||||
val binding = ItemSongBinding.inflate(LayoutInflater.from(parent.context))
|
||||
|
||||
// Force the item to *actually* be the screen width so ellipsizing can work.
|
||||
binding.root.layoutParams = RecyclerView.LayoutParams(
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@
|
|||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/view_pager"
|
||||
|
|
|
|||
21
app/src/main/res/layout/fragment_artist_detail.xml
Normal file
21
app/src/main/res/layout/fragment_artist_detail.xml
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="artist"
|
||||
type="org.oxycblt.auxio.music.models.Artist" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@{artist.name}" />
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
|
|
@ -19,13 +18,13 @@
|
|||
app:title="@string/title_library_fragment"
|
||||
tools:titleTextColor="@color/blue" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/library_recycler"
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/nav_host"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/album_item" />
|
||||
|
||||
app:defaultNavHost="false"
|
||||
app:navGraph="@navigation/nav_library" />
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
18
app/src/main/res/layout/fragment_library_list.xml
Normal file
18
app/src/main/res/layout/fragment_library_list.xml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/library_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/item_album" />
|
||||
|
||||
</FrameLayout>
|
||||
</layout>
|
||||
|
|
@ -14,8 +14,7 @@
|
|||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading_bar"
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
|
|
@ -25,7 +24,7 @@
|
|||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/song_item" />
|
||||
tools:listitem="@layout/item_song" />
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
62
app/src/main/res/layout/item_album.xml
Normal file
62
app/src/main/res/layout/item_album.xml
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="album"
|
||||
type="org.oxycblt.auxio.music.models.Album" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="@dimen/padding_medium">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cover"
|
||||
android:layout_width="@dimen/cover_size_normal"
|
||||
android:layout_height="@dimen/cover_size_normal"
|
||||
app:coverArt="@{album}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@tools:sample/backgrounds/scenic"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/album_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/margin_medium"
|
||||
android:text="@{album.name}"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
app:layout_constraintBottom_toTopOf="@+id/song_count"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/cover"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
tools:text="Album Name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/song_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/margin_medium"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/cover"
|
||||
app:layout_constraintTop_toBottomOf="@+id/album_name"
|
||||
app:songCount="@{album}"
|
||||
tools:text="10 Songs" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
63
app/src/main/res/layout/item_artist.xml
Normal file
63
app/src/main/res/layout/item_artist.xml
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="artist"
|
||||
type="org.oxycblt.auxio.music.models.Artist" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="@dimen/padding_medium">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/artist_image"
|
||||
android:layout_width="@dimen/cover_size_normal"
|
||||
android:layout_height="@dimen/cover_size_normal"
|
||||
app:artistImage="@{artist}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@tools:sample/backgrounds/scenic"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/artist_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@{artist.name}"
|
||||
android:layout_marginStart="@dimen/margin_medium"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintBottom_toTopOf="@+id/album_song_count"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/artist_image"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
tools:text="Artist Name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/album_song_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||
android:layout_marginStart="@dimen/margin_medium"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:artistCounts="@{artist}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/artist_image"
|
||||
app:layout_constraintTop_toBottomOf="@+id/artist_name"
|
||||
tools:text="2 Albums, 20 Songs" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
81
app/src/main/res/layout/item_song.xml
Normal file
81
app/src/main/res/layout/item_song.xml
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="song"
|
||||
type="org.oxycblt.auxio.music.models.Song" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="@dimen/padding_medium">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cover"
|
||||
android:layout_width="@dimen/cover_size_compact"
|
||||
android:layout_height="@dimen/cover_size_compact"
|
||||
app:coverArt="@{song}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@tools:sample/backgrounds/scenic"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/song_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/margin_medium"
|
||||
android:layout_marginEnd="@dimen/margin_medium"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@{song.name}"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintBottom_toTopOf="@+id/song_info"
|
||||
app:layout_constraintEnd_toStartOf="@+id/duration"
|
||||
app:layout_constraintStart_toEndOf="@+id/cover"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed"
|
||||
tools:text="Song Name" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/song_info"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/margin_medium"
|
||||
android:layout_marginEnd="@dimen/margin_medium"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:text="@{@string/format_song_info(song.album.artist.name, song.album.name)}"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/duration"
|
||||
app:layout_constraintStart_toEndOf="@+id/cover"
|
||||
app:layout_constraintTop_toBottomOf="@+id/song_name"
|
||||
tools:text="Artist / Album" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:text="@{song.formattedDuration}"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||
android:textColor="?android:attr/textColorTertiary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="16:16" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
26
app/src/main/res/navigation/nav_library.xml
Normal file
26
app/src/main/res/navigation/nav_library.xml
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/nav_library"
|
||||
app:startDestination="@id/libraryListFragment">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/libraryListFragment"
|
||||
android:name="org.oxycblt.auxio.library.LibraryListFragment"
|
||||
android:label="LibraryFragment"
|
||||
tools:layout="@layout/fragment_library_list">
|
||||
<action
|
||||
android:id="@+id/action_show_artist"
|
||||
app:destination="@id/artistDetailFragment" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/artistDetailFragment"
|
||||
android:name="org.oxycblt.auxio.detail.ArtistDetailFragment"
|
||||
android:label="ArtistDetailFragment"
|
||||
tools:layout="@layout/fragment_artist_detail">
|
||||
<argument
|
||||
android:name="artistId"
|
||||
app:argType="long" />
|
||||
</fragment>
|
||||
</navigation>
|
||||
Loading…
Reference in a new issue