Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method to only cancel async calls without destroying CustomerSessions instance. #624

Merged
merged 2 commits into from
Dec 18, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions stripe/src/main/java/com/stripe/android/CustomerSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ public static void endCustomerSession() {
clearInstance();
}

/**
* End any async calls in process and will not invoke callback listeners.
* It will not clear the singleton instance of a {@link CustomerSession} so it can be
* safely used when a view is being removed/destroyed to avoid null pointer exceptions
* due to async operation delay.
* No need to call {@link CustomerSession#initCustomerSession(EphemeralKeyProvider)} again
* after this operation.
*/
public static void cancelCallbacks(){
umarhussain15 marked this conversation as resolved.
Show resolved Hide resolved
if (mInstance == null) {
return;
}
mInstance.mThreadPoolExecutor.shutdownNow();
}

@VisibleForTesting
static void initCustomerSession(
@NonNull EphemeralKeyProvider keyProvider,
Expand Down