Skip to content

Commit

Permalink
Remove LiveData from PaymentAuthWebViewClient. (#7519)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaynewstrom-stripe authored Oct 27, 2023
1 parent a831aff commit 73d9b5a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import androidx.annotation.ColorInt
import androidx.annotation.VisibleForTesting
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isGone
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.lifecycleScope
import com.stripe.android.R
import com.stripe.android.StripeIntentResult
import com.stripe.android.auth.PaymentBrowserAuthContract
Expand All @@ -21,6 +21,8 @@ import com.stripe.android.core.exception.StripeException
import com.stripe.android.databinding.StripePaymentAuthWebViewActivityBinding
import com.stripe.android.payments.PaymentFlowResult
import com.stripe.android.stripe3ds2.utils.CustomizeUtils
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch

class PaymentAuthWebViewActivity : AppCompatActivity() {

Expand Down Expand Up @@ -79,10 +81,12 @@ class PaymentAuthWebViewActivity : AppCompatActivity() {

logger.debug("PaymentAuthWebViewActivity#onCreate() - PaymentAuthWebView init and loadUrl")

val isPagedLoaded = MutableLiveData(false)
isPagedLoaded.observe(this) { shouldHide ->
if (shouldHide) {
viewBinding.progressBar.isGone = true
val isPagedLoaded = MutableStateFlow(false)
lifecycleScope.launch {
isPagedLoaded.collect { shouldHide ->
if (shouldHide) {
viewBinding.progressBar.isGone = true
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.annotation.VisibleForTesting
import androidx.lifecycle.MutableLiveData
import com.stripe.android.core.Logger
import com.stripe.android.payments.DefaultReturnUrl
import kotlinx.coroutines.flow.MutableStateFlow

internal class PaymentAuthWebViewClient(
private val logger: Logger,
private val isPageLoaded: MutableLiveData<Boolean>,
private val isPageLoaded: MutableStateFlow<Boolean>,
private val clientSecret: String,
returnUrl: String?,
private val activityStarter: (Intent) -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import android.content.Intent
import android.net.Uri
import android.webkit.WebResourceRequest
import android.webkit.WebView
import androidx.lifecycle.MutableLiveData
import androidx.test.core.app.ApplicationProvider
import com.google.common.truth.Truth.assertThat
import com.stripe.android.FakeLogger
import com.stripe.android.payments.DefaultReturnUrl
import com.stripe.android.view.PaymentAuthWebViewClient.Companion.isCompletionUrl
import kotlinx.coroutines.flow.MutableStateFlow
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import kotlin.test.Test

@RunWith(RobolectricTestRunner::class)
class PaymentAuthWebViewClientTest {
private val isPageLoaded = MutableLiveData(false)
private val isPageLoaded = MutableStateFlow(false)

private val onAuthCompletedErrors = mutableListOf<Throwable>()
private var activityFinished = false
Expand Down

0 comments on commit 73d9b5a

Please sign in to comment.