-
Notifications
You must be signed in to change notification settings - Fork 658
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate PaymentMethodsActivity to use Activity Result API (#3205)
Simplify API for receiving results from `AddPaymentMethodActivity` This change requires refactoring `AddPaymentMethodRowView` https://developer.android.com/training/basics/intents/result
- Loading branch information
1 parent
76ecafd
commit 97c3ac3
Showing
10 changed files
with
225 additions
and
168 deletions.
There are no files selected for viewing
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
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
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
24 changes: 24 additions & 0 deletions
24
stripe/src/main/java/com/stripe/android/view/AddPaymentMethodContract.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.stripe.android.view | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import androidx.activity.result.contract.ActivityResultContract | ||
|
||
internal class AddPaymentMethodContract : | ||
ActivityResultContract<AddPaymentMethodActivityStarter.Args, AddPaymentMethodActivityStarter.Result>() { | ||
|
||
override fun createIntent( | ||
context: Context, | ||
input: AddPaymentMethodActivityStarter.Args? | ||
): Intent { | ||
return Intent(context, AddPaymentMethodActivity::class.java) | ||
.putExtra(ActivityStarter.Args.EXTRA, input) | ||
} | ||
|
||
override fun parseResult( | ||
resultCode: Int, | ||
intent: Intent? | ||
): AddPaymentMethodActivityStarter.Result { | ||
return AddPaymentMethodActivityStarter.Result.fromIntent(intent) | ||
} | ||
} |
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
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
Oops, something went wrong.