remove one more redundant DBHelper function

This commit is contained in:
tibbi 2018-05-20 23:01:57 +02:00
parent 709e570221
commit 763962eb8a
3 changed files with 10 additions and 13 deletions

View file

@ -335,7 +335,7 @@ class MainActivity : SimpleActivity(), SongListListener {
runOnUiThread {
RemovePlaylistDialog(this, playlist) {
if (it) {
val paths = dbHelper.getPlaylistSongPaths(config.currentPlaylist)
val paths = songsDAO.getSongsFromPlaylist(config.currentPlaylist).map { it.path }
val files = paths.map { FileDirItem(it, it.getFilenameFromPath()) } as ArrayList<FileDirItem>
paths.forEach {
songsDAO.removeSongPath(it)

View file

@ -12,9 +12,9 @@ import com.simplemobiletools.musicplayer.activities.SimpleActivity
import com.simplemobiletools.musicplayer.dialogs.NewPlaylistDialog
import com.simplemobiletools.musicplayer.dialogs.RemovePlaylistDialog
import com.simplemobiletools.musicplayer.extensions.config
import com.simplemobiletools.musicplayer.extensions.dbHelper
import com.simplemobiletools.musicplayer.extensions.playlistChanged
import com.simplemobiletools.musicplayer.extensions.playlistDAO
import com.simplemobiletools.musicplayer.extensions.songsDAO
import com.simplemobiletools.musicplayer.helpers.ALL_SONGS_PLAYLIST_ID
import com.simplemobiletools.musicplayer.interfaces.RefreshPlaylistsListener
import com.simplemobiletools.musicplayer.models.Playlist
@ -78,14 +78,15 @@ class PlaylistsAdapter(activity: SimpleActivity, val playlists: ArrayList<Playli
private fun deletePlaylistSongs(ids: ArrayList<Int>, callback: () -> Unit) {
var cnt = ids.size
ids.map { activity.dbHelper.getPlaylistSongPaths(it).map { FileDirItem(it, it.getFilenameFromPath()) } as ArrayList<FileDirItem> }
.forEach {
activity.deleteFiles(it) {
if (--cnt <= 0) {
callback()
}
}
ids.map {
val paths = activity.songsDAO.getSongsFromPlaylist(it).map { it.path }
val fileDirItems = paths.map { FileDirItem(it, it.getFilenameFromPath()) } as ArrayList<FileDirItem>
activity.deleteFiles(fileDirItems) {
if (--cnt <= 0) {
callback()
}
}
}
}
private fun removePlaylists(ids: ArrayList<Int>) {

View file

@ -67,8 +67,4 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
val selection = "$COL_PATH = ?"
mDb.update(TABLE_NAME_SONGS, values, selection, selectionArgs)
}
fun getPlaylistSongPaths(playlistId: Int): ArrayList<String> {
return ArrayList<String>()
}
}