Merge pull request #2283 from Kruna1Pate1/fix/playlist-crash

Fix crash on opening deleted local playlist
This commit is contained in:
Krunal Patel 2022-12-07 17:40:13 +05:30 committed by GitHub
commit 6eeed5246b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -40,6 +40,7 @@ class DeletePlaylistDialog(
DatabaseHolder.Database.localPlaylistsDao().deletePlaylistById(playlistId) DatabaseHolder.Database.localPlaylistsDao().deletePlaylistById(playlistId)
DatabaseHolder.Database.localPlaylistsDao().deletePlaylistItemsByPlaylistId(playlistId) DatabaseHolder.Database.localPlaylistsDao().deletePlaylistItemsByPlaylistId(playlistId)
} }
onSuccess.invoke()
return return
} }

View File

@ -129,12 +129,14 @@ class LibraryFragment : BaseFragment() {
// listen for playlists to become deleted // listen for playlists to become deleted
playlistsAdapter.registerAdapterDataObserver(object : playlistsAdapter.registerAdapterDataObserver(object :
RecyclerView.AdapterDataObserver() { RecyclerView.AdapterDataObserver() {
override fun onChanged() { override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
binding.nothingHere.visibility = if (playlistsAdapter.itemCount == 0) View.VISIBLE else View.GONE binding.nothingHere.visibility =
super.onChanged() if (playlistsAdapter.itemCount == 0) View.VISIBLE else View.GONE
super.onItemRangeRemoved(positionStart, itemCount)
} }
}) })
binding.nothingHere.visibility = View.GONE
binding.playlistRecView.adapter = playlistsAdapter binding.playlistRecView.adapter = playlistsAdapter
} else { } else {
runOnUiThread { runOnUiThread {