Reformatted with String Interpolation

This commit is contained in:
Sonu Sourav 2020-04-08 20:20:02 +05:30
parent 6aafb3d30d
commit 3fb5321d4f

View File

@ -19,7 +19,6 @@ package org.kiwix.kiwixmobile.core.downloader
import org.kiwix.kiwixmobile.core.utils.StorageUtils.getFileNameFromUrl
import java.util.ArrayList
import java.util.Locale
object ChunkUtils {
private const val ALPHABET = "abcdefghijklmnopqrstuvwxyz"
@ -46,20 +45,12 @@ object ChunkUtils {
): List<Chunk> {
val chunks: MutableList<Chunk> = ArrayList()
var currentRange: Long = 0
var minLen: Long
for (zim in fileNames) {
minLen = minOf(
contentLength, (currentRange + CHUNK_SIZE)
)
val minLen: Long = minOf(contentLength, (currentRange + CHUNK_SIZE))
val range: String = if (currentRange + CHUNK_SIZE >= contentLength) {
String.format(Locale.US, "%d-", currentRange)
"$currentRange-"
} else {
String.format(
Locale.US,
"%d-%d",
currentRange,
currentRange + CHUNK_SIZE
)
"$currentRange-${currentRange + CHUNK_SIZE}"
}
chunks.add(
Chunk(