Fix RTL constraints for Album/Song items
Fix incorrect constraints when viewing an album or song item in Right-To-Left mode.
This commit is contained in:
parent
c9875a03a9
commit
eafc89a294
6 changed files with 19 additions and 15 deletions
|
@ -32,6 +32,7 @@ class LibraryFragment : Fragment() {
|
||||||
val adapter = AlbumDataAdapter()
|
val adapter = AlbumDataAdapter()
|
||||||
binding.libraryRecycler.adapter = adapter
|
binding.libraryRecycler.adapter = adapter
|
||||||
binding.libraryRecycler.applyDivider()
|
binding.libraryRecycler.applyDivider()
|
||||||
|
binding.libraryRecycler.setHasFixedSize(true)
|
||||||
|
|
||||||
libraryModel.albums.observe(
|
libraryModel.albums.observe(
|
||||||
viewLifecycleOwner,
|
viewLifecycleOwner,
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.ListAdapter
|
import androidx.recyclerview.widget.ListAdapter
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import org.oxycblt.auxio.databinding.SongItemBinding
|
import org.oxycblt.auxio.databinding.SongItemBinding
|
||||||
import org.oxycblt.auxio.music.models.Song
|
import org.oxycblt.auxio.music.models.Song
|
||||||
import org.oxycblt.auxio.recycler.SongViewHolder
|
import org.oxycblt.auxio.recycler.SongViewHolder
|
||||||
|
@ -17,15 +18,20 @@ class SongDataAdapter : ListAdapter<Song, SongViewHolder>(DiffCallback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SongViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SongViewHolder {
|
||||||
return SongViewHolder(
|
val binding = SongItemBinding.inflate(LayoutInflater.from(parent.context))
|
||||||
SongItemBinding.inflate(LayoutInflater.from(parent.context))
|
|
||||||
|
// Force the layout to be the width of the screen so that the cutoff can work properly.
|
||||||
|
binding.root.layoutParams = RecyclerView.LayoutParams(
|
||||||
|
RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT
|
||||||
)
|
)
|
||||||
|
|
||||||
|
return SongViewHolder(binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: SongViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: SongViewHolder, position: Int) {
|
||||||
val Song = getItem(position)
|
val song = getItem(position)
|
||||||
|
|
||||||
holder.bind(Song)
|
holder.bind(song)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object DiffCallback : DiffUtil.ItemCallback<Song>() {
|
companion object DiffCallback : DiffUtil.ItemCallback<Song>() {
|
||||||
|
|
|
@ -30,6 +30,7 @@ class SongsFragment : Fragment() {
|
||||||
val adapter = SongDataAdapter()
|
val adapter = SongDataAdapter()
|
||||||
binding.songRecycler.adapter = adapter
|
binding.songRecycler.adapter = adapter
|
||||||
binding.songRecycler.applyDivider()
|
binding.songRecycler.applyDivider()
|
||||||
|
binding.songRecycler.setHasFixedSize(true)
|
||||||
|
|
||||||
songsModel.songs.observe(
|
songsModel.songs.observe(
|
||||||
viewLifecycleOwner,
|
viewLifecycleOwner,
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
android:layout_height="@dimen/cover_size_compact"
|
android:layout_height="@dimen/cover_size_compact"
|
||||||
android:contentDescription="@{@string/description_cover_art + album.title}"
|
android:contentDescription="@{@string/description_cover_art + album.title}"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:src="@tools:sample/backgrounds/scenic"
|
tools:src="@tools:sample/backgrounds/scenic"
|
||||||
|
|
|
@ -21,37 +21,35 @@
|
||||||
android:layout_height="@dimen/cover_size_compact"
|
android:layout_height="@dimen/cover_size_compact"
|
||||||
android:contentDescription="@{@string/description_cover_art + song.album.title}"
|
android:contentDescription="@{@string/description_cover_art + song.album.title}"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:src="@tools:sample/backgrounds/scenic"
|
tools:src="@tools:sample/backgrounds/scenic"
|
||||||
tools:srcCompat="@tools:sample/backgrounds/scenic" />
|
tools:srcCompat="@tools:sample/backgrounds/scenic" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/album_name"
|
android:id="@+id/song_name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/margin_medium"
|
android:layout_marginStart="@dimen/margin_medium"
|
||||||
android:text="@{song.title}"
|
android:text="@{song.title}"
|
||||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
app:layout_constraintBottom_toTopOf="@+id/song_count"
|
app:layout_constraintBottom_toTopOf="@+id/song_data"
|
||||||
app:layout_constraintStart_toEndOf="@+id/cover"
|
app:layout_constraintStart_toEndOf="@+id/cover"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintVertical_chainStyle="packed"
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
tools:text="Song Name" />
|
tools:text="Song Name" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/song_count"
|
android:id="@+id/song_data"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/margin_medium"
|
android:layout_marginStart="@dimen/margin_medium"
|
||||||
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@+id/cover"
|
app:layout_constraintStart_toEndOf="@+id/cover"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/album_name"
|
app:layout_constraintTop_toBottomOf="@+id/song_name"
|
||||||
app:songData="@{song}"
|
app:songData="@{song}"
|
||||||
tools:text="Artist / Album" />
|
tools:text="Artist / Album" />
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<dimen name="margin_medium">16dp</dimen>
|
<dimen name="margin_medium">16dp</dimen>
|
||||||
|
|
||||||
<dimen name="cover_size">64dp</dimen>
|
<dimen name="cover_size">64dp</dimen>
|
||||||
<dimen name="cover_size_compact">42dp</dimen>
|
<dimen name="cover_size_compact">44dp</dimen>
|
||||||
|
|
||||||
<dimen name="elevation_normal">4dp</dimen>
|
<dimen name="elevation_normal">4dp</dimen>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in a new issue