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:
OxygenCobalt 2020-11-13 20:49:53 -07:00
parent 2ebee41ed0
commit ee95bc1a9e
5 changed files with 17 additions and 7 deletions

View file

@ -40,7 +40,7 @@ fun NotificationManager.createMediaNotification(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(
NotificationUtils.CHANNEL_ID,
context.getString(R.string.label_notification_playback),
context.getString(R.string.label_channel),
NotificationManager.IMPORTANCE_DEFAULT
)

View file

@ -81,6 +81,19 @@ class QueueAdapter(
data.removeAt(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

View file

@ -302,8 +302,6 @@ class PlaybackStateManager private constructor() {
mUserQueue.removeAt(index)
Log.d(this::class.simpleName, mUserQueue.toString())
forceUserQueueUpdate()
}

View file

@ -216,7 +216,7 @@
app:layout_constraintBottom_toBottomOf="@+id/playback_play_pause"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/playback_play_pause"
android:contentDescription="@string/description_loop" />
android:contentDescription="@string/description_change_loop" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View file

@ -32,8 +32,7 @@
<string name="label_queue_add">Add 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_queue_already_added">Already in queue!</string>
<string name="label_notification_playback">Music Playback</string>
<string name="label_channel">Music Playback</string>
<string name="label_service_playback">The music playback service for Auxio.</string>
<!-- Hint Namespace | EditText Hints -->
@ -55,7 +54,7 @@
<string name="description_skip_prev">Skip to last song</string>
<string name="description_shuffle_on">Turn shuffle on</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 -->
<string name="placeholder_genre">Unknown Genre</string>