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

java.lang.NumberFormatException #13

Open
EKami opened this issue Oct 22, 2014 · 0 comments
Open

java.lang.NumberFormatException #13

EKami opened this issue Oct 22, 2014 · 0 comments

Comments

@EKami
Copy link

EKami commented Oct 22, 2014

Hello,
I sometimes get an java.lang.NumberFormatException. Here is the complete stacktrace:

10-22 01:49:40.867  16136-16136/com.heetch.debug E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.NumberFormatException: Invalid long: ""
            at java.lang.Long.invalidLong(Long.java:125)
            at java.lang.Long.parseLong(Long.java:346)
            at java.lang.Long.parseLong(Long.java:319)
            at com.paymentkit.views.FieldHolder.validateCard(FieldHolder.java:156)
            at com.paymentkit.views.FieldHolder.access$100(FieldHolder.java:26)
            at com.paymentkit.views.FieldHolder$2.onCardNumberInputComplete(FieldHolder.java:237)
            at com.paymentkit.views.CardNumEditText$ZanyInputConnection.handleNextPress(CardNumEditText.java:219)
            at com.paymentkit.views.CardNumEditText$ZanyInputConnection.performEditorAction(CardNumEditText.java:212)
            at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:297)
            at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:77)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5419)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
            at dalvik.system.NativeStart.main(Native Method)

It happen when I hit the "next" button of my soft keyboard when the FieldHolder is empty.
Here is a possible patch for the method throwing that exception:

    private void validateCard() {
        String cardNumberText = mCardHolder.getCardField().getText().toString();

        if (cardNumberText.equals(""))
            return;
        long cardNumber = Long.parseLong(cardNumberText.replaceAll("\\s", ""));
        if (ValidateCreditCard.isValid(cardNumber)) {
            CardType cardType = ValidateCreditCard.matchCardType(cardNumber);
            mCardIcon.setCardType(cardType);
            transitionToExtraFields();
        } else {
            mCardHolder.indicateInvalidCardNum();
        }
    }

at line 155 of FieldHolder.java.
Could you patch this? Thank you.

pull bot pushed a commit to nagyist/PaymentKit-Droid that referenced this issue Dec 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant