- Send Activity now sends with CryptoNetInfoRequests
This commit is contained in:
parent
c2f627694e
commit
497545f8d2
1 changed files with 33 additions and 22 deletions
|
@ -20,8 +20,10 @@ import java.util.List;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
|
import butterknife.OnItemSelected;
|
||||||
import butterknife.OnTextChanged;
|
import butterknife.OnTextChanged;
|
||||||
import cy.agorise.crystalwallet.R;
|
import cy.agorise.crystalwallet.R;
|
||||||
|
import cy.agorise.crystalwallet.cryptonetinforequests.ValidateBitsharesSendRequest;
|
||||||
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
import cy.agorise.crystalwallet.dao.CrystalDatabase;
|
||||||
import cy.agorise.crystalwallet.enums.CryptoNet;
|
import cy.agorise.crystalwallet.enums.CryptoNet;
|
||||||
import cy.agorise.crystalwallet.enums.SeedType;
|
import cy.agorise.crystalwallet.enums.SeedType;
|
||||||
|
@ -29,6 +31,7 @@ import cy.agorise.crystalwallet.models.AccountSeed;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
import cy.agorise.crystalwallet.models.CryptoCoinBalance;
|
||||||
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
import cy.agorise.crystalwallet.models.CryptoCurrency;
|
||||||
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
import cy.agorise.crystalwallet.models.CryptoNetAccount;
|
||||||
|
import cy.agorise.crystalwallet.models.GrapheneAccount;
|
||||||
import cy.agorise.crystalwallet.models.GrapheneAccountInfo;
|
import cy.agorise.crystalwallet.models.GrapheneAccountInfo;
|
||||||
import cy.agorise.crystalwallet.viewmodels.CryptoNetAccountViewModel;
|
import cy.agorise.crystalwallet.viewmodels.CryptoNetAccountViewModel;
|
||||||
import cy.agorise.crystalwallet.viewmodels.GrapheneAccountInfoViewModel;
|
import cy.agorise.crystalwallet.viewmodels.GrapheneAccountInfoViewModel;
|
||||||
|
@ -67,6 +70,7 @@ public class SendTransactionActivity extends AppCompatActivity implements UIVali
|
||||||
|
|
||||||
private long cryptoNetAccountId;
|
private long cryptoNetAccountId;
|
||||||
private CryptoNetAccount cryptoNetAccount;
|
private CryptoNetAccount cryptoNetAccount;
|
||||||
|
private GrapheneAccount grapheneAccount;
|
||||||
private CrystalDatabase db;
|
private CrystalDatabase db;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -83,6 +87,14 @@ public class SendTransactionActivity extends AppCompatActivity implements UIVali
|
||||||
if (this.cryptoNetAccountId != -1) {
|
if (this.cryptoNetAccountId != -1) {
|
||||||
db = CrystalDatabase.getAppDatabase(this);
|
db = CrystalDatabase.getAppDatabase(this);
|
||||||
this.cryptoNetAccount = db.cryptoNetAccountDao().getById(this.cryptoNetAccountId);
|
this.cryptoNetAccount = db.cryptoNetAccountDao().getById(this.cryptoNetAccountId);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* this is only for graphene accounts.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
this.grapheneAccount = new GrapheneAccount(this.cryptoNetAccount);
|
||||||
|
this.grapheneAccount.loadInfo(db.grapheneAccountInfoDao().getByAccountId(this.cryptoNetAccountId));
|
||||||
|
|
||||||
final LiveData<List<CryptoCoinBalance>> balancesList = db.cryptoCoinBalanceDao().getBalancesFromAccount(cryptoNetAccountId);
|
final LiveData<List<CryptoCoinBalance>> balancesList = db.cryptoCoinBalanceDao().getBalancesFromAccount(cryptoNetAccountId);
|
||||||
balancesList.observe(this, new Observer<List<CryptoCoinBalance>>() {
|
balancesList.observe(this, new Observer<List<CryptoCoinBalance>>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -102,7 +114,7 @@ public class SendTransactionActivity extends AppCompatActivity implements UIVali
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
sendTransactionValidator = new SendTransactionValidator(this.getApplicationContext(), this.cryptoNetAccount, etFrom, etTo, etAmount, etMemo);
|
sendTransactionValidator = new SendTransactionValidator(this.getApplicationContext(), this.cryptoNetAccount, etFrom, etTo, spAsset, etAmount, etMemo);
|
||||||
sendTransactionValidator.setListener(this);
|
sendTransactionValidator.setListener(this);
|
||||||
} else {
|
} else {
|
||||||
this.finish();
|
this.finish();
|
||||||
|
@ -121,6 +133,11 @@ public class SendTransactionActivity extends AppCompatActivity implements UIVali
|
||||||
this.sendTransactionValidator.validate();
|
this.sendTransactionValidator.validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OnItemSelected(R.id.spAsset)
|
||||||
|
public void afterAssetSelected(Spinner spinner, int position) {
|
||||||
|
this.sendTransactionValidator.validate();
|
||||||
|
}
|
||||||
|
|
||||||
@OnTextChanged(value = R.id.etAmount,
|
@OnTextChanged(value = R.id.etAmount,
|
||||||
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
|
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
|
||||||
void afterAmountChanged(Editable editable) {
|
void afterAmountChanged(Editable editable) {
|
||||||
|
@ -140,28 +157,18 @@ public class SendTransactionActivity extends AppCompatActivity implements UIVali
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.btnSend)
|
@OnClick(R.id.btnSend)
|
||||||
public void importSeed(){
|
public void importSend(){
|
||||||
if (this.sendTransactionValidator.isValid()) {
|
if (this.sendTransactionValidator.isValid()) {
|
||||||
AccountSeed seed = new AccountSeed();
|
ValidateBitsharesSendRequest sendRequest = new ValidateBitsharesSendRequest(
|
||||||
|
this.getApplicationContext(),
|
||||||
//TODO verify if words are already in the db
|
this.grapheneAccount,
|
||||||
//TODO check if name has been asigned to other seed
|
this.etTo.getText().toString(),
|
||||||
seed.setMasterSeed(etSeedWords.getText().toString());
|
this.etAmount,
|
||||||
seed.setName(etAccountName.getText().toString());
|
((CryptoCurrency)spAsset.getSelectedItem()).getName(),
|
||||||
seed.setType(SeedType.BRAINKEY);
|
feeAmount,
|
||||||
|
feeAsset,
|
||||||
accountSeedViewModel.addSeed(seed);
|
etMemo.getText().toString()
|
||||||
|
);
|
||||||
CryptoNetAccountViewModel cryptoNetAccountViewModel = ViewModelProviders.of(this).get(CryptoNetAccountViewModel.class);
|
|
||||||
GrapheneAccountInfoViewModel grapheneAccountInfoViewModel = ViewModelProviders.of(this).get(GrapheneAccountInfoViewModel.class);
|
|
||||||
CryptoNetAccount cryptoNetAccount = new CryptoNetAccount();
|
|
||||||
cryptoNetAccount.setSeedId(seed.getId());
|
|
||||||
cryptoNetAccount.setAccountIndex(0);
|
|
||||||
cryptoNetAccount.setCryptoNet(CryptoNet.BITSHARES);
|
|
||||||
cryptoNetAccountViewModel.addCryptoNetAccount(cryptoNetAccount);
|
|
||||||
GrapheneAccountInfo grapheneAccountInfo = new GrapheneAccountInfo(cryptoNetAccount.getId());
|
|
||||||
grapheneAccountInfo.setName(etAccountName.getText().toString());
|
|
||||||
grapheneAccountInfoViewModel.addGrapheneAccountInfo(grapheneAccountInfo);
|
|
||||||
|
|
||||||
this.finish();
|
this.finish();
|
||||||
}
|
}
|
||||||
|
@ -180,6 +187,8 @@ public class SendTransactionActivity extends AppCompatActivity implements UIVali
|
||||||
tvToError.setText("");
|
tvToError.setText("");
|
||||||
} else if (field.getView() == etAmount){
|
} else if (field.getView() == etAmount){
|
||||||
tvAmountError.setText("");
|
tvAmountError.setText("");
|
||||||
|
} else if (field.getView() == spAsset){
|
||||||
|
tvAssetError.setText("");
|
||||||
} else if (field.getView() == etMemo){
|
} else if (field.getView() == etMemo){
|
||||||
tvMemoError.setText("");
|
tvMemoError.setText("");
|
||||||
}
|
}
|
||||||
|
@ -200,6 +209,8 @@ public class SendTransactionActivity extends AppCompatActivity implements UIVali
|
||||||
tvFromError.setText(field.getMessage());
|
tvFromError.setText(field.getMessage());
|
||||||
} else if (field.getView() == etTo){
|
} else if (field.getView() == etTo){
|
||||||
tvToError.setText(field.getMessage());
|
tvToError.setText(field.getMessage());
|
||||||
|
} else if (field.getView() == spAsset){
|
||||||
|
tvAssetError.setText(field.getMessage());
|
||||||
} else if (field.getView() == etAmount){
|
} else if (field.getView() == etAmount){
|
||||||
tvAmountError.setText(field.getMessage());
|
tvAmountError.setText(field.getMessage());
|
||||||
} else if (field.getView() == etMemo){
|
} else if (field.getView() == etMemo){
|
||||||
|
|
Loading…
Reference in a new issue