Private BufferTask() accepts only non-null now

This commit is contained in:
tzugen 2021-03-24 16:39:34 +01:00
parent 2171c971a3
commit 8d65b1d25f
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
1 changed files with 7 additions and 7 deletions

View File

@ -616,9 +616,10 @@ class LocalMediaPlayer(private val audioFocusHandler: AudioFocusHandler, private
}
}
private inner class BufferTask(private val downloadFile: DownloadFile?, private val position: Int) : CancellableTask() {
private inner class BufferTask(private val downloadFile: DownloadFile, private val position: Int) : CancellableTask() {
private val expectedFileSize: Long
private val partialFile: File
private val partialFile: File = downloadFile.partialFile
override fun execute() {
setPlayerState(PlayerState.DOWNLOADING)
while (!bufferComplete() && !isOffline(context)) {
@ -627,13 +628,13 @@ class LocalMediaPlayer(private val audioFocusHandler: AudioFocusHandler, private
return
}
}
if (downloadFile != null) {
doPlay(downloadFile, position, true)
}
doPlay(downloadFile, position, true)
}
private fun bufferComplete(): Boolean {
val completeFileAvailable = downloadFile!!.isWorkDone
val completeFileAvailable = downloadFile.isWorkDone
val size = partialFile.length()
Timber.i("Buffering %s (%d/%d, %s)", partialFile, size, expectedFileSize, completeFileAvailable)
return completeFileAvailable || size >= expectedFileSize
@ -644,7 +645,6 @@ class LocalMediaPlayer(private val audioFocusHandler: AudioFocusHandler, private
}
init {
partialFile = downloadFile!!.partialFile
var bufferLength = Util.getBufferLength(context).toLong()
if (bufferLength == 0L) {
// Set to seconds in a day, basically infinity