refresh the list after adding new items

This commit is contained in:
tibbi 2017-03-28 22:49:14 +02:00
parent e4fdee2529
commit a30503274f
2 changed files with 4 additions and 2 deletions

View file

@ -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)
}
}

View file

@ -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)