diff --git a/app/src/main/java/phone/vishnu/dialogmusicplayer/MainViewModel.kt b/app/src/main/java/phone/vishnu/dialogmusicplayer/MainViewModel.kt index c5d272b..8ec7e92 100644 --- a/app/src/main/java/phone/vishnu/dialogmusicplayer/MainViewModel.kt +++ b/app/src/main/java/phone/vishnu/dialogmusicplayer/MainViewModel.kt @@ -34,13 +34,13 @@ class MainViewModel(application: Application) : AndroidViewModel(application) { this.repository = SaveItemRepository(application) } - fun insert(saveItem: SaveItem?) { + fun insert(saveItem: SaveItem) { viewModelScope.launch(Dispatchers.IO) { repository?.insertSaveItem(saveItem) } } - fun delete(saveItem: SaveItem?) { + fun delete(saveItem: SaveItem) { viewModelScope.launch(Dispatchers.IO) { repository?.deleteSaveItem(saveItem) } diff --git a/app/src/main/java/phone/vishnu/dialogmusicplayer/SaveItemDao.kt b/app/src/main/java/phone/vishnu/dialogmusicplayer/SaveItemDao.kt index 959afc3..e04c46a 100644 --- a/app/src/main/java/phone/vishnu/dialogmusicplayer/SaveItemDao.kt +++ b/app/src/main/java/phone/vishnu/dialogmusicplayer/SaveItemDao.kt @@ -31,16 +31,16 @@ import androidx.room.Update interface SaveItemDao { @Insert(onConflict = OnConflictStrategy.REPLACE) - fun insert(saveItem: SaveItem?) + fun insert(saveItem: SaveItem) @Update - fun update(saveItem: SaveItem?) + fun update(saveItem: SaveItem) @Delete - fun delete(saveItem: SaveItem?) + fun delete(saveItem: SaveItem) @Query("SELECT * FROM SaveItem") - fun getAll(): LiveData> + fun getAll(): LiveData> @Query("DELETE FROM SaveItem") fun deleteAll() diff --git a/app/src/main/java/phone/vishnu/dialogmusicplayer/SaveItemRepository.kt b/app/src/main/java/phone/vishnu/dialogmusicplayer/SaveItemRepository.kt index 0bd6375..f7680cf 100644 --- a/app/src/main/java/phone/vishnu/dialogmusicplayer/SaveItemRepository.kt +++ b/app/src/main/java/phone/vishnu/dialogmusicplayer/SaveItemRepository.kt @@ -33,15 +33,15 @@ class SaveItemRepository(application: Application?) { return saveItemDao.getSaveItem(id) } - fun insertSaveItem(saveItem: SaveItem?) { + fun insertSaveItem(saveItem: SaveItem) { saveItemDao.insert(saveItem) } - suspend fun updateSaveItem(saveItem: SaveItem?) { + suspend fun updateSaveItem(saveItem: SaveItem) { saveItemDao.update(saveItem) } - fun deleteSaveItem(saveItem: SaveItem?) { + fun deleteSaveItem(saveItem: SaveItem) { saveItemDao.delete(saveItem) }