- Fixed Bitshares account creation validation to only fire event when account is not null

- Now the Service load transactions only when GrapheneAccountInfo is inserted
This commit is contained in:
Javier Varona 2018-03-25 22:13:56 -04:00
parent e2a453478c
commit 71c1df2306
2 changed files with 15 additions and 7 deletions

View file

@ -54,7 +54,13 @@ public class ValidateCreateBitsharesAccountRequest extends CryptoNetInfoRequest
public void validate(){ public void validate(){
if ((this.accountExists != null)){// && (this.account != null)){ if ((this.accountExists != null)){// && (this.account != null)){
this._fireOnCarryOutEvent(); if (this.accountExists == true) {
this._fireOnCarryOutEvent();
} else {
if (this.account != null){
this._fireOnCarryOutEvent();
}
}
} }
} }

View file

@ -126,15 +126,17 @@ public class CrystalWalletService extends LifecycleService {
final CrystalWalletService thisService = this; final CrystalWalletService thisService = this;
final CrystalDatabase db = CrystalDatabase.getAppDatabase(this); final CrystalDatabase db = CrystalDatabase.getAppDatabase(this);
final LiveData<List<CryptoNetAccount>> cryptoNetAccountList = db.cryptoNetAccountDao().getAll(); //final LiveData<List<CryptoNetAccount>> cryptoNetAccountList = db.cryptoNetAccountDao().getAll();
cryptoNetAccountList.observe(this, new Observer<List<CryptoNetAccount>>() { final LiveData<List<GrapheneAccountInfo>> grapheneAccountInfoList = db.grapheneAccountInfoDao().getAll();
grapheneAccountInfoList.observe(this, new Observer<List<GrapheneAccountInfo>>() {
@Override @Override
public void onChanged(@Nullable List<CryptoNetAccount> cryptoNetAccounts) { public void onChanged(@Nullable List<GrapheneAccountInfo> grapheneAccountInfos) {
GrapheneAccount nextGrapheneAccount; GrapheneAccount nextGrapheneAccount;
for(CryptoNetAccount nextAccount : cryptoNetAccountList.getValue()) { for(GrapheneAccountInfo nextGrapheneAccountInfo : grapheneAccountInfos) {
GrapheneAccountInfo grapheneAccountInfo = db.grapheneAccountInfoDao().getByAccountId(nextAccount.getId()); CryptoNetAccount nextAccount = db.cryptoNetAccountDao().getById(nextGrapheneAccountInfo.getCryptoNetAccountId());
//GrapheneAccountInfo grapheneAccountInfo = db.grapheneAccountInfoDao().getByAccountId(nextAccount.getId());
nextGrapheneAccount = new GrapheneAccount(nextAccount); nextGrapheneAccount = new GrapheneAccount(nextAccount);
nextGrapheneAccount.loadInfo(grapheneAccountInfo); nextGrapheneAccount.loadInfo(nextGrapheneAccountInfo);
bitsharesAccountManager.loadAccountFromDB(nextGrapheneAccount,thisService); bitsharesAccountManager.loadAccountFromDB(nextGrapheneAccount,thisService);