From 4b413b78fe8289d454969f8eb72214458fe15641 Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Sun, 14 Apr 2024 23:30:52 -0500 Subject: [PATCH] fix: alpha update message --- .../java/ani/dantotsu/others/AppUpdater.kt | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/app/src/google/java/ani/dantotsu/others/AppUpdater.kt b/app/src/google/java/ani/dantotsu/others/AppUpdater.kt index 3b952fb9..27bd5263 100644 --- a/app/src/google/java/ani/dantotsu/others/AppUpdater.kt +++ b/app/src/google/java/ani/dantotsu/others/AppUpdater.kt @@ -126,23 +126,25 @@ object AppUpdater { } private fun compareVersion(version: String): Boolean { - if (BuildConfig.BUILD_TYPE == "debug" || BuildConfig.BUILD_TYPE == "alpha") { - return BuildConfig.VERSION_NAME != version - } else { - fun toDouble(list: List): Double { - return list.mapIndexed { i: Int, s: String -> - when (i) { - 0 -> s.toDouble() * 100 - 1 -> s.toDouble() * 10 - 2 -> s.toDouble() - else -> s.toDoubleOrNull() ?: 0.0 - } - }.sum() - } + return when (BuildConfig.BUILD_TYPE) { + "debug" -> BuildConfig.VERSION_NAME != version + "alpha" -> false + else -> { + fun toDouble(list: List): Double { + return list.mapIndexed { i: Int, s: String -> + when (i) { + 0 -> s.toDouble() * 100 + 1 -> s.toDouble() * 10 + 2 -> s.toDouble() + else -> s.toDoubleOrNull() ?: 0.0 + } + }.sum() + } - val new = toDouble(version.split(".")) - val curr = toDouble(BuildConfig.VERSION_NAME.split(".")) - return new > curr + val new = toDouble(version.split(".")) + val curr = toDouble(BuildConfig.VERSION_NAME.split(".")) + new > curr + } } }