]> git.ktnx.net Git - mobile-ledger.git/commitdiff
header row has (adapter) ID of 0, not -1
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Mon, 8 Feb 2021 05:44:37 +0000 (05:44 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 18 Feb 2021 07:33:35 +0000 (07:33 +0000)
-1 is the ID of the first newly added account and IDs must be unique

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

index 5c49a494a6958885fc59b9016988ed89fc79b13a..a12c92b68d3daf955429deab274d9cdac512e61e 100644 (file)
@@ -193,7 +193,7 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
     public long getItemId(int position) {
         // header item is always first and IDs id may duplicate some of the account IDs
         if (position == 0)
-            return -1;
+            return 0;
         TemplateDetailsItem.AccountRow accRow = differ.getCurrentList()
                                                       .get(position)
                                                       .asAccountRowItem();
index 5132af264025056cb95a9ab9fde9271aadeea702..7f983807c59e3cd686f6d18fa2e7886b6b77dd9e 100644 (file)
@@ -66,7 +66,7 @@ public class TemplateDetailsViewModel extends ViewModel {
         if (list.size() < 1) {
             final TemplateDetailsItem.Header header = TemplateDetailsItem.createHeader();
             header.setName(mDefaultPatternName);
-            header.setId(genItemId());
+            header.setId(0);
             list.add(header);
             changes = true;
         }