Use await query for db update

This commit is contained in:
Krunal Patel 2022-12-09 21:56:42 +05:30
parent 85400101e2
commit 44cc6d42b2
2 changed files with 7 additions and 6 deletions

View File

@ -178,8 +178,10 @@ object PlaylistsHelper {
if (transaction.videos.size > 1) { if (transaction.videos.size > 1) {
if (index == 0) { if (index == 0) {
transaction.videos[1].thumbnailUrl?.let { transaction.playlist.thumbnailUrl = it } transaction.videos[1].thumbnailUrl?.let { transaction.playlist.thumbnailUrl = it }
awaitQuery {
DatabaseHolder.Database.localPlaylistsDao().updatePlaylist(transaction.playlist) DatabaseHolder.Database.localPlaylistsDao().updatePlaylist(transaction.playlist)
} }
}
return return
} }
// remove thumbnail if playlist now empty // remove thumbnail if playlist now empty

View File

@ -185,17 +185,16 @@ class PlaylistFragment : BaseFragment() {
} }
val info = binding.playlistInfo.text.split(TextUtils.SEPARATOR) val info = binding.playlistInfo.text.split(TextUtils.SEPARATOR)
val countInfo = getString(
R.string.videoCount,
playlistAdapter!!.itemCount.toString()
)
binding.playlistInfo.text = ( binding.playlistInfo.text = (
if (info.size == 2) { if (info.size == 2) {
info[0] + TextUtils.SEPARATOR info[0] + TextUtils.SEPARATOR
} else { } else {
"" ""
} }
) + countInfo ) + getString(
R.string.videoCount,
playlistAdapter!!.itemCount.toString()
)
super.onItemRangeRemoved(positionStart, itemCount) super.onItemRangeRemoved(positionStart, itemCount)
} }
}) })