Skip to content

Commit

Permalink
PIMOB: Addressing pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
chintan-soni-cko committed Oct 13, 2023
1 parent 927cba9 commit 0c87c11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0c87c11

Please sign in to comment.