Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
ZTFtrue committed Jan 27, 2024
1 parent e071f83 commit c813168
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions app/src/main/java/com/ztftrue/music/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1070,14 +1070,14 @@ class MainActivity : ComponentActivity() {
}
}
if (showCreatePlayListDialogForQueue) {
CreatePlayListDialog(musicViewModel, onDismiss = {
CreatePlayListDialog(musicViewModel, onDismiss = { playListName ->
showCreatePlayListDialogForQueue = false
if (!it.isNullOrEmpty()) {
if (!playListName.isNullOrEmpty()) {
val ids = ArrayList<Long>(musicViewModel.musicQueue.size)
musicViewModel.musicQueue.forEach {
ids.add(it.id)
}
val idPlayList = PlaylistManager.createPlaylist(context, it)
val idPlayList = PlaylistManager.createPlaylist(context, playListName)
if (idPlayList != -1L) {
PlaylistManager.addMusicsToPlaylist(
context,
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/ztftrue/music/play/PlayService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ class PlayService : MediaBrowserServiceCompat() {
}
}

var errorCount = 0;
var errorCount = 0
private fun playerAddListener() {
exoPlayer.addListener(@UnstableApi object : Player.Listener {
override fun onIsPlayingChanged(isPlaying: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ fun MusicItemView(
}

OperateType.RemoveFromQueue -> {
val indexM = viewModel.musicQueue.indexOfFirst { it.id == music.id }
val indexM = viewModel.musicQueue.indexOfFirst { musicItem -> musicItem.id == music.id }
if(indexM == -1) return@OperateDialog
val bundle = Bundle()
bundle.putInt("index", indexM)
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/ztftrue/music/ui/public/QueuePage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ fun QueuePage(
}
}
if (showCreatePlayListDialog) {
CreatePlayListDialog(musicViewModel, onDismiss = {
CreatePlayListDialog(musicViewModel, onDismiss = { playListName ->
showCreatePlayListDialog = false
if (!it.isNullOrEmpty()) {
if (!playListName.isNullOrEmpty()) {
val ids = ArrayList<Long>(musicList.size)
musicList.forEach {
ids.add(it.id)
}
val idPlayList = PlaylistManager.createPlaylist(context, it)
val idPlayList = PlaylistManager.createPlaylist(context, playListName)
if (idPlayList != -1L) {
PlaylistManager.addMusicsToPlaylist(context, idPlayList, ids)
musicViewModel.mediaBrowser?.sendCustomAction(
Expand Down

0 comments on commit c813168

Please sign in to comment.