From 2ee3874c91042392f2cd038a9ec35859eb7142fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint?= Date: Wed, 28 Jul 2021 19:15:00 +0200 Subject: [PATCH] Created a method in FormattedNumberTextView.java to format the counts. It groups the displayed number by thousands. --- .../customviews/FormattedNumberTextView.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/awais/instagrabber/customviews/FormattedNumberTextView.java b/app/src/main/java/awais/instagrabber/customviews/FormattedNumberTextView.java index 06cdbf93..c4b9ef60 100644 --- a/app/src/main/java/awais/instagrabber/customviews/FormattedNumberTextView.java +++ b/app/src/main/java/awais/instagrabber/customviews/FormattedNumberTextView.java @@ -13,6 +13,8 @@ import androidx.transition.Transition; import androidx.transition.TransitionManager; import androidx.transition.TransitionSet; +import java.text.DecimalFormat; +import java.text.NumberFormat; import java.time.Duration; import awais.instagrabber.customviews.helpers.ChangeText; @@ -156,10 +158,15 @@ public class FormattedNumberTextView extends AppCompatTextView { setText(NumberUtils.abbreviate(number, null)); return; } - setText(String.valueOf(number)); + setText(numberFormatter(number)); if (autoToggleToAbbreviation) { getHandler().postDelayed(() -> setShowAbbreviation(true), autoToggleTimeoutMs); } }); } + + private String numberFormatter(long number){ + DecimalFormat decimalFormat = new DecimalFormat("###,###"); + return decimalFormat.format(number); + } }