mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 23:40:33 +05:30
Fix queue starts wrong video after reordering
This commit is contained in:
parent
00c607db49
commit
c2f0d68ddf
@ -7,6 +7,7 @@ import android.view.LayoutInflater
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.libretube.databinding.QueueRowBinding
|
import com.github.libretube.databinding.QueueRowBinding
|
||||||
|
import com.github.libretube.extensions.toID
|
||||||
import com.github.libretube.ui.viewholders.PlayingQueueViewHolder
|
import com.github.libretube.ui.viewholders.PlayingQueueViewHolder
|
||||||
import com.github.libretube.util.ImageHelper
|
import com.github.libretube.util.ImageHelper
|
||||||
import com.github.libretube.util.PlayingQueue
|
import com.github.libretube.util.PlayingQueue
|
||||||
@ -46,10 +47,16 @@ class PlayingQueueAdapter : RecyclerView.Adapter<PlayingQueueViewHolder>() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
root.setOnClickListener {
|
root.setOnClickListener {
|
||||||
val oldIndex = PlayingQueue.currentIndex()
|
val oldPosition = PlayingQueue.currentIndex()
|
||||||
PlayingQueue.onQueueItemSelected(position)
|
// get the new position from the queue to work properly after reordering the queue
|
||||||
notifyItemChanged(oldIndex)
|
val newPosition = PlayingQueue.getStreams().indexOfFirst {
|
||||||
notifyItemChanged(position)
|
it.url?.toID() == streamItem.url?.toID()
|
||||||
|
}.takeIf { it >= 0 } ?: return@setOnClickListener
|
||||||
|
|
||||||
|
// select the new item in the queue and update the selected item in the UI
|
||||||
|
PlayingQueue.onQueueItemSelected(newPosition)
|
||||||
|
notifyItemChanged(oldPosition)
|
||||||
|
notifyItemChanged(newPosition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user