Added App rater

This commit is contained in:
h4h13 2019-09-23 00:26:40 +05:30
parent 07b1559350
commit b665ffd25f
14 changed files with 322 additions and 31 deletions

View file

@ -20,6 +20,8 @@ import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView
import java.io.File
import java.text.DecimalFormat
import java.util.*
import kotlin.math.log10
import kotlin.math.pow
class SongFileAdapter(
@ -174,10 +176,10 @@ class SongFileAdapter(
private const val FOLDER = 1
fun readableFileSize(size: Long): String {
if (size <= 0) return size.toString() + " B"
if (size <= 0) return "$size B"
val units = arrayOf("B", "KB", "MB", "GB", "TB")
val digitGroups = (Math.log10(size.toDouble()) / Math.log10(1024.0)).toInt()
return DecimalFormat("#,##0.##").format(size / Math.pow(1024.0, digitGroups.toDouble())) + " " + units[digitGroups]
val digitGroups = (log10(size.toDouble()) / log10(1024.0)).toInt()
return DecimalFormat("#,##0.##").format(size / 1024.0.pow(digitGroups.toDouble())) + " " + units[digitGroups]
}
}
}