Search in sources :

Example 1 with BinaryInputParser

use of de.schildbach.wallet.ui.InputParser.BinaryInputParser in project bitcoin-wallet by bitcoin-wallet.

the class WalletActivity method handleIntent.

private void handleIntent(final Intent intent) {
    final String action = intent.getAction();
    if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) {
        final String inputType = intent.getType();
        final NdefMessage ndefMessage = (NdefMessage) intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)[0];
        final byte[] input = Nfc.extractMimePayload(Constants.MIMETYPE_TRANSACTION, ndefMessage);
        new BinaryInputParser(inputType, input) {

            @Override
            protected void handlePaymentIntent(final PaymentIntent paymentIntent) {
                cannotClassify(inputType);
            }

            @Override
            protected void error(final int messageResId, final Object... messageArgs) {
                final DialogBuilder dialog = DialogBuilder.dialog(WalletActivity.this, 0, messageResId, messageArgs);
                dialog.singleDismissButton(null);
                dialog.show();
            }
        }.parse();
    }
}
Also used : NdefMessage(android.nfc.NdefMessage) BinaryInputParser(de.schildbach.wallet.ui.InputParser.BinaryInputParser) PaymentIntent(de.schildbach.wallet.data.PaymentIntent)

Aggregations

NdefMessage (android.nfc.NdefMessage)1 PaymentIntent (de.schildbach.wallet.data.PaymentIntent)1 BinaryInputParser (de.schildbach.wallet.ui.InputParser.BinaryInputParser)1