diff --git a/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Summary.java b/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Summary.java index 487f503..8d8b967 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Summary.java +++ b/app/src/main/java/com/herbron/moodl/Activities/HomeActivityFragments/Summary.java @@ -213,7 +213,7 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface, for (int i = 0; i < balanceManager.getTotalBalance().size(); i++) { final Currency currency = balanceManager.getTotalBalance().get(i); - if (!currency.getSymbol().equals("USD") && (Math.abs(currency.getBalance() * currency.getValue()) >= preferencesManager.getMinimumAmount())) { + if ((Math.abs(currency.getBalance() * currency.getValue()) >= preferencesManager.getMinimumAmount())) { //currencyView.add(layoutGenerator.getInfoLayout(currency, totalValue, preferencesManager.isBalanceHidden())); renderedCurrencies.add(currency); } @@ -236,6 +236,8 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface, loadingDialog.dismiss(); } + updateTitle(); + handler.removeCallbacks(updateRunnable); } }); @@ -371,9 +373,6 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface, { coinCounter = 0; iconCounter = 0; - - totalValue = 0; - totalFluctuation = 0; } private void adaptView() @@ -466,8 +465,25 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface, }); } + private void computeTotalValue() + { + totalValue = 0; + totalFluctuation = 0; + + for(int i = 0; i < currencyLayout.getChildCount(); i++) + { + if(currencyLayout.getChildAt(i) instanceof CurrencyCardview) + { + totalValue += ((CurrencyCardview) currencyLayout.getChildAt(i)).getOwnedValue(); + totalFluctuation += ((CurrencyCardview) currencyLayout.getChildAt(i)).getFluctuation(); + } + } + } + protected void updateTitle() { + computeTotalValue(); + float totalFluctuationPercentage = totalFluctuation / (totalValue - totalFluctuation) * 100; if(preferencesManager.isBalanceHidden()) @@ -700,13 +716,8 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface, private void loadCurrency(Currency currency) { - if(!currency.getSymbol().equals("USD")) - { - currency.setName(balanceManager.getCurrencyName(currency.getSymbol())); - currency.setId(balanceManager.getCurrencyId(currency.getSymbol())); - totalValue += currency.getValue() * currency.getBalance(); - totalFluctuation += (currency.getValue() * currency.getBalance()) * (currency.getDayFluctuationPercentage() / 100); - } + currency.setName(balanceManager.getCurrencyName(currency.getSymbol())); + currency.setId(balanceManager.getCurrencyId(currency.getSymbol())); } @Override @@ -732,13 +743,6 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface, balanceManager.getTotalBalance().set(i, localCurrency); } - getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - updateTitle(); - } - }); - return null; } diff --git a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java index 4bc3741..1b97985 100644 --- a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java +++ b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java @@ -275,6 +275,7 @@ public class BuyFragment extends CustomRecordFragment { totalValueEditText.setText(String.valueOf(transaction.getAmount() * transaction.getPrice())); fees_editText.setText(String.valueOf(transaction.getFees())); note_editText.setText(transaction.getNote()); + deductHoldingsSwitch.setChecked(transaction.isDeducted()); } private void initializeViewElements() diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/BalanceManager.java b/app/src/main/java/com/herbron/moodl/DataManagers/BalanceManager.java index 8693f8c..7de9f43 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/BalanceManager.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/BalanceManager.java @@ -30,7 +30,6 @@ public class BalanceManager implements BinanceUpdateNotifierInterface, HitBTCUpd private int balanceCounter; - //NEW IMPLEMENTATION private List hitBtcManagers; private List binanceManagers; diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyCardview.java b/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyCardview.java index 87f3e94..6fdee83 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyCardview.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/CurrencyData/CurrencyCardview.java @@ -305,6 +305,16 @@ public class CurrencyCardview extends CardView implements CurrencyInfoUpdateNoti } } + public double getOwnedValue() + { + return currency.getValue() * currency.getBalance(); + } + + public double getFluctuation() + { + return getOwnedValue() * (currency.getDayFluctuationPercentage() / 100); + } + private LineData generateData(Currency currency) { LineDataSet dataSet;