- 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
This commit is contained in:
Javier Varona 2017-10-22 20:28:37 -04:00
parent 4434ad40a5
commit 7f96370568
2 changed files with 8 additions and 3 deletions

View file

@ -22,6 +22,7 @@ import cy.agorise.crystalwallet.models.GrapheneAccount;
import cy.agorise.crystalwallet.models.GrapheneAccountInfo; import cy.agorise.crystalwallet.models.GrapheneAccountInfo;
import cy.agorise.crystalwallet.viewmodels.AccountSeedViewModel; import cy.agorise.crystalwallet.viewmodels.AccountSeedViewModel;
import cy.agorise.crystalwallet.viewmodels.CryptoNetAccountViewModel; 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.ImportSeedValidator;
import cy.agorise.crystalwallet.viewmodels.validators.UIValidatorListener; import cy.agorise.crystalwallet.viewmodels.validators.UIValidatorListener;
import cy.agorise.crystalwallet.viewmodels.validators.ValidationField; import cy.agorise.crystalwallet.viewmodels.validators.ValidationField;
@ -115,12 +116,15 @@ public class ImportSeedActivity extends AppCompatActivity implements UIValidator
accountSeedViewModel.addSeed(seed); accountSeedViewModel.addSeed(seed);
CryptoNetAccountViewModel cryptoNetAccountViewModel = ViewModelProviders.of(this).get(CryptoNetAccountViewModel.class); CryptoNetAccountViewModel cryptoNetAccountViewModel = ViewModelProviders.of(this).get(CryptoNetAccountViewModel.class);
GrapheneAccountInfoViewModel grapheneAccountInfoViewModel = ViewModelProviders.of(this).get(GrapheneAccountInfoViewModel.class);
CryptoNetAccount cryptoNetAccount = new CryptoNetAccount(); CryptoNetAccount cryptoNetAccount = new CryptoNetAccount();
cryptoNetAccount.setSeedId(seed.getId()); cryptoNetAccount.setSeedId(seed.getId());
cryptoNetAccount.setAccountIndex(0); cryptoNetAccount.setAccountIndex(0);
cryptoNetAccount.setCryptoNet(cy.agorise.crystalwallet.enums.CryptoNet.BITSHARES); cryptoNetAccount.setCryptoNet(cy.agorise.crystalwallet.enums.CryptoNet.BITSHARES);
cryptoNetAccountViewModel.addCryptoNetAccount(cryptoNetAccount); cryptoNetAccountViewModel.addCryptoNetAccount(cryptoNetAccount);
GrapheneAccountInfo grapheneAccountInfo = new GrapheneAccountInfo(cryptoNetAccount.getId()); GrapheneAccountInfo grapheneAccountInfo = new GrapheneAccountInfo(cryptoNetAccount.getId());
grapheneAccountInfo.setName(etAccountName.getText().toString());
grapheneAccountInfoViewModel.addGrapheneAccountInfo(grapheneAccountInfo);
this.finish(); this.finish();
} }

View file

@ -2,6 +2,7 @@ package cy.agorise.crystalwallet.service;
import android.app.Service; import android.app.Service;
import android.arch.lifecycle.LifecycleService;
import android.arch.lifecycle.LiveData; import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.Observer; import android.arch.lifecycle.Observer;
import android.content.Intent; 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 Looper mServiceLooper;
private ServiceHandler mServiceHandler; private ServiceHandler mServiceHandler;
@ -50,7 +51,7 @@ public class CrystalWalletService extends Service {
} }
public void loadAccountTransactions(){ public void loadAccountTransactions(){
/*this.keepLoadingAccountTransactions = true; this.keepLoadingAccountTransactions = true;
final CrystalWalletService thisService = this; final CrystalWalletService thisService = this;
CrystalDatabase db = CrystalDatabase.getAppDatabase(this); CrystalDatabase db = CrystalDatabase.getAppDatabase(this);
@ -62,7 +63,7 @@ public class CrystalWalletService extends Service {
bitsharesAccountManager.loadAccountFromDB(nextAccount,thisService); bitsharesAccountManager.loadAccountFromDB(nextAccount,thisService);
} }
} }
});*/ });