From 131a5c5ea8589b5efea44656e064d83a8ba1b61e Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Sat, 28 Oct 2017 20:58:39 -0400 Subject: [PATCH] - Now the name of the coins appears in the balances, instead of "unknown"; --- .../cy/agorise/crystalwallet/dao/CryptoCurrencyDao.java | 2 +- .../crystalwallet/views/CryptoCoinBalanceViewHolder.java | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoCurrencyDao.java b/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoCurrencyDao.java index e34106f..142e312 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoCurrencyDao.java +++ b/app/src/main/java/cy/agorise/crystalwallet/dao/CryptoCurrencyDao.java @@ -20,7 +20,7 @@ public interface CryptoCurrencyDao { List getAll(); @Query("SELECT * FROM crypto_currency WHERE id = :id") - CryptoCurrency getById(int id); + CryptoCurrency getById(long id); @Query("SELECT * FROM crypto_currency WHERE id IN (:ids)") List getByIds(List ids); diff --git a/app/src/main/java/cy/agorise/crystalwallet/views/CryptoCoinBalanceViewHolder.java b/app/src/main/java/cy/agorise/crystalwallet/views/CryptoCoinBalanceViewHolder.java index c46d448..7783260 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/views/CryptoCoinBalanceViewHolder.java +++ b/app/src/main/java/cy/agorise/crystalwallet/views/CryptoCoinBalanceViewHolder.java @@ -1,12 +1,15 @@ package cy.agorise.crystalwallet.views; +import android.content.Context; import android.support.v7.widget.RecyclerView; import android.view.View; import android.widget.TextView; import cy.agorise.crystalwallet.R; +import cy.agorise.crystalwallet.dao.CrystalDatabase; import cy.agorise.crystalwallet.models.CryptoCoinBalance; import cy.agorise.crystalwallet.models.CryptoCoinTransaction; +import cy.agorise.crystalwallet.models.CryptoCurrency; /** * Created by Henry Varona on 17/9/2017. @@ -15,11 +18,13 @@ import cy.agorise.crystalwallet.models.CryptoCoinTransaction; public class CryptoCoinBalanceViewHolder extends RecyclerView.ViewHolder { private TextView cryptoCoinName; private TextView cryptoCoinBalance; + private Context context; public CryptoCoinBalanceViewHolder(View itemView) { super(itemView); cryptoCoinName = (TextView) itemView.findViewById(R.id.tvCryptoCoinName); cryptoCoinBalance = (TextView) itemView.findViewById(R.id.tvCryptoCoinBalanceAmount); + this.context = itemView.getContext(); } @@ -33,7 +38,9 @@ public class CryptoCoinBalanceViewHolder extends RecyclerView.ViewHolder { cryptoCoinName.setText("loading..."); cryptoCoinBalance.setText(""); } else { - //cryptoCoinName.setText(balance.getCoin().getLabel()); + CryptoCurrency currency = CrystalDatabase.getAppDatabase(this.context).cryptoCurrencyDao().getById(balance.getCryptoCurrencyId()); + + cryptoCoinName.setText(currency.getName()); cryptoCoinBalance.setText(""+balance.getBalance()); } }