use of com.hedera.hashgraph.sdk.account.AccountId in project hedera-sdk-java by hashgraph.
the class AccountBalanceFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
accountBalance = view.findViewById(R.id.accountBalance);
accountId = view.findViewById(R.id.accountId);
view.findViewById(R.id.button).setOnClickListener(v -> {
try {
final AccountId operatorId = AccountId.fromString(view.getResources().getString(R.string.operator_id));
final Ed25519PrivateKey operatorKey = Ed25519PrivateKey.fromString(view.getResources().getString(R.string.operator_key));
Client client = Client.forTestnet().setOperator(operatorId, operatorKey);
final AccountId id = AccountId.fromString(accountId.getText().toString());
new AccountBalanceAsyncTask(id).execute(client);
} catch (IllegalArgumentException e) {
accountBalance.setText("Error: " + e.getMessage());
}
});
}
use of com.hedera.hashgraph.sdk.account.AccountId in project hedera-sdk-java by hashgraph.
the class CryptoTransferFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
recipientAccountId = view.findViewById(R.id.recipientAccountId);
amountToSend = view.findViewById(R.id.amountToSend);
resultText = view.findViewById(R.id.transferResult);
view.findViewById(R.id.sendHbar).setOnClickListener(v -> {
try {
final AccountId operatorId = AccountId.fromString(view.getResources().getString(R.string.operator_id));
final Ed25519PrivateKey operatorKey = Ed25519PrivateKey.fromString(view.getResources().getString(R.string.operator_key));
Client client = Client.forTestnet().setOperator(operatorId, operatorKey);
final AccountId recipientId = AccountId.fromString(recipientAccountId.getText().toString());
final Hbar amount = new Hbar(new BigDecimal(amountToSend.getText().toString()).longValueExact());
new TransferAsyncTask(operatorId, recipientId, amount).execute(client);
} catch (Throwable e) {
resultText.setText("Error: " + e.getMessage());
}
});
}
Aggregations