Minor code improvement

This commit is contained in:
Naveen 2023-07-26 16:16:21 +05:30
parent aa683a0957
commit 33e7e6595e
No known key found for this signature in database
GPG key ID: 0E155DAD31671DA3
2 changed files with 10 additions and 2 deletions

View file

@ -101,7 +101,7 @@ class TracksAdapter(
R.id.cab_rename -> displayEditDialog()
R.id.cab_remove_from_playlist -> removeFromPlaylist()
R.id.cab_delete -> askConfirmDelete()
R.id.cab_share -> activity.shareTracks(getSelectedTracks())
R.id.cab_share -> shareFiles()
R.id.cab_select_all -> selectAll()
R.id.cab_play_next -> playNext()
}
@ -211,6 +211,10 @@ class TracksAdapter(
}
}
private fun shareFiles() {
activity.shareTracks(getSelectedTracks())
}
private fun getSelectedTracks(): List<Track> = tracks.filter { selectedKeys.contains(it.hashCode()) }
fun updateItems(newItems: ArrayList<Track>, highlightText: String = "", forceUpdate: Boolean = false) {

View file

@ -97,7 +97,7 @@ class TracksHeaderAdapter(activity: SimpleActivity, var items: ArrayList<ListIte
R.id.cab_add_to_queue -> addToQueue()
R.id.cab_properties -> showProperties()
R.id.cab_delete -> askConfirmDelete()
R.id.cab_share -> activity.shareTracks(getSelectedTracks())
R.id.cab_share -> shareFiles()
R.id.cab_rename -> displayEditDialog()
R.id.cab_select_all -> selectAll()
R.id.cab_play_next -> playNext()
@ -172,6 +172,10 @@ class TracksHeaderAdapter(activity: SimpleActivity, var items: ArrayList<ListIte
}
}
private fun shareFiles() {
activity.shareTracks(getSelectedTracks())
}
private fun getSelectedTracks(): List<Track> = items.filter { it is Track && selectedKeys.contains(it.hashCode()) }.toList() as List<Track>
fun updateItems(newItems: ArrayList<ListItem>) {