use of jota.utils.IotaUnits in project run-wallet-android by runplay.
the class GenerateQRCodeFragment method amountInSelectedUnit.
private String amountInSelectedUnit() {
String inputAmount = amountEditText.getText().toString();
IotaUnits unit = toIotaUnit(unitsSpinner.getSelectedItemPosition());
Long iota = Long.parseLong(inputAmount) * (long) Math.pow(10, unit.getValue());
return iota.toString();
}
use of jota.utils.IotaUnits in project run-wallet-android by runplay.
the class SnTrFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
((AppCompatActivity) getActivity()).setSupportActionBar(newTransferToolbar);
setHasOptionsMenu(false);
// paytoAddresses.clear();
newTransferToolbar.setNavigationIcon(getResources().getDrawable(R.drawable.md_nav_back));
newTransferToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
}
});
initUnitsSpinner();
addMessage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (messageLayout.getVisibility() == View.GONE) {
messageLayout.setVisibility(View.VISIBLE);
} else {
messageLayout.setVisibility(View.GONE);
}
}
});
addTag.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (tagLayout.getVisibility() == View.GONE) {
tagLayout.setVisibility(View.VISIBLE);
} else {
tagLayout.setVisibility(View.GONE);
}
}
});
qrSelect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
openQRCodeScanner();
}
});
addPayment.setEnabled(false);
addPayment.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addAdress();
}
});
next.setEnabled(false);
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
goNext();
}
});
Wallet wallet = Store.getCurrentWallet();
balances = PayPacket.calculateAvailableBalances();
availableBalance.setText(IotaToText.convertRawIotaAmountToDisplayText(balances.available, true));
// if(wallet.getAvailableBalance()>0) {
availableBalance.setTextColor(B.getColor(getActivity(), R.color.green));
// }
pendingBalance.setText(IotaToText.convertRawIotaAmountToDisplayText(balances.locked, true));
pendingBalance.setAlpha(0.4F);
pendingLabel.setAlpha(0.5F);
if (wallet.getBalancePendingIn() > 0) {
pendingBalance.setTextColor(B.getColor(getActivity(), R.color.green));
}
addressEditText.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
isLongClicked = true;
return false;
}
});
btnClear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addressEditText.setText("");
amountEditText.setText("");
}
});
addressEditText.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (isLongClicked) {
isLongClicked = false;
return false;
}
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE);
if (imm.isActive(addressEditText)) {
return false;
}
int inType = addressEditText.getInputType();
addressEditText.setInputType(InputType.TYPE_NULL);
addressEditText.onTouchEvent(event);
addressEditText.setInputType(inType);
// consume touch event
return true;
}
});
addressEditText.addTextChangedListener(inputWatcher);
amountEditText.addTextChangedListener(inputWatcher);
btnBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
goBackBtn();
}
});
keyboard.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
UiManager.setKeyboard(getActivity(), addressEditText, true);
scroller.postDelayed(new Runnable() {
@Override
public void run() {
scrollView.post(new Runnable() {
@Override
public void run() {
scrollView.fullScroll(View.FOCUS_DOWN);
addressEditText.requestFocus();
}
});
}
}, 500);
}
});
btnPaste.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
ClipData cd = clipboard.getPrimaryClip();
if (cd != null && cd.getItemCount() > 0) {
addressEditText.setText(cd.getItemAt(0).coerceToText(getActivity()));
}
}
});
Bundle bundle = getArguments();
if (getArguments() != null) {
QRCode qrCode = bundle.getParcelable(Constants.QRCODE);
if (qrCode != null) {
if (qrCode.getAddress() != null)
addressEditText.setText(qrCode.getAddress());
if (qrCode.getAmount() != null && !qrCode.getAmount().isEmpty()) {
Long amount = Long.parseLong((qrCode.getAmount()));
IotaUnits unit = IotaUnitConverter.findOptimalIotaUnitToDisplay(amount);
String amountText = Math.round(IotaUnitConverter.convertAmountTo(amount, unit)) + "";
amountEditText.setText(amountText);
unitsSpinner.setSelection(toSpinnerItemIndex(unit));
}
if (qrCode.getMessage() != null)
messageEditText.setText(qrCode.getMessage());
if (qrCode.getTag() != null)
tagEditText.setText(qrCode.getTag());
checkContinue();
}
}
checkContinue();
}
use of jota.utils.IotaUnits in project run-wallet-android by runplay.
the class SnTrFragment method amountInSelectedUnit.
private String amountInSelectedUnit() {
String inputAmount = amountEditText.getText().toString();
if (inputAmount.isEmpty())
inputAmount = "0";
inputAmount = Long.valueOf(Math.round(Sf.toDouble(inputAmount))).toString();
// amountEditText.setText(inputAmount+"");
IotaUnits unit = toIotaUnit(unitsSpinner.getSelectedItemPosition());
Long iota = Long.parseLong(inputAmount) * (long) Math.pow(10, unit.getValue());
return iota.toString();
}
Aggregations