Fix music load failure [Resolves #4]
Remove the `check` statements from `applyAlbum` and `applyGenre` that could cause the music loading to fail on some devices. Now only the first album/genre applied will stick. This resolves issue #4.
This commit is contained in:
parent
e3e0015237
commit
0a7fbeca6d
2 changed files with 7 additions and 11 deletions
|
@ -56,9 +56,7 @@ class LoadingFragment : Fragment() {
|
||||||
null -> showLoading(binding)
|
null -> showLoading(binding)
|
||||||
|
|
||||||
// Anything else is an error
|
// Anything else is an error
|
||||||
else -> {
|
else -> showError(binding, response)
|
||||||
showError(binding, response)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,23 +55,21 @@ data class Song(
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply a genre to a song.
|
* Apply a genre to a song.
|
||||||
* @throws IllegalStateException When a genre is already applied.
|
|
||||||
*/
|
*/
|
||||||
fun applyGenre(genre: Genre) {
|
fun applyGenre(genre: Genre) {
|
||||||
check(mGenre == null) { "Genre is already applied" }
|
if (mGenre == null) {
|
||||||
|
|
||||||
mGenre = genre
|
mGenre = genre
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply an album to a song.
|
* Apply an album to a song.
|
||||||
* @throws IllegalStateException When an album is already applied.
|
|
||||||
*/
|
*/
|
||||||
fun applyAlbum(album: Album) {
|
fun applyAlbum(album: Album) {
|
||||||
check(mAlbum == null) { "Album is already applied" }
|
if (mAlbum == null) {
|
||||||
|
|
||||||
mAlbum = album
|
mAlbum = album
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val seconds = duration / 1000
|
val seconds = duration / 1000
|
||||||
val formattedDuration: String = seconds.toDuration()
|
val formattedDuration: String = seconds.toDuration()
|
||||||
|
|
Loading…
Reference in a new issue