]> git.ktnx.net Git - mobile-ledger.git/commitdiff
model: reorder account rows by their position
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 8 Feb 2021 06:01:32 +0000 (06:01 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 18 Feb 2021 07:36:20 +0000 (07:36 +0000)
it is stupid that this cannot be achieved in Room

app/src/main/java/net/ktnx/mobileledger/ui/templates/TemplateDetailsViewModel.java

index 9f87aa796cdc8605e14c400b004f006a8e2bb40f..5d8ef18a084dddb696721a574aa7c25b92bcf3c1 100644 (file)
@@ -173,6 +173,8 @@ public class TemplateDetailsViewModel extends ViewModel {
 
                 TemplateDetailsItem header = TemplateDetailsItem.fromRoomObject(src.header);
                 l.add(header);
+                Collections.sort(src.accounts,
+                        (o1, o2) -> Long.compare(o1.getPosition(), o2.getPosition()));
                 for (TemplateAccount acc : src.accounts) {
                     l.add(TemplateDetailsItem.fromRoomObject(acc));
                 }