Fix total value calculus and allow fiat display
- Fix Deduct switch not being updated when editing a transaction Previous commit tested and working
This commit is contained in:
parent
4738a65dcc
commit
7623012353
@ -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())
|
||||
@ -699,14 +715,9 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -30,7 +30,6 @@ public class BalanceManager implements BinanceUpdateNotifierInterface, HitBTCUpd
|
||||
|
||||
private int balanceCounter;
|
||||
|
||||
//NEW IMPLEMENTATION
|
||||
private List<HitBtcManager> hitBtcManagers;
|
||||
private List<BinanceManager> binanceManagers;
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user