Code Cleanup
This commit is contained in:
parent
7f3b2b3d91
commit
8a050e114b
2 changed files with 15 additions and 30 deletions
|
@ -93,7 +93,7 @@ dependencies {
|
|||
implementation "androidx.appcompat:appcompat:$appcompat_version"
|
||||
implementation 'androidx.annotation:annotation:1.3.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.3.0-alpha01'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||
implementation "androidx.preference:preference-ktx:$preference_version"
|
||||
implementation 'androidx.core:core-ktx:1.7.0'
|
||||
implementation 'androidx.palette:palette-ktx:1.0.0'
|
||||
|
|
|
@ -35,7 +35,7 @@ import kotlinx.coroutines.withContext
|
|||
import java.io.File
|
||||
|
||||
class LibraryViewModel(
|
||||
private val repository: RealRepository
|
||||
private val repository: RealRepository,
|
||||
) : ViewModel(), IMusicServiceEventListener {
|
||||
|
||||
private val _paletteColor = MutableLiveData<Int>()
|
||||
|
@ -380,6 +380,14 @@ class LibraryViewModel(
|
|||
createPlaylist(PlaylistEntity(playlistName = playlistName))
|
||||
insertSongs(songs.map { it.toSongEntity(playlistId) })
|
||||
forceReload(Playlists)
|
||||
withContext(Main) {
|
||||
Toast.makeText(
|
||||
App.getContext(),
|
||||
App.getContext()
|
||||
.getString(R.string.playlist_created_sucessfully, playlistName),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
} else {
|
||||
val playlist = playlists.firstOrNull()
|
||||
if (playlist != null) {
|
||||
|
@ -389,34 +397,11 @@ class LibraryViewModel(
|
|||
}
|
||||
}
|
||||
withContext(Main) {
|
||||
when {
|
||||
playlists.isEmpty() -> {
|
||||
Toast.makeText(
|
||||
App.getContext(),
|
||||
App.getContext()
|
||||
.getString(R.string.playlist_created_sucessfully, playlistName),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
checkPlaylistExists(playlistName).isNotEmpty() -> {
|
||||
Toast.makeText(
|
||||
App.getContext(),
|
||||
App.getContext().getString(R.string.playList_already_exits),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
playlists.isNotEmpty() -> {
|
||||
Toast.makeText(
|
||||
App.getContext(),
|
||||
App.getContext().getString(
|
||||
Toast.makeText(App.getContext(), App.getContext().getString(
|
||||
R.string.added_song_count_to_playlist,
|
||||
songs.size,
|
||||
playlistName
|
||||
),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue