Fix songs not loading from SD card

main
Hemanth S 2020-09-12 12:23:23 +05:30
parent 0ef83c7136
commit cc494edbbf
5 changed files with 11 additions and 5 deletions

View File

@ -21,4 +21,7 @@ interface PlayCountDao {
@Query("DELETE FROM SongEntity WHERE id =:songId")
fun deleteSong(songId: Int)
@Query("UPDATE PlayCountEntity SET play_count = play_count + 1 WHERE id = :id")
fun updateQuantity(id: Int)
}

View File

@ -5,7 +5,7 @@ import androidx.room.RoomDatabase
@Database(
entities = [PlaylistEntity::class, SongEntity::class, HistoryEntity::class, PlayCountEntity::class, BlackListStoreEntity::class, LyricsEntity::class],
version = 21,
version = 22,
exportSchema = false
)
abstract class RetroDatabase : RoomDatabase() {

View File

@ -3,11 +3,12 @@ package code.name.monkey.retromusic.db
import android.os.Parcelable
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey
import kotlinx.android.parcel.Parcelize
@Parcelize
@Entity
@Entity(indices = [Index(value = ["playlist_creator_id", "id"], unique = true)])
class SongEntity(
@ColumnInfo(name = "playlist_creator_id")
val playlistCreatorId: Int,
@ -35,6 +36,5 @@ class SongEntity(
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "song_key")
var songPrimaryKey: Long = 0
}

View File

@ -64,8 +64,11 @@ class RealRoomRepository(
playlistDao.playlistsWithSongs()
@WorkerThread
override suspend fun insertSongs(songs: List<SongEntity>) =
override suspend fun insertSongs(songs: List<SongEntity>) {
playlistDao.insertSongsToPlaylist(songs)
}
override fun getSongs(playlistEntity: PlaylistEntity): LiveData<List<SongEntity>> =
playlistDao.songsFromPlaylist(playlistEntity.playListId)

View File

@ -155,7 +155,7 @@ class RealSongRepository(private val context: Context) : SongRepository {
val uri = if (VersionUtils.hasQ()) {
MediaStore.Audio.Media.getContentUri(MediaStore.VOLUME_EXTERNAL_PRIMARY)
MediaStore.Audio.Media.getContentUri(MediaStore.VOLUME_EXTERNAL)
} else {
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
}