From 7f9637056808cc2ecf9d826ee925685bbd70cf6c Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Sun, 22 Oct 2017 20:28:37 -0400 Subject: [PATCH] - Fixed the way import seed was adding the graphene account - Now the service is listening to dao chenges and calling the bitshares manager when that happens --- .../crystalwallet/activities/ImportSeedActivity.java | 4 ++++ .../crystalwallet/service/CrystalWalletService.java | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/ImportSeedActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/ImportSeedActivity.java index b7421c6..26a1733 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/ImportSeedActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/ImportSeedActivity.java @@ -22,6 +22,7 @@ import cy.agorise.crystalwallet.models.GrapheneAccount; import cy.agorise.crystalwallet.models.GrapheneAccountInfo; import cy.agorise.crystalwallet.viewmodels.AccountSeedViewModel; import cy.agorise.crystalwallet.viewmodels.CryptoNetAccountViewModel; +import cy.agorise.crystalwallet.viewmodels.GrapheneAccountInfoViewModel; import cy.agorise.crystalwallet.viewmodels.validators.ImportSeedValidator; import cy.agorise.crystalwallet.viewmodels.validators.UIValidatorListener; import cy.agorise.crystalwallet.viewmodels.validators.ValidationField; @@ -115,12 +116,15 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator accountSeedViewModel.addSeed(seed); 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(cy.agorise.crystalwallet.enums.CryptoNet.BITSHARES); cryptoNetAccountViewModel.addCryptoNetAccount(cryptoNetAccount); GrapheneAccountInfo grapheneAccountInfo = new GrapheneAccountInfo(cryptoNetAccount.getId()); + grapheneAccountInfo.setName(etAccountName.getText().toString()); + grapheneAccountInfoViewModel.addGrapheneAccountInfo(grapheneAccountInfo); this.finish(); } 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 48b3fa5..172a2e9 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/service/CrystalWalletService.java +++ b/app/src/main/java/cy/agorise/crystalwallet/service/CrystalWalletService.java @@ -2,6 +2,7 @@ package cy.agorise.crystalwallet.service; import android.app.Service; +import android.arch.lifecycle.LifecycleService; import android.arch.lifecycle.LiveData; import android.arch.lifecycle.Observer; import android.content.Intent; @@ -24,7 +25,7 @@ import cy.agorise.crystalwallet.models.CryptoNetAccount; */ -public class CrystalWalletService extends Service { +public class CrystalWalletService extends LifecycleService { private Looper mServiceLooper; private ServiceHandler mServiceHandler; @@ -50,7 +51,7 @@ public class CrystalWalletService extends Service { } public void loadAccountTransactions(){ - /*this.keepLoadingAccountTransactions = true; + this.keepLoadingAccountTransactions = true; final CrystalWalletService thisService = this; CrystalDatabase db = CrystalDatabase.getAppDatabase(this); @@ -62,7 +63,7 @@ public class CrystalWalletService extends Service { bitsharesAccountManager.loadAccountFromDB(nextAccount,thisService); } } - });*/ + });