use of org.bitcoinj.uri.BitcoinURI in project bitcoin-wallet by bitcoin-wallet.
the class SendingAddressesFragment method getAddressFromPrimaryClip.
private Address getAddressFromPrimaryClip() {
if (!clipboardManager.hasPrimaryClip())
return null;
final ClipData clip = clipboardManager.getPrimaryClip();
final ClipDescription clipDescription = clip.getDescription();
if (clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) {
final CharSequence clipText = clip.getItemAt(0).getText();
if (clipText == null)
return null;
try {
return Address.fromBase58(Constants.NETWORK_PARAMETERS, clipText.toString().trim());
} catch (final AddressFormatException x) {
return null;
}
} else if (clipDescription.hasMimeType(ClipDescription.MIMETYPE_TEXT_URILIST)) {
final Uri clipUri = clip.getItemAt(0).getUri();
if (clipUri == null)
return null;
try {
return new BitcoinURI(clipUri.toString()).getAddress();
} catch (final BitcoinURIParseException x) {
return null;
}
} else {
return null;
}
}
Aggregations