Skip to content

Commit

Permalink
remove the things related to migrating from old sqlite to Room
Browse files Browse the repository at this point in the history
  • Loading branch information
tibbi committed Oct 25, 2018
1 parent 4709229 commit 6f877ef
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,29 +236,6 @@ class MainActivity : SimpleActivity(), SongListListener {
}
}

private fun handleSongMigration() {
dbHelper.getAllSongs {
if (it.isEmpty()) {
config.wereSongsMigrated = true
return@getAllSongs
}

val songs = it
dbHelper.getAllPlaylists {
it.forEach {
val playlist = it
val newPlaylistId = if (playlist.id == ALL_SONGS_PLAYLIST_ID) ALL_SONGS_PLAYLIST_ID else playlistDAO.insert(playlist.copy(id = 0)).toInt()
val playlistSongPaths = songs.filter { it.playListId == newPlaylistId }.map { it.path } as ArrayList<String>
RoomHelper(applicationContext).addSongsToPlaylist(playlistSongPaths, newPlaylistId)
}

playlistChanged(ALL_SONGS_PLAYLIST_ID)
config.wereSongsMigrated = true
dbHelper.clearDatabase()
}
}
}

private fun setTopArtHeight() {
topArtHeight = if (config.showAlbumCover) resources.getDimensionPixelSize(R.dimen.top_art_height) else 0
artView!!.setPadding(0, topArtHeight, 0, 0)
Expand Down Expand Up @@ -505,12 +482,6 @@ class MainActivity : SimpleActivity(), SongListListener {
}

private fun initializePlayer() {
if (!config.wereSongsMigrated) {
Thread {
handleSongMigration()
}.start()
}

if (isThirdPartyIntent) {
initThirdPartyIntent()
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import android.content.Intent
import android.util.TypedValue
import com.simplemobiletools.musicplayer.R
import com.simplemobiletools.musicplayer.databases.SongsDatabase
import com.simplemobiletools.musicplayer.helpers.*
import com.simplemobiletools.musicplayer.helpers.CALL_SETUP_AFTER
import com.simplemobiletools.musicplayer.helpers.Config
import com.simplemobiletools.musicplayer.helpers.PAUSE
import com.simplemobiletools.musicplayer.helpers.REFRESH_LIST
import com.simplemobiletools.musicplayer.interfaces.PlaylistsDao
import com.simplemobiletools.musicplayer.interfaces.SongsDao
import com.simplemobiletools.musicplayer.models.Playlist
Expand All @@ -25,8 +28,6 @@ fun Context.sendIntent(action: String) {

val Context.config: Config get() = Config.newInstance(applicationContext)

val Context.dbHelper: DBHelper get() = DBHelper.newInstance(applicationContext)

val Context.playlistDAO: PlaylistsDao get() = getSongsDB().PlaylistsDao()

val Context.songsDAO: SongsDao get() = getSongsDB().SongsDao()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getInt(SHOW_FILENAME, SHOW_FILENAME_IF_UNAVAILABLE)
set(showFilename) = prefs.edit().putInt(SHOW_FILENAME, showFilename).apply()

var wereSongsMigrated: Boolean
get() = prefs.getBoolean(WERE_SONGS_MIGRATED, false)
set(wereSongsMigrated) = prefs.edit().putBoolean(WERE_SONGS_MIGRATED, wereSongsMigrated).apply()

var swapPrevNext: Boolean
get() = prefs.getBoolean(SWAP_PREV_NEXT, false)
set(swapPrevNext) = prefs.edit().putBoolean(SWAP_PREV_NEXT, swapPrevNext).apply()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const val IGNORED_PATHS = "ignored_paths"
const val CURRENT_PLAYLIST = "current_playlist"
const val SHOW_FILENAME = "show_filename"
const val SHOW_ALBUM_COVER = "show_album_cover"
const val WERE_SONGS_MIGRATED = "were_songs_migrated" // check migration from old sqlite to Room
const val SWAP_PREV_NEXT = "swap_prev_next"

const val LIST_HEADERS_COUNT = 2
Expand Down

This file was deleted.

0 comments on commit 6f877ef

Please sign in to comment.