Fix lateinit initialization issue

pull/1466/head
Alex Baker 5 years ago
parent 4425e29899
commit a02cd7ae71

@ -37,6 +37,7 @@ import net.openid.appauth.RegistrationRequest
import net.openid.appauth.RegistrationResponse import net.openid.appauth.RegistrationResponse
import net.openid.appauth.ResponseTypeValues import net.openid.appauth.ResponseTypeValues
import org.tasks.R import org.tasks.R
import org.tasks.Tasks.Companion.IS_GENERIC
import org.tasks.analytics.Firebase import org.tasks.analytics.Firebase
import org.tasks.billing.Inventory import org.tasks.billing.Inventory
import org.tasks.billing.PurchaseActivity import org.tasks.billing.PurchaseActivity
@ -76,7 +77,8 @@ class SignInActivity : InjectingAppCompatActivity() {
private var mAuthIntentLatch = CountDownLatch(1) private var mAuthIntentLatch = CountDownLatch(1)
private val mExecutor: ExecutorService = newSingleThreadExecutor() private val mExecutor: ExecutorService = newSingleThreadExecutor()
private lateinit var authService: AuthorizationService private val authService: AuthorizationService
get() = viewModel.authService!!
private val configuration: Configuration private val configuration: Configuration
get() = authService.configuration get() = authService.configuration
@ -141,12 +143,10 @@ class SignInActivity : InjectingAppCompatActivity() {
1 -> AuthorizationService.ISS_GITHUB 1 -> AuthorizationService.ISS_GITHUB
else -> throw IllegalArgumentException() else -> throw IllegalArgumentException()
}) })
viewModel.authService?.let { startAuthorization(it) } startAuthorization()
} }
private fun startAuthorization(authService: AuthorizationService) { private fun startAuthorization() {
this.authService = authService
if (authStateManager.current.isAuthorized && if (authStateManager.current.isAuthorized &&
!configuration.hasConfigurationChanged()) { !configuration.hasConfigurationChanged()) {
Timber.i("User is already authenticated, signing out") Timber.i("User is already authenticated, signing out")
@ -169,7 +169,7 @@ class SignInActivity : InjectingAppCompatActivity() {
if (e is HttpException && e.code == 402) { if (e is HttpException && e.code == 402) {
startActivityForResult( startActivityForResult(
Intent(this, PurchaseActivity::class.java) Intent(this, PurchaseActivity::class.java)
.putExtra(EXTRA_GITHUB, authService.isGitHub), .putExtra(EXTRA_GITHUB, viewModel.authService?.isGitHub ?: IS_GENERIC),
RC_PURCHASE RC_PURCHASE
) )
} else { } else {

Loading…
Cancel
Save