Created
July 24, 2019 03:19
-
-
Save saturngod/4f88aa5920415d0c430d812c7119f6d6 to your computer and use it in GitHub Desktop.
Check version compare to update or not
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun shouldUpgrade(server_version: String, app_version: String): Boolean { | |
if (server_version == app_version) { | |
return false | |
} | |
val versions = server_version.split(".") | |
val apps = app_version.split(".") | |
for (i in 0..versions.count() - 1) { | |
var first = versions[i] | |
if (apps.count() > i) { | |
var app = apps[i] | |
if (first.toInt() > app.toInt()) { | |
return true | |
} | |
else if (first.toInt() < app.toInt()) { | |
return false | |
} | |
} | |
else { | |
return true | |
} | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment