diff --git a/app/src/main/java/checkout/checkout_android/CVVTokenizationActivity.java b/app/src/main/java/checkout/checkout_android/CVVTokenizationActivity.java index 110b0c41..ae0aa6bd 100644 --- a/app/src/main/java/checkout/checkout_android/CVVTokenizationActivity.java +++ b/app/src/main/java/checkout/checkout_android/CVVTokenizationActivity.java @@ -91,15 +91,15 @@ private void initViews() { private void createCVVComponentMediator(CVVComponentApi cvvComponentApi) { // Create config for CVV component - CVVComponentConfig visaCVVComponentConfig = new CVVComponentConfig( + final CVVComponentConfig visaCVVComponentConfig = new CVVComponentConfig( CardScheme.Companion.fromString("unknown"), isEnteredCVVValid -> Unit.INSTANCE, DefaultCVVInputFieldStyle.INSTANCE.create() ); // Create CVVComponentMediator for CVV component - CVVComponentMediator defaultCVVComponentMediator = cvvComponentApi.createComponentMediator(visaCVVComponentConfig); - View defaultCVVComponentView = defaultCVVComponentMediator.provideCvvComponentContent(cvvComponentLinearLayout); + final CVVComponentMediator defaultCVVComponentMediator = cvvComponentApi.createComponentMediator(visaCVVComponentConfig); + final View defaultCVVComponentView = defaultCVVComponentMediator.provideCvvComponentContent(cvvComponentLinearLayout); // Add defaultCVVComponent as view in parent layout cvvComponentLinearLayout.addView(defaultCVVComponentView); @@ -109,7 +109,7 @@ private void createCVVComponentMediator(CVVComponentApi cvvComponentApi) { private void createAMEXCVVComponentMediator(CVVComponentApi cvvComponentApi) { - CVVComponentConfig visaCVVComponentConfig = new CVVComponentConfig( + final CVVComponentConfig visaCVVComponentConfig = new CVVComponentConfig( CardScheme.Companion.fromString("American_express"), isEnteredCVVValid -> { cvvTokenizationViewModel.setIsAmexCVVValid(isEnteredCVVValid); @@ -124,9 +124,9 @@ null, new TextStyle(), ) ); - CVVComponentMediator amexCVVComponentMediator = cvvComponentApi.createComponentMediator(visaCVVComponentConfig); + final CVVComponentMediator amexCVVComponentMediator = cvvComponentApi.createComponentMediator(visaCVVComponentConfig); - View amexCVVComponentView = amexCVVComponentMediator.provideCvvComponentContent(amexCustomCVVComponentLinearLayout); + final View amexCVVComponentView = amexCVVComponentMediator.provideCvvComponentContent(amexCustomCVVComponentLinearLayout); amexCustomCVVComponentLinearLayout.addView(amexCVVComponentView); amexCVVTokenizationButton.setOnClickListener(v -> amexCVVComponentMediator.createToken(resultHandler)); diff --git a/frames/src/main/java/com/checkout/frames/cvvinputfield/api/InternalCVVComponentMediator.kt b/frames/src/main/java/com/checkout/frames/cvvinputfield/api/InternalCVVComponentMediator.kt index 8d80ecf4..a5ab4650 100644 --- a/frames/src/main/java/com/checkout/frames/cvvinputfield/api/InternalCVVComponentMediator.kt +++ b/frames/src/main/java/com/checkout/frames/cvvinputfield/api/InternalCVVComponentMediator.kt @@ -59,11 +59,10 @@ internal class InternalCVVComponentMediator( override fun provideCvvComponentContent( container: View, - ): View = ComposeView(container.context).apply { - // Dispose of the Composition when the view's LifecycleOwner is destroyed - setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) - setContent { InternalCVVComponent() } - } + ): View = provideCvvComponentContent( + container, + ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed, + ) @VisibleForTesting internal fun getIsCVVComponentCalled() = isCVVComponentCalled