fixed lint warning
This commit is contained in:
parent
18c31a5704
commit
51ff716ff5
|
@ -251,15 +251,15 @@ open class APIDataSource private constructor(
|
||||||
@Suppress("ThrowsCount")
|
@Suppress("ThrowsCount")
|
||||||
@Throws(HttpDataSourceException::class)
|
@Throws(HttpDataSourceException::class)
|
||||||
private fun skipFully(bytesToSkip: Long, dataSpec: DataSpec) {
|
private fun skipFully(bytesToSkip: Long, dataSpec: DataSpec) {
|
||||||
var bytesToSkip = bytesToSkip
|
var bytesToSkipCpy = bytesToSkip
|
||||||
if (bytesToSkip == 0L) {
|
if (bytesToSkipCpy == 0L) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val skipBuffer = ByteArray(4096)
|
val skipBuffer = ByteArray(4096)
|
||||||
try {
|
try {
|
||||||
while (bytesToSkip > 0) {
|
while (bytesToSkipCpy > 0) {
|
||||||
val readLength =
|
val readLength =
|
||||||
bytesToSkip.coerceAtMost(skipBuffer.size.toLong()).toInt()
|
bytesToSkipCpy.coerceAtMost(skipBuffer.size.toLong()).toInt()
|
||||||
val read = Util.castNonNull(responseByteStream).read(skipBuffer, 0, readLength)
|
val read = Util.castNonNull(responseByteStream).read(skipBuffer, 0, readLength)
|
||||||
if (Thread.currentThread().isInterrupted) {
|
if (Thread.currentThread().isInterrupted) {
|
||||||
throw InterruptedIOException()
|
throw InterruptedIOException()
|
||||||
|
@ -271,7 +271,7 @@ open class APIDataSource private constructor(
|
||||||
HttpDataSourceException.TYPE_OPEN
|
HttpDataSourceException.TYPE_OPEN
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
bytesToSkip -= read.toLong()
|
bytesToSkipCpy -= read.toLong()
|
||||||
bytesTransferred(read)
|
bytesTransferred(read)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -305,8 +305,8 @@ open class APIDataSource private constructor(
|
||||||
*/
|
*/
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
private fun readInternal(buffer: ByteArray, offset: Int, readLength: Int): Int {
|
private fun readInternal(buffer: ByteArray, offset: Int, readLength: Int): Int {
|
||||||
var readLength = readLength
|
var readLengthCpy = readLength
|
||||||
if (readLength == 0) {
|
if (readLengthCpy == 0) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if (bytesToRead != C.LENGTH_UNSET.toLong()) {
|
if (bytesToRead != C.LENGTH_UNSET.toLong()) {
|
||||||
|
@ -314,9 +314,9 @@ open class APIDataSource private constructor(
|
||||||
if (bytesRemaining == 0L) {
|
if (bytesRemaining == 0L) {
|
||||||
return C.RESULT_END_OF_INPUT
|
return C.RESULT_END_OF_INPUT
|
||||||
}
|
}
|
||||||
readLength = readLength.toLong().coerceAtMost(bytesRemaining).toInt()
|
readLengthCpy = readLengthCpy.toLong().coerceAtMost(bytesRemaining).toInt()
|
||||||
}
|
}
|
||||||
val read = Util.castNonNull(responseByteStream).read(buffer, offset, readLength)
|
val read = Util.castNonNull(responseByteStream).read(buffer, offset, readLengthCpy)
|
||||||
if (read == -1) {
|
if (read == -1) {
|
||||||
return C.RESULT_END_OF_INPUT
|
return C.RESULT_END_OF_INPUT
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,8 +101,8 @@ class CachedDataSource(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun readInternal(buffer: ByteArray, offset: Int, readLength: Int): Int {
|
private fun readInternal(buffer: ByteArray, offset: Int, readLength: Int): Int {
|
||||||
var readLength = readLength
|
var readLengthCpy = readLength
|
||||||
if (readLength == 0) {
|
if (readLengthCpy == 0) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if (bytesToRead != C.LENGTH_UNSET.toLong()) {
|
if (bytesToRead != C.LENGTH_UNSET.toLong()) {
|
||||||
|
@ -110,9 +110,9 @@ class CachedDataSource(
|
||||||
if (bytesRemaining == 0L) {
|
if (bytesRemaining == 0L) {
|
||||||
return C.RESULT_END_OF_INPUT
|
return C.RESULT_END_OF_INPUT
|
||||||
}
|
}
|
||||||
readLength = readLength.toLong().coerceAtMost(bytesRemaining).toInt()
|
readLengthCpy = readLengthCpy.toLong().coerceAtMost(bytesRemaining).toInt()
|
||||||
}
|
}
|
||||||
val read = Util.castNonNull(responseByteStream).read(buffer, offset, readLength)
|
val read = Util.castNonNull(responseByteStream).read(buffer, offset, readLengthCpy)
|
||||||
if (read == -1) {
|
if (read == -1) {
|
||||||
Timber.i("CachedDatasource: EndOfInput")
|
Timber.i("CachedDatasource: EndOfInput")
|
||||||
return C.RESULT_END_OF_INPUT
|
return C.RESULT_END_OF_INPUT
|
||||||
|
@ -134,15 +134,15 @@ class CachedDataSource(
|
||||||
@Suppress("ThrowsCount")
|
@Suppress("ThrowsCount")
|
||||||
@Throws(HttpDataSourceException::class)
|
@Throws(HttpDataSourceException::class)
|
||||||
private fun skipFully(bytesToSkip: Long, dataSpec: DataSpec) {
|
private fun skipFully(bytesToSkip: Long, dataSpec: DataSpec) {
|
||||||
var bytesToSkip = bytesToSkip
|
var bytesToSkipCpy = bytesToSkip
|
||||||
if (bytesToSkip == 0L) {
|
if (bytesToSkipCpy == 0L) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val skipBuffer = ByteArray(4096)
|
val skipBuffer = ByteArray(4096)
|
||||||
try {
|
try {
|
||||||
while (bytesToSkip > 0) {
|
while (bytesToSkipCpy > 0) {
|
||||||
val readLength =
|
val readLength =
|
||||||
bytesToSkip.coerceAtMost(skipBuffer.size.toLong()).toInt()
|
bytesToSkipCpy.coerceAtMost(skipBuffer.size.toLong()).toInt()
|
||||||
val read = Util.castNonNull(responseByteStream).read(skipBuffer, 0, readLength)
|
val read = Util.castNonNull(responseByteStream).read(skipBuffer, 0, readLength)
|
||||||
if (Thread.currentThread().isInterrupted) {
|
if (Thread.currentThread().isInterrupted) {
|
||||||
throw InterruptedIOException()
|
throw InterruptedIOException()
|
||||||
|
@ -154,7 +154,7 @@ class CachedDataSource(
|
||||||
HttpDataSourceException.TYPE_OPEN
|
HttpDataSourceException.TYPE_OPEN
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
bytesToSkip -= read.toLong()
|
bytesToSkipCpy -= read.toLong()
|
||||||
bytesTransferred(read)
|
bytesTransferred(read)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue