From 2a4ba215e69f1106f6d1a83a78f50fcca0a098d8 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Tue, 28 Aug 2018 13:43:14 +0200 Subject: [PATCH] Fix 'infinity' balance percentage when hiding the balance --- .idea/caches/build_file_checksums.ser | Bin 540 -> 545 bytes .../HomeActivityFragments/Summary.java | 10 +++++++++- .../CurrencyData/CurrencyCardview.java | 6 ++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index c7baaf739d989bc42cf5042f3ae94cae9fd2ff69..ce3de474a50c71b4ce97aaf54f757eb2b9101f94 100644 GIT binary patch delta 81 zcmV-X0IvU>1fc|wm;``K8y}IJwUe0vL^7xp5}ld>Xcf?C5YOMJAn0@eFhe?ARdZ!> nb6i1WZE0?4b98cHbZ>H8E@yIKWNc+zlkfo>lZOEklkWj7|05qm delta 75 zcmV-R0JQ(11e^qrm;`vmjm(jpwGt~sI$TwAWpZ;|M|Ej*Z*^{ElfD5qlTiUg8PyUh hQsgO{MjOF-z)RJ-5p)0%XL4a=Y-N*x0Tq)F0uh5M9IOBU 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 8d8b967..595e631 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 @@ -228,7 +228,7 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface, for(int i = 0; i < renderedCurrencies.size(); i++) { //currencyLayout.addView(currencyView.get(i)); - currencyLayout.addView(new CurrencyCardview(getActivity(), renderedCurrencies.get(i), getActivity(), totalValue, preferencesManager.isBalanceHidden())); + currencyLayout.addView(new CurrencyCardview(getActivity(), renderedCurrencies.get(i), getActivity(), preferencesManager.isBalanceHidden())); } if(loadingDialog.isShowing()) @@ -478,6 +478,14 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface, totalFluctuation += ((CurrencyCardview) currencyLayout.getChildAt(i)).getFluctuation(); } } + + for(int i = 0; i < currencyLayout.getChildCount(); i++) + { + if(currencyLayout.getChildAt(i) instanceof CurrencyCardview) + { + ((CurrencyCardview) currencyLayout.getChildAt(i)).updateCardViewInfos(totalValue, preferencesManager.isBalanceHidden()); + } + } } protected void updateTitle() 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 6fdee83..e84c227 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 @@ -126,7 +126,7 @@ public class CurrencyCardview extends CardView implements CurrencyInfoUpdateNoti updateColor(currency); } - public CurrencyCardview(@NonNull final Context context, final Currency currency, Activity activity, float totalValue, boolean isBalanceHidden) + public CurrencyCardview(@NonNull final Context context, final Currency currency, Activity activity, boolean isBalanceHidden) { super(context); @@ -166,8 +166,6 @@ public class CurrencyCardview extends CardView implements CurrencyInfoUpdateNoti } }); - updateCardViewInfos(currency, totalValue, isBalanceHidden); - findViewById(R.id.linearLayoutSubCharts).setOnClickListener(detailsClickListener); findViewById(R.id.LineChartView).setOnClickListener(detailsClickListener); @@ -250,7 +248,7 @@ public class CurrencyCardview extends CardView implements CurrencyInfoUpdateNoti } } - private void updateCardViewInfos(Currency currency, float totalValue, boolean isBalanceHidden) + public void updateCardViewInfos(float totalValue, boolean isBalanceHidden) { double value = currency.getValue() * currency.getBalance(); double percentage = value / totalValue * 100;