Skip to content

Instantly share code, notes, and snippets.

@saturngod
Created July 24, 2019 03:19
Show Gist options
  • Save saturngod/4f88aa5920415d0c430d812c7119f6d6 to your computer and use it in GitHub Desktop.
Save saturngod/4f88aa5920415d0c430d812c7119f6d6 to your computer and use it in GitHub Desktop.
Check version compare to update or not
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