From c81316843e3ee63bee0077369b0afca565c33bd5 Mon Sep 17 00:00:00 2001 From: ztftrue Date: Sat, 27 Jan 2024 17:09:23 +0800 Subject: [PATCH] clean code --- app/src/main/java/com/ztftrue/music/MainActivity.kt | 6 +++--- app/src/main/java/com/ztftrue/music/play/PlayService.kt | 2 +- .../main/java/com/ztftrue/music/ui/public/MusicItemView.kt | 2 +- app/src/main/java/com/ztftrue/music/ui/public/QueuePage.kt | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/ztftrue/music/MainActivity.kt b/app/src/main/java/com/ztftrue/music/MainActivity.kt index 539410a..d1c6073 100644 --- a/app/src/main/java/com/ztftrue/music/MainActivity.kt +++ b/app/src/main/java/com/ztftrue/music/MainActivity.kt @@ -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(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, diff --git a/app/src/main/java/com/ztftrue/music/play/PlayService.kt b/app/src/main/java/com/ztftrue/music/play/PlayService.kt index 2e1f448..050cbc2 100644 --- a/app/src/main/java/com/ztftrue/music/play/PlayService.kt +++ b/app/src/main/java/com/ztftrue/music/play/PlayService.kt @@ -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) { diff --git a/app/src/main/java/com/ztftrue/music/ui/public/MusicItemView.kt b/app/src/main/java/com/ztftrue/music/ui/public/MusicItemView.kt index 34a0684..bdb880e 100644 --- a/app/src/main/java/com/ztftrue/music/ui/public/MusicItemView.kt +++ b/app/src/main/java/com/ztftrue/music/ui/public/MusicItemView.kt @@ -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) diff --git a/app/src/main/java/com/ztftrue/music/ui/public/QueuePage.kt b/app/src/main/java/com/ztftrue/music/ui/public/QueuePage.kt index a54c62f..8b3ccb1 100644 --- a/app/src/main/java/com/ztftrue/music/ui/public/QueuePage.kt +++ b/app/src/main/java/com/ztftrue/music/ui/public/QueuePage.kt @@ -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(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(