fixing a ConcurrentModificationException
This commit is contained in:
parent
215c26fc2e
commit
f5dcac2163
2 changed files with 12 additions and 6 deletions
|
@ -70,7 +70,7 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:f74a128e2e'
|
||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:ffead928f7'
|
||||
implementation 'org.greenrobot:eventbus:3.3.1'
|
||||
implementation 'androidx.media:media:1.6.0'
|
||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||
|
|
|
@ -30,10 +30,7 @@ import androidx.media.session.MediaButtonReceiver
|
|||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
import com.simplemobiletools.commons.helpers.isMarshmallowPlus
|
||||
import com.simplemobiletools.commons.helpers.isOreoPlus
|
||||
import com.simplemobiletools.commons.helpers.isQPlus
|
||||
import com.simplemobiletools.commons.helpers.*
|
||||
import com.simplemobiletools.musicplayer.R
|
||||
import com.simplemobiletools.musicplayer.activities.MainActivity
|
||||
import com.simplemobiletools.musicplayer.databases.SongsDatabase
|
||||
|
@ -236,7 +233,16 @@ class MusicService : Service(), MediaPlayer.OnPreparedListener, MediaPlayer.OnEr
|
|||
mTracks = getQueuedTracks()
|
||||
|
||||
val wantedTrackId = intent?.getLongExtra(TRACK_ID, -1L)
|
||||
mCurrTrack = mTracks.firstOrNull { it.mediaStoreId == wantedTrackId }
|
||||
|
||||
// use an oldschool loop to avoid ConcurrentModificationException
|
||||
for (i in 0 until mTracks.size) {
|
||||
val track = mTracks[i]
|
||||
if (track.mediaStoreId == wantedTrackId) {
|
||||
mCurrTrack = track
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
checkTrackOrder()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue