Fix null download units

Resolves : #687, #674
This commit is contained in:
Rahul Kumar Patel
2021-09-12 14:48:36 +05:30
parent 145da38644
commit 934a96fb11
2 changed files with 12 additions and 3 deletions

View File

@@ -30,6 +30,7 @@ import kotlin.math.pow
object CommonUtil {
private val siPrefixes: Map<Int, String> = hashMapOf(
Pair(0, ""),
Pair(1, ""),
Pair(3, " KB"),
Pair(6, " MB"),
@@ -37,6 +38,7 @@ object CommonUtil {
)
private val diPrefixes: Map<Int, String> = hashMapOf(
Pair(0, ""),
Pair(1, ""),
Pair(3, " K"),
Pair(6, " M"),
@@ -44,7 +46,7 @@ object CommonUtil {
)
fun addSiPrefix(value: Long): String {
if (value <= 0L)
if (value <= 1L)
return "NA"
var tempValue = value
var order = 0
@@ -56,7 +58,7 @@ object CommonUtil {
}
fun addDiPrefix(value: Long): String {
if (value <= 0L)
if (value <= 1L)
return "NA"
var tempValue = value
var order = 0

View File

@@ -67,7 +67,14 @@ abstract class BaseDetailsActivity : BaseActivity() {
//Sub Section Inflation
fun inflateAppDescription(B: LayoutDetailsDescriptionBinding, app: App) {
B.txtInstalls.text = CommonUtil.addDiPrefix(app.installs)
val installs = CommonUtil.addDiPrefix(app.installs)
if (installs != "NA") {
B.txtInstalls.text = CommonUtil.addDiPrefix(app.installs)
} else {
B.txtInstalls.hide()
}
B.txtSize.text = CommonUtil.addSiPrefix(app.size)
B.txtRating.text = app.labeledRating
B.txtSdk.text = ("Target SDK ${app.targetSdk}")