queue: fix visual error when adding to queue
Fix a visual error where adding to queue would visually place items next to the starting index rather than at the end. This was a result of forgetting to update the Add instructions returned by Queue.addToNext to return the end of the queue rather than the current index, which completely broke the queue visual. Resolves #435.
This commit is contained in:
parent
63f7627fbc
commit
d97eaf67b9
4 changed files with 19 additions and 9 deletions
|
@ -17,6 +17,7 @@
|
||||||
- Items should no longer be indicated as playing if the currently playing song is not contained
|
- Items should no longer be indicated as playing if the currently playing song is not contained
|
||||||
within it
|
within it
|
||||||
- Fixed blurry playing indicator in album/artist/genre/playlist items
|
- Fixed blurry playing indicator in album/artist/genre/playlist items
|
||||||
|
- Fixed incorrect songs being displayed when adding albums to the end of the queue
|
||||||
|
|
||||||
## 3.1.0
|
## 3.1.0
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
||||||
private val selectionBadge: ImageView?
|
private val selectionBadge: ImageView?
|
||||||
|
|
||||||
@DimenRes private val iconSizeRes: Int?
|
@DimenRes private val iconSizeRes: Int?
|
||||||
@DimenRes private val cornerRadiusRes: Int
|
@DimenRes private val cornerRadiusRes: Int?
|
||||||
|
|
||||||
private var fadeAnimator: ValueAnimator? = null
|
private var fadeAnimator: ValueAnimator? = null
|
||||||
private val indicatorMatrix = Matrix()
|
private val indicatorMatrix = Matrix()
|
||||||
|
@ -103,7 +103,12 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
||||||
|
|
||||||
val sizing = styledAttrs.getIntOrThrow(R.styleable.CoverView_sizing)
|
val sizing = styledAttrs.getIntOrThrow(R.styleable.CoverView_sizing)
|
||||||
iconSizeRes = SIZING_ICON_SIZE[sizing]
|
iconSizeRes = SIZING_ICON_SIZE[sizing]
|
||||||
cornerRadiusRes = SIZING_CORNER_RADII[sizing]
|
cornerRadiusRes =
|
||||||
|
if (uiSettings.roundMode) {
|
||||||
|
SIZING_CORNER_RADII[sizing]
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
val playbackIndicatorEnabled =
|
val playbackIndicatorEnabled =
|
||||||
styledAttrs.getBoolean(R.styleable.CoverView_enablePlaybackIndicator, true)
|
styledAttrs.getBoolean(R.styleable.CoverView_enablePlaybackIndicator, true)
|
||||||
|
@ -162,7 +167,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
||||||
background =
|
background =
|
||||||
MaterialShapeDrawable().apply {
|
MaterialShapeDrawable().apply {
|
||||||
fillColor = context.getColorCompat(R.color.sel_cover_bg)
|
fillColor = context.getColorCompat(R.color.sel_cover_bg)
|
||||||
setCornerSize(context.getDimen(cornerRadiusRes))
|
setCornerSize(cornerRadiusRes?.let(context::getDimen) ?: 0f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,6 +225,11 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
||||||
invalidateSelectionIndicatorAlpha(selectionBadge ?: return)
|
invalidateSelectionIndicatorAlpha(selectionBadge ?: return)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun setEnabled(enabled: Boolean) {
|
||||||
|
super.setEnabled(enabled)
|
||||||
|
invalidateRootAlpha()
|
||||||
|
}
|
||||||
|
|
||||||
override fun setSelected(selected: Boolean) {
|
override fun setSelected(selected: Boolean) {
|
||||||
super.setSelected(selected)
|
super.setSelected(selected)
|
||||||
invalidateRootAlpha()
|
invalidateRootAlpha()
|
||||||
|
@ -249,7 +259,7 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun invalidateRootAlpha() {
|
private fun invalidateRootAlpha() {
|
||||||
alpha = if (isSelected || isEnabled) 1f else 0.5f
|
alpha = if (isEnabled || isSelected) 1f else 0.5f
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun invalidatePlaybackIndicatorAlpha(playbackIndicator: PlaybackIndicator) {
|
private fun invalidatePlaybackIndicatorAlpha(playbackIndicator: PlaybackIndicator) {
|
||||||
|
@ -370,7 +380,8 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
||||||
ImageRequest.Builder(context)
|
ImageRequest.Builder(context)
|
||||||
.data(songs)
|
.data(songs)
|
||||||
.error(StyledDrawable(context, context.getDrawableCompat(errorRes), iconSizeRes))
|
.error(StyledDrawable(context, context.getDrawableCompat(errorRes), iconSizeRes))
|
||||||
.transformations(RoundedCornersTransformation(context.getDimen(cornerRadiusRes)))
|
.transformations(
|
||||||
|
RoundedCornersTransformation(cornerRadiusRes?.let(context::getDimen) ?: 0f))
|
||||||
.target(image)
|
.target(image)
|
||||||
.build()
|
.build()
|
||||||
// Dispose of any previous image request and load a new image.
|
// Dispose of any previous image request and load a new image.
|
||||||
|
|
|
@ -234,6 +234,7 @@ class EditableQueue : Queue {
|
||||||
*/
|
*/
|
||||||
fun addToQueue(songs: List<Song>): Queue.Change {
|
fun addToQueue(songs: List<Song>): Queue.Change {
|
||||||
logD("Adding ${songs.size} songs to the back of the queue")
|
logD("Adding ${songs.size} songs to the back of the queue")
|
||||||
|
val point = orderedMapping.size
|
||||||
val heapIndices = songs.map(::addSongToHeap)
|
val heapIndices = songs.map(::addSongToHeap)
|
||||||
// Can simple append the new songs to the end of both mappings.
|
// Can simple append the new songs to the end of both mappings.
|
||||||
orderedMapping.addAll(heapIndices)
|
orderedMapping.addAll(heapIndices)
|
||||||
|
@ -242,8 +243,7 @@ class EditableQueue : Queue {
|
||||||
shuffledMapping.addAll(heapIndices)
|
shuffledMapping.addAll(heapIndices)
|
||||||
}
|
}
|
||||||
check()
|
check()
|
||||||
return Queue.Change(
|
return Queue.Change(Queue.Change.Type.MAPPING, UpdateInstructions.Add(point, songs.size))
|
||||||
Queue.Change.Type.MAPPING, UpdateInstructions.Add(index + 1, songs.size))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -105,9 +105,7 @@ class QueueFragment : ViewBindingFragment<FragmentQueueBinding>(), EditClickList
|
||||||
private fun updateQueue(queue: List<Song>, index: Int, isPlaying: Boolean) {
|
private fun updateQueue(queue: List<Song>, index: Int, isPlaying: Boolean) {
|
||||||
val binding = requireBinding()
|
val binding = requireBinding()
|
||||||
|
|
||||||
// Replace or diff the queue depending on the type of change it is.
|
|
||||||
queueAdapter.update(queue, queueModel.queueInstructions.consume())
|
queueAdapter.update(queue, queueModel.queueInstructions.consume())
|
||||||
// Update position in list (and thus past/future items)
|
|
||||||
queueAdapter.setPosition(index, isPlaying)
|
queueAdapter.setPosition(index, isPlaying)
|
||||||
|
|
||||||
// If requested, scroll to a new item (occurs when the index moves)
|
// If requested, scroll to a new item (occurs when the index moves)
|
||||||
|
|
Loading…
Reference in a new issue