refresh the list after adding new items
This commit is contained in:
parent
e4fdee2529
commit
a30503274f
2 changed files with 4 additions and 2 deletions
|
@ -141,6 +141,7 @@ class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
|
|||
val files = File(it).listFiles() ?: return@FilePickerDialog
|
||||
val paths = files.mapTo(ArrayList<String>()) { it.absolutePath }
|
||||
dbHelper.addSongsToPlaylist(paths)
|
||||
sendIntent(REFRESH_LIST)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,6 +149,7 @@ class MainActivity : SimpleActivity(), SeekBar.OnSeekBarChangeListener {
|
|||
val initialPath = if (mSongs.isEmpty()) Environment.getExternalStorageDirectory().toString() else mSongs[0].path
|
||||
FilePickerDialog(this, initialPath) {
|
||||
dbHelper.addSongToPlaylist(it)
|
||||
sendIntent(REFRESH_LIST)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -165,13 +165,13 @@ class SongAdapter(val activity: SimpleActivity, var songs: ArrayList<Song>, val
|
|||
|
||||
}
|
||||
|
||||
private fun updateSongs(newSongs: ArrayList<Song>) {
|
||||
fun updateSongs(newSongs: ArrayList<Song>) {
|
||||
songs = newSongs
|
||||
currentSongIndex = -1
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun updateCurrentSongIndex(index: Int) {
|
||||
fun updateCurrentSongIndex(index: Int) {
|
||||
val prevIndex = currentSongIndex
|
||||
currentSongIndex = -1
|
||||
notifyItemChanged(prevIndex)
|
||||
|
|
Loading…
Reference in a new issue