[android] Changed yearly saving calculation for bookmarks subscription

This commit is contained in:
Александр Зацепин 2019-07-10 13:56:21 +03:00 committed by yoksnod
parent 3284c924fb
commit 1d06f6cc21

View file

@ -202,8 +202,7 @@ public class BookmarkSubscriptionFragment extends BaseMwmFragment
TextView priceView = getViewOrThrow().findViewById(R.id.annual_price);
priceView.setText(price);
TextView savingView = getViewOrThrow().findViewById(R.id.sale);
String saving = Utils.formatCurrencyString(calculateYearlySaving(), details.getCurrencyCode());
savingView.setText(getString(R.string.annual_save_component, saving));
savingView.setText(getString(R.string.annual_save_component, calculateYearlySaving()));
}
private void updateMonthlyButton()
@ -214,11 +213,11 @@ public class BookmarkSubscriptionFragment extends BaseMwmFragment
priceView.setText(price);
}
private float calculateYearlySaving()
private int calculateYearlySaving()
{
float pricePerMonth = getProductDetailsForPeriod(PurchaseUtils.Period.P1M).getPrice();
float pricePerYear = getProductDetailsForPeriod(PurchaseUtils.Period.P1Y).getPrice();
return pricePerMonth * PurchaseUtils.MONTHS_IN_YEAR - pricePerYear;
return (int) (100 * (1 - pricePerYear / (pricePerMonth * PurchaseUtils.MONTHS_IN_YEAR)));
}
@NonNull