Skip to content

Instantly share code, notes, and snippets.

@Elvis10ten
Last active February 5, 2018 08:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Elvis10ten/6d9b117f0559cb4e8400f72b675ec9bd to your computer and use it in GitHub Desktop.
Save Elvis10ten/6d9b117f0559cb4e8400f72b675ec9bd to your computer and use it in GitHub Desktop.
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
class SplashActivity: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
// Make sure this is before calling super.onCreate
setTheme(R.style.AppTheme)
super.onCreate(savedInstanceState)
val user = UserDb.getCurrentUser()
routeToAppropriatePage(user)
finish()
}
private fun routeToAppropriatePage(user: User) {
// Example routing
when {
user == null -> OnboardingActivity.start(this)
user.hasPhoneNumber() -> EditProfileActivity.start(this)
user.hasSubscriptionExpired() -> PaymentPlansActivity.start(this)
else -> HomeActivity.start(this)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment