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

fixing npe in CardInputWidget #392

Merged
merged 1 commit into from
Sep 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
import java.util.Locale;

import static com.stripe.android.model.Card.BRAND_RESOURCE_MAP;
import static com.stripe.android.model.Card.CVC_LENGTH_AMERICAN_EXPRESS;
import static com.stripe.android.model.Card.CVC_LENGTH_COMMON;
import static com.stripe.android.model.Card.CardBrand;
import static com.stripe.android.view.CardInputListener.FocusField.FOCUS_CARD;
import static com.stripe.android.view.CardInputListener.FocusField.FOCUS_CVC;
Expand Down Expand Up @@ -204,6 +202,20 @@ public void setEnabled(boolean isEnabled) {
mCvcNumberEditText.setEnabled(isEnabled);
}

/**
* Override of {@link View#isEnabled()} that returns {@code true} only
* if all three sub-controls are enabled.
*
* @return {@code true} if the card number field, expiry field, and cvc field are enabled,
* {@code false} otherwise
*/
@Override
public boolean isEnabled() {
return mCardNumberEditText.isEnabled() &&
mExpiryDateEditText.isEnabled() &&
mCvcNumberEditText.isEnabled();
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (ev.getAction() != MotionEvent.ACTION_DOWN) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ public int getDefaultErrorColorInt() {

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
InputConnection inputConnection = super.onCreateInputConnection(outAttrs);
if (inputConnection == null) {
return null;
}
return new SoftDeleteInputConnection(super.onCreateInputConnection(outAttrs), true);
}

Expand Down