]> git.ktnx.net Git - mobile-ledger.git/commitdiff
helper method fot getting the short account name
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 15 Dec 2018 19:35:33 +0000 (19:35 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 15 Dec 2018 19:35:33 +0000 (19:35 +0000)
assets:cash:Peter becomes a:c:Peter

app/src/main/java/net/ktnx/mobileledger/model/LedgerTransactionItem.java

index ff19a450251aef1077855d2862f21502cb42c0e8..3334706047813167f73bfb6c9afc309ed463931b 100644 (file)
@@ -40,6 +40,11 @@ public class LedgerTransactionItem {
     public String getAccountName() {
         return accountName;
     }
+    public String getShortAccountName() {
+        String result = accountName;
+        result = result.replaceAll("(?<=^|:)(.)[^:]+(?=:)", "$1");
+        return result;
+    }
 
     public void setAccountName(String accountName) {
         this.accountName = accountName;