Kris Wong
10/26/2020, 1:23 PMhandle
...Kris Wong
10/26/2020, 1:23 PMabstract class LockSafeActivity : SDKBaseActivity() {
private var appLocked = true
final override fun onCreate(savedInstanceState: Bundle?) {
appLocked = AppLockedState.isLocked()
super.onCreate(savedInstanceState)
if (appLocked) {
finish()
} else {
handleOnCreate(savedInstanceState)
}
}
protected open fun handleOnCreate(savedInstanceState: Bundle?) = Unit
final override fun onStart() {
super.onStart()
if (!appLocked) {
handleOnStart()
}
}
protected open fun handleOnStart() = Unit
final override fun onPostCreate(savedInstanceState: Bundle?) {
super.onPostCreate(savedInstanceState)
if (!appLocked) {
handleOnPostCreate(savedInstanceState)
}
}
protected open fun handleOnPostCreate(savedInstanceState: Bundle?) = Unit
final override fun onResume() {
super.onResume()
if (!appLocked) {
handleOnResume()
}
}
protected open fun handleOnResume() = Unit
final override fun onPostResume() {
super.onPostResume()
if (!appLocked) {
handleOnPostResume()
}
}
protected open fun handleOnPostResume() = Unit
final override fun onPause() {
super.onPause()
if (!appLocked) {
handleOnPause()
}
}
protected open fun handleOnPause() = Unit
final override fun onStop() {
super.onStop()
if (!appLocked) {
handleOnStop()
}
}
protected open fun handleOnStop() = Unit
final override fun onDestroy() {
super.onDestroy()
if (!appLocked) {
handleOnDestroy()
}
}
protected open fun handleOnDestroy() = Unit
}
Kris Wong
10/26/2020, 1:24 PM