open-learning-exchange / myplanet

🌕 myPlanet android app reads data from 🌎 for offline use as well as it collect usage data and sends them back to the Planet.
GNU Affero General Public License v3.0
23 stars 25 forks source link

actions: less warnings is more (fixes #3671) #3672

Closed ewhang5 closed 1 week ago

ewhang5 commented 1 week ago

fixes #3671

ewhang5 commented 1 week ago

@Okuro3499 addressed your comment.

ewhang5 commented 1 week ago

@ewhang5 this can be refactored to something like this. currently it seems to have repetitive lines

val versionInfo = if (Build.VERSION.SDK_INT >= TIRAMISU) {
    intent.getSerializableExtra("versionInfo", MyPlanet::class.java)
} else {
    @Suppress("DEPRECATION")
    intent.getSerializableExtra("versionInfo") as? MyPlanet
}

if (versionInfo != null) {
    onUpdateAvailable(versionInfo, intent.getBooleanExtra("cancelable", false))
} else {
    service.checkVersion(this, settings)
}

addressed your comment