Fix more queue bugs
Fix bugs with QueueAdapter where removing the last item from the user queue or the next queue would cause weird behavior or a crash.
This commit is contained in:
parent
2ebee41ed0
commit
ee95bc1a9e
5 changed files with 17 additions and 7 deletions
|
@ -40,7 +40,7 @@ fun NotificationManager.createMediaNotification(
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
val channel = NotificationChannel(
|
val channel = NotificationChannel(
|
||||||
NotificationUtils.CHANNEL_ID,
|
NotificationUtils.CHANNEL_ID,
|
||||||
context.getString(R.string.label_notification_playback),
|
context.getString(R.string.label_channel),
|
||||||
NotificationManager.IMPORTANCE_DEFAULT
|
NotificationManager.IMPORTANCE_DEFAULT
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,19 @@ class QueueAdapter(
|
||||||
data.removeAt(adapterIndex)
|
data.removeAt(adapterIndex)
|
||||||
|
|
||||||
notifyItemRemoved(adapterIndex)
|
notifyItemRemoved(adapterIndex)
|
||||||
|
|
||||||
|
// Check for two things:
|
||||||
|
// If the data from the next queue is now entirely empty [Signified by a header at the end]
|
||||||
|
// Or if the data from the last queue is now entirely empty [Signified by there being 2 headers with no items in between]
|
||||||
|
if (data[data.lastIndex] is Header) {
|
||||||
|
val lastIndex = data.lastIndex
|
||||||
|
|
||||||
|
data.removeAt(lastIndex)
|
||||||
|
notifyItemRemoved(lastIndex)
|
||||||
|
} else if (data.lastIndex >= 1 && data[0] is Header && data[1] is Header) {
|
||||||
|
data.removeAt(0)
|
||||||
|
notifyItemRemoved(0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic ViewHolder for a queue item
|
// Generic ViewHolder for a queue item
|
||||||
|
|
|
@ -302,8 +302,6 @@ class PlaybackStateManager private constructor() {
|
||||||
|
|
||||||
mUserQueue.removeAt(index)
|
mUserQueue.removeAt(index)
|
||||||
|
|
||||||
Log.d(this::class.simpleName, mUserQueue.toString())
|
|
||||||
|
|
||||||
forceUserQueueUpdate()
|
forceUserQueueUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/playback_play_pause"
|
app:layout_constraintBottom_toBottomOf="@+id/playback_play_pause"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@+id/playback_play_pause"
|
app:layout_constraintTop_toTopOf="@+id/playback_play_pause"
|
||||||
android:contentDescription="@string/description_loop" />
|
android:contentDescription="@string/description_change_loop" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</layout>
|
</layout>
|
|
@ -32,8 +32,7 @@
|
||||||
<string name="label_queue_add">Add to queue</string>
|
<string name="label_queue_add">Add to queue</string>
|
||||||
<string name="label_queue_added">Added to queue</string>
|
<string name="label_queue_added">Added to queue</string>
|
||||||
<string name="label_next_user_queue">Next in Queue</string>
|
<string name="label_next_user_queue">Next in Queue</string>
|
||||||
<string name="label_queue_already_added">Already in queue!</string>
|
<string name="label_channel">Music Playback</string>
|
||||||
<string name="label_notification_playback">Music Playback</string>
|
|
||||||
<string name="label_service_playback">The music playback service for Auxio.</string>
|
<string name="label_service_playback">The music playback service for Auxio.</string>
|
||||||
|
|
||||||
<!-- Hint Namespace | EditText Hints -->
|
<!-- Hint Namespace | EditText Hints -->
|
||||||
|
@ -55,7 +54,7 @@
|
||||||
<string name="description_skip_prev">Skip to last song</string>
|
<string name="description_skip_prev">Skip to last song</string>
|
||||||
<string name="description_shuffle_on">Turn shuffle on</string>
|
<string name="description_shuffle_on">Turn shuffle on</string>
|
||||||
<string name="description_shuffle_off">Turn shuffle off</string>
|
<string name="description_shuffle_off">Turn shuffle off</string>
|
||||||
<string name="description_loop">Loop</string>
|
<string name="description_change_loop">Change Repeat Mode</string>
|
||||||
|
|
||||||
<!-- Placeholder Namespace | Placeholder values -->
|
<!-- Placeholder Namespace | Placeholder values -->
|
||||||
<string name="placeholder_genre">Unknown Genre</string>
|
<string name="placeholder_genre">Unknown Genre</string>
|
||||||
|
|
Loading…
Reference in a new issue