Last active
February 5, 2018 08:44
-
-
Save Elvis10ten/6d9b117f0559cb4e8400f72b675ec9bd to your computer and use it in GitHub Desktop.
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
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