From 62541e1863c65e0065ab6f4aeec057e17f0bd9d5 Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Mon, 19 Nov 2018 23:19:23 -0400 Subject: [PATCH] - Now the bitcoin accounts get their transactions loaded --- .../agorise/crystalwallet/dao/CryptoNetAccountDao.java | 3 +++ .../crystalwallet/service/CrystalWalletService.java | 10 +++++++++- .../crystalwallet/views/CryptoNetAccountAdapter.java | 6 ++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoNetAccountDao.java b/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoNetAccountDao.java index f987a69..638075d 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoNetAccountDao.java +++ b/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoNetAccountDao.java @@ -29,6 +29,9 @@ public interface CryptoNetAccountDao { @Query("SELECT cna.* FROM crypto_net_account cna WHERE seed_id = :seedId") List getAllCryptoNetAccountBySeed( long seedId); + @Query("SELECT cna.* FROM crypto_net_account cna WHERE crypto_net == 'BITCOIN'") + LiveData> getAllBitcoins(); + @Query("SELECT * FROM crypto_net_account WHERE id = :accountId") LiveData getByIdLiveData( long accountId); 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 6e1bbce..8d3b05c 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/service/CrystalWalletService.java +++ b/app/src/main/java/cy/agorise/crystalwallet/service/CrystalWalletService.java @@ -170,7 +170,15 @@ public class CrystalWalletService extends LifecycleService { } }); - + final LiveData> cryptoNetAccountList = db.cryptoNetAccountDao().getAllBitcoins(); + cryptoNetAccountList.observe(this, new Observer>() { + @Override + public void onChanged(@Nullable List cryptoNetAccounts) { + for(CryptoNetAccount nextCryptoNetAccount : cryptoNetAccounts) { + generalAccountManager.loadAccountFromDB(nextCryptoNetAccount,thisService); + } + } + }); /*while(this.keepLoadingAccountTransactions){ try{ diff --git a/app/src/main/java/cy/agorise/crystalwallet/views/CryptoNetAccountAdapter.java b/app/src/main/java/cy/agorise/crystalwallet/views/CryptoNetAccountAdapter.java index 1917046..e08d0ae 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/views/CryptoNetAccountAdapter.java +++ b/app/src/main/java/cy/agorise/crystalwallet/views/CryptoNetAccountAdapter.java @@ -2,6 +2,7 @@ package cy.agorise.crystalwallet.views; import android.arch.lifecycle.ViewModelProviders; import android.content.Context; +import android.support.annotation.Nullable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -30,6 +31,11 @@ public class CryptoNetAccountAdapter extends ArrayAdapter { this.data = objects; } + @Override + public CryptoNetAccount getItem(int position) { + return data.get(position); + } + @Override public View getDropDownView(int position, View convertView, ViewGroup parent) { return getView(position, convertView, parent);