From 71c1df2306dfc7fdee983d4cd5d3d5bbf2f46e83 Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Sun, 25 Mar 2018 22:13:56 -0400 Subject: [PATCH] - Fixed Bitshares account creation validation to only fire event when account is not null - Now the Service load transactions only when GrapheneAccountInfo is inserted --- .../ValidateCreateBitsharesAccountRequest.java | 8 +++++++- .../service/CrystalWalletService.java | 14 ++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/ValidateCreateBitsharesAccountRequest.java b/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/ValidateCreateBitsharesAccountRequest.java index 276174b..7fd8cf7 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/ValidateCreateBitsharesAccountRequest.java +++ b/app/src/main/java/cy/agorise/crystalwallet/cryptonetinforequests/ValidateCreateBitsharesAccountRequest.java @@ -54,7 +54,13 @@ public class ValidateCreateBitsharesAccountRequest extends CryptoNetInfoRequest public void validate(){ if ((this.accountExists != null)){// && (this.account != null)){ - this._fireOnCarryOutEvent(); + if (this.accountExists == true) { + this._fireOnCarryOutEvent(); + } else { + if (this.account != null){ + this._fireOnCarryOutEvent(); + } + } } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/service/CrystalWalletService.java b/app/src/main/java/cy/agorise/crystalwallet/service/CrystalWalletService.java index 01a80bd..d757b6a 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/service/CrystalWalletService.java +++ b/app/src/main/java/cy/agorise/crystalwallet/service/CrystalWalletService.java @@ -126,15 +126,17 @@ public class CrystalWalletService extends LifecycleService { final CrystalWalletService thisService = this; final CrystalDatabase db = CrystalDatabase.getAppDatabase(this); - final LiveData> cryptoNetAccountList = db.cryptoNetAccountDao().getAll(); - cryptoNetAccountList.observe(this, new Observer>() { + //final LiveData> cryptoNetAccountList = db.cryptoNetAccountDao().getAll(); + final LiveData> grapheneAccountInfoList = db.grapheneAccountInfoDao().getAll(); + grapheneAccountInfoList.observe(this, new Observer>() { @Override - public void onChanged(@Nullable List cryptoNetAccounts) { + public void onChanged(@Nullable List grapheneAccountInfos) { GrapheneAccount nextGrapheneAccount; - for(CryptoNetAccount nextAccount : cryptoNetAccountList.getValue()) { - GrapheneAccountInfo grapheneAccountInfo = db.grapheneAccountInfoDao().getByAccountId(nextAccount.getId()); + for(GrapheneAccountInfo nextGrapheneAccountInfo : grapheneAccountInfos) { + CryptoNetAccount nextAccount = db.cryptoNetAccountDao().getById(nextGrapheneAccountInfo.getCryptoNetAccountId()); + //GrapheneAccountInfo grapheneAccountInfo = db.grapheneAccountInfoDao().getByAccountId(nextAccount.getId()); nextGrapheneAccount = new GrapheneAccount(nextAccount); - nextGrapheneAccount.loadInfo(grapheneAccountInfo); + nextGrapheneAccount.loadInfo(nextGrapheneAccountInfo); bitsharesAccountManager.loadAccountFromDB(nextGrapheneAccount,thisService);