Fix songs not loading from SD card
This commit is contained in:
parent
0ef83c7136
commit
cc494edbbf
5 changed files with 11 additions and 5 deletions
|
@ -21,4 +21,7 @@ interface PlayCountDao {
|
||||||
|
|
||||||
@Query("DELETE FROM SongEntity WHERE id =:songId")
|
@Query("DELETE FROM SongEntity WHERE id =:songId")
|
||||||
fun deleteSong(songId: Int)
|
fun deleteSong(songId: Int)
|
||||||
|
|
||||||
|
@Query("UPDATE PlayCountEntity SET play_count = play_count + 1 WHERE id = :id")
|
||||||
|
fun updateQuantity(id: Int)
|
||||||
}
|
}
|
|
@ -5,7 +5,7 @@ import androidx.room.RoomDatabase
|
||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
entities = [PlaylistEntity::class, SongEntity::class, HistoryEntity::class, PlayCountEntity::class, BlackListStoreEntity::class, LyricsEntity::class],
|
entities = [PlaylistEntity::class, SongEntity::class, HistoryEntity::class, PlayCountEntity::class, BlackListStoreEntity::class, LyricsEntity::class],
|
||||||
version = 21,
|
version = 22,
|
||||||
exportSchema = false
|
exportSchema = false
|
||||||
)
|
)
|
||||||
abstract class RetroDatabase : RoomDatabase() {
|
abstract class RetroDatabase : RoomDatabase() {
|
||||||
|
|
|
@ -3,11 +3,12 @@ package code.name.monkey.retromusic.db
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import androidx.room.ColumnInfo
|
import androidx.room.ColumnInfo
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
|
import androidx.room.Index
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
import kotlinx.android.parcel.Parcelize
|
import kotlinx.android.parcel.Parcelize
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
@Entity
|
@Entity(indices = [Index(value = ["playlist_creator_id", "id"], unique = true)])
|
||||||
class SongEntity(
|
class SongEntity(
|
||||||
@ColumnInfo(name = "playlist_creator_id")
|
@ColumnInfo(name = "playlist_creator_id")
|
||||||
val playlistCreatorId: Int,
|
val playlistCreatorId: Int,
|
||||||
|
@ -35,6 +36,5 @@ class SongEntity(
|
||||||
@PrimaryKey(autoGenerate = true)
|
@PrimaryKey(autoGenerate = true)
|
||||||
@ColumnInfo(name = "song_key")
|
@ColumnInfo(name = "song_key")
|
||||||
var songPrimaryKey: Long = 0
|
var songPrimaryKey: Long = 0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,11 @@ class RealRoomRepository(
|
||||||
playlistDao.playlistsWithSongs()
|
playlistDao.playlistsWithSongs()
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
override suspend fun insertSongs(songs: List<SongEntity>) =
|
override suspend fun insertSongs(songs: List<SongEntity>) {
|
||||||
|
|
||||||
playlistDao.insertSongsToPlaylist(songs)
|
playlistDao.insertSongsToPlaylist(songs)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun getSongs(playlistEntity: PlaylistEntity): LiveData<List<SongEntity>> =
|
override fun getSongs(playlistEntity: PlaylistEntity): LiveData<List<SongEntity>> =
|
||||||
playlistDao.songsFromPlaylist(playlistEntity.playListId)
|
playlistDao.songsFromPlaylist(playlistEntity.playListId)
|
||||||
|
|
|
@ -155,7 +155,7 @@ class RealSongRepository(private val context: Context) : SongRepository {
|
||||||
|
|
||||||
|
|
||||||
val uri = if (VersionUtils.hasQ()) {
|
val uri = if (VersionUtils.hasQ()) {
|
||||||
MediaStore.Audio.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY)
|
MediaStore.Audio.Media.getContentUri(MediaStore.VOLUME_EXTERNAL)
|
||||||
} else {
|
} else {
|
||||||
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
|
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue