Skip to content

Commit 5e399e3

Browse files
committed
Some Issues Fixed Related to Favourites.
1 parent d5f6256 commit 5e399e3

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

app/src/main/java/com/harshRajpurohit/musicPlayer/Music.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,17 @@ fun favouriteChecker(id: String): Int{
6464
return -1
6565
}
6666
fun checkPlaylist(playlist: ArrayList<Music>): ArrayList<Music>{
67-
playlist.forEachIndexed { index, music ->
67+
val iter = playlist.iterator()
68+
while(iter.hasNext()){
69+
val music = iter.next()
6870
val file = File(music.path)
6971
if(!file.exists())
70-
playlist.removeAt(index)
71-
}
72+
playlist.remove(music)
73+
}
74+
// playlist.forEachIndexed { index, music ->
75+
// val file = File(music.path)
76+
// if(!file.exists())
77+
// playlist.removeAt(index)
78+
// }
7279
return playlist
7380
}

app/src/main/java/com/harshRajpurohit/musicPlayer/PlayerActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class PlayerActivity : AppCompatActivity(), ServiceConnection, MediaPlayer.OnCom
130130

131131
}
132132
binding.favouriteBtnPA.setOnClickListener {
133+
fIndex = favouriteChecker(musicListPA[songPosition].id)
133134
if(isFavourite){
134135
isFavourite = false
135136
binding.favouriteBtnPA.setImageResource(R.drawable.favourite_empty_icon)

0 commit comments

Comments
 (0)