Fix crash on opening deleted local playlist

Upadte playlist view on content change.
This commit is contained in:
Krunal Patel 2022-12-07 15:53:04 +05:30
parent b0f863c747
commit d534389c82
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().deletePlaylistItemsByPlaylistId(playlistId)
}
onSuccess.invoke()
return
}

View File

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