Avoid unnecessary updates
This commit is contained in:
parent
8dbbe99253
commit
5721ccf615
2 changed files with 7 additions and 13 deletions
|
@ -8,7 +8,6 @@ import android.view.MenuItem
|
|||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.view.MenuItemCompat
|
||||
import androidx.media3.common.MediaItem
|
||||
import androidx.media3.common.Timeline
|
||||
import com.simplemobiletools.commons.extensions.areSystemAnimationsEnabled
|
||||
import com.simplemobiletools.commons.extensions.beGoneIf
|
||||
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
|
||||
|
@ -60,8 +59,6 @@ class QueueActivity : SimpleControllerActivity() {
|
|||
getAdapter()?.updateCurrentTrack()
|
||||
}
|
||||
|
||||
override fun onTimelineChanged(timeline: Timeline, reason: Int) = updateAdapter()
|
||||
|
||||
private fun setupOptionsMenu() {
|
||||
setupSearch(binding.queueToolbar.menu)
|
||||
binding.queueToolbar.setOnMenuItemClickListener { menuItem ->
|
||||
|
@ -159,15 +156,6 @@ class QueueActivity : SimpleControllerActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun updateAdapter() {
|
||||
val adapter = getAdapter() ?: return
|
||||
withPlayer {
|
||||
val currentTracks = currentMediaItemsShuffled.toTracks() as ArrayList<Track>
|
||||
adapter.updateItems(currentTracks)
|
||||
binding.queueList.lazySmoothScroll(shuffledMediaItemsIndices.indexOf(currentMediaItemIndex))
|
||||
}
|
||||
}
|
||||
|
||||
private fun createPlaylistFromQueue() {
|
||||
NewPlaylistDialog(this) { newPlaylistId ->
|
||||
val tracks = ArrayList<Track>()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.simplemobiletools.musicplayer.adapters
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.Menu
|
||||
import android.widget.ImageView
|
||||
|
@ -155,5 +156,10 @@ abstract class BaseMusicAdapter<Type>(
|
|||
}
|
||||
}
|
||||
|
||||
fun notifyDataChanged() = notifyItemRangeChanged(0, itemCount)
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
fun notifyDataChanged() = if (itemCount == 0) {
|
||||
notifyDataSetChanged()
|
||||
} else {
|
||||
notifyItemRangeChanged(0, itemCount)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue