]> git.ktnx.net Git - mobile-ledger.git/commitdiff
bump library dependencies
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 18 Apr 2021 10:43:24 +0000 (13:43 +0300)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 18 Apr 2021 10:43:24 +0000 (13:43 +0300)
RecycleView 1.2.0 deprecated getAdapterPosition, replace with
getBindingAdapterPosition -- no concat adapters are used

app/build.gradle
app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryAdapter.java
app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionAccountRowItemHolder.java
app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionHeaderItemHolder.java
app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemViewHolder.java
app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemsAdapter.java
app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfilesRecyclerViewAdapter.java
app/src/main/java/net/ktnx/mobileledger/ui/templates/TemplateDetailsAdapter.java

index 6cbd93bcd364e7493252a1bc15de046d7388b729..4bae3dbf474efb2e4ec419f4509eb29db497904f 100644 (file)
@@ -64,13 +64,13 @@ dependencies {
     def room_version = '2.2.6'
     implementation "androidx.room:room-runtime:$room_version"
     annotationProcessor "androidx.room:room-compiler:$room_version"
-    def nav_version = '2.3.4'
+    def nav_version = '2.3.5'
     implementation fileTree(include: ['*.jar'], dir: 'libs')
     implementation 'androidx.legacy:legacy-support-v4:1.0.0'
     implementation 'com.google.android.material:material:1.3.0'
     implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
     implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
-    implementation 'androidx.recyclerview:recyclerview:1.1.0'
+    implementation 'androidx.recyclerview:recyclerview:1.2.0'
     testImplementation 'junit:junit:4.13.2'
     androidTestImplementation 'androidx.test:runner:1.4.0-alpha05'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0-alpha05'
index 350c470db73f254374392245774bf64a2bcadac3..3a6130754db2dc8e2f064daf2516886733529287 100644 (file)
@@ -259,7 +259,7 @@ public class AccountSummaryAdapter extends RecyclerView.Adapter<AccountSummaryAd
         @NotNull
         private LedgerAccount getAccount() {
             return listDiffer.getCurrentList()
-                             .get(getAdapterPosition())
+                             .get(getBindingAdapterPosition())
                              .getAccount();
         }
         private void toggleAmountsExpanded() {
index 4e3a6cf8ef95a2a45896bb623af36375e5daeb3f..5e930569e1afac281593d7a7d0d5cd51151b87e2 100644 (file)
@@ -31,6 +31,7 @@ import android.widget.TextView;
 import androidx.annotation.ColorInt;
 import androidx.annotation.NonNull;
 import androidx.constraintlayout.widget.ConstraintLayout;
+import androidx.recyclerview.widget.RecyclerView;
 
 import net.ktnx.mobileledger.R;
 import net.ktnx.mobileledger.databinding.NewTransactionAccountRowBinding;
@@ -73,7 +74,7 @@ class NewTransactionAccountRowItemHolder extends NewTransactionItemViewHolder {
                 boolean wasSyncing = syncingData;
                 syncingData = true;
                 try {
-                    final int pos = getAdapterPosition();
+                    final int pos = getBindingAdapterPosition();
                     if (id == R.id.account_row_acc_name) {
                         adapter.noteFocusIsOnAccount(pos);
                     }
@@ -178,7 +179,7 @@ class NewTransactionAccountRowItemHolder extends NewTransactionItemViewHolder {
             CurrencySelectorFragment cpf = new CurrencySelectorFragment();
             cpf.showPositionAndPadding();
             cpf.setOnCurrencySelectedListener(
-                    c -> adapter.setItemCurrency(getAdapterPosition(), c));
+                    c -> adapter.setItemCurrency(getBindingAdapterPosition(), c));
             cpf.show(activity.getSupportFragmentManager(), "currency-selector");
         });
 
@@ -221,7 +222,7 @@ class NewTransactionAccountRowItemHolder extends NewTransactionItemViewHolder {
         ignoreFocusChanges = true;
         try {
             if (((focusInfo == null) || (focusInfo.element == null) ||
-                 focusInfo.position != getAdapterPosition()))
+                 focusInfo.position != getBindingAdapterPosition()))
                 return;
 
             NewTransactionModel.TransactionAccount acc = getItem().toTransactionAccount();
@@ -397,7 +398,7 @@ class NewTransactionAccountRowItemHolder extends NewTransactionItemViewHolder {
             return false;
         }
 
-        if (getAdapterPosition() < 0) {
+        if (getBindingAdapterPosition() == RecyclerView.NO_POSITION) {
             // probably the row was swiped out
             Logger.debug("new-trans", "Ignoring request to suncData(): adapter position negative");
             return false;
index feaf745971624ac937daba3f966d991cdb0c8b5b..37c55ce8aa1e4b19ec98f4b287d003683d8773c8 100644 (file)
@@ -29,6 +29,7 @@ import android.widget.TextView;
 
 import androidx.annotation.ColorInt;
 import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
 
 import net.ktnx.mobileledger.R;
 import net.ktnx.mobileledger.databinding.NewTransactionHeaderRowBinding;
@@ -71,7 +72,7 @@ class NewTransactionHeaderItemHolder extends NewTransactionItemViewHolder
                 boolean wasSyncing = syncingData;
                 syncingData = true;
                 try {
-                    final int pos = getAdapterPosition();
+                    final int pos = getBindingAdapterPosition();
                     if (id == R.id.transaction_comment) {
                         adapter.noteFocusIsOnTransactionComment(pos);
                     }
@@ -153,7 +154,7 @@ class NewTransactionHeaderItemHolder extends NewTransactionItemViewHolder
         ignoreFocusChanges = true;
         try {
             if (((focusInfo == null) || (focusInfo.element == null) ||
-                 focusInfo.position != getAdapterPosition()))
+                 focusInfo.position != getBindingAdapterPosition()))
                 return;
 
             NewTransactionModel.Item head = getItem().toTransactionHead();
@@ -249,7 +250,7 @@ class NewTransactionHeaderItemHolder extends NewTransactionItemViewHolder
             return false;
         }
 
-        if (getAdapterPosition() < 0) {
+        if (getBindingAdapterPosition() == RecyclerView.NO_POSITION) {
             // probably the row was swiped out
             Logger.debug("new-trans", "Ignoring request to suncData(): adapter position negative");
             return false;
index f78fdbe81efc680cea373124bb620f4a3c2d58eb..56daf91f80adaf3a04532151b0b40b066687994f 100644 (file)
@@ -35,10 +35,10 @@ abstract class NewTransactionItemViewHolder extends RecyclerView.ViewHolder {
         mProfile = Data.getProfile();
     }
     NewTransactionModel.Item getItem() {
-        return mAdapter.getItem(getAdapterPosition());
+        return mAdapter.getItem(getBindingAdapterPosition());
 //        return Objects.requireNonNull(mAdapter.model.getItems()
 //                                                    .getValue())
-//                      .get(getAdapterPosition());
+//                      .get(getBindingAdapterPosition());
     }
     abstract public void bind(NewTransactionModel.Item item);
 }
index 73ddc8fe37f929ca495cf1158f9eafb0e474db1b..b6b17beaf827add2bbab416da70301dd643e0553 100644 (file)
@@ -81,7 +81,7 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter<NewTransactionItem
             public boolean canDropOver(@NonNull RecyclerView recyclerView,
                                        @NonNull RecyclerView.ViewHolder current,
                                        @NonNull RecyclerView.ViewHolder target) {
-                final int adapterPosition = target.getAdapterPosition();
+                final int adapterPosition = target.getBindingAdapterPosition();
 
                 // first item is immovable
                 if (adapterPosition == 0)
@@ -94,7 +94,7 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter<NewTransactionItem
                                         @NonNull RecyclerView.ViewHolder viewHolder) {
                 int flags = makeFlag(ItemTouchHelper.ACTION_STATE_IDLE, ItemTouchHelper.END);
                 // the top (date and description) and the bottom (padding) items are always there
-                final int adapterPosition = viewHolder.getAdapterPosition();
+                final int adapterPosition = viewHolder.getBindingAdapterPosition();
                 if (adapterPosition > 0) {
                     flags |= makeFlag(ItemTouchHelper.ACTION_STATE_DRAG,
                             ItemTouchHelper.UP | ItemTouchHelper.DOWN) |
@@ -109,12 +109,13 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter<NewTransactionItem
                                   @NonNull RecyclerView.ViewHolder viewHolder,
                                   @NonNull RecyclerView.ViewHolder target) {
 
-                model.moveItem(viewHolder.getAdapterPosition(), target.getAdapterPosition());
+                model.moveItem(viewHolder.getBindingAdapterPosition(),
+                        target.getBindingAdapterPosition());
                 return true;
             }
             @Override
             public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
-                int pos = viewHolder.getAdapterPosition();
+                int pos = viewHolder.getBindingAdapterPosition();
                 viewModel.removeItem(pos);
             }
         });
index d1cceb42f15ebed28dc5f446da7cc7323ac4a69e..08a071ddf63106703fbd10c00c501c6065b22599 100644 (file)
@@ -81,12 +81,13 @@ public class ProfilesRecyclerViewAdapter
                                   @NonNull RecyclerView.ViewHolder viewHolder,
                                   @NonNull RecyclerView.ViewHolder target) {
                 final List<Profile> profiles = new ArrayList<>(listDiffer.getCurrentList());
-                Collections.swap(profiles, viewHolder.getAdapterPosition(),
-                        target.getAdapterPosition());
+                Collections.swap(profiles, viewHolder.getBindingAdapterPosition(),
+                        target.getBindingAdapterPosition());
                 DB.get()
                   .getProfileDAO()
                   .updateOrder(profiles, null);
-//                notifyItemMoved(viewHolder.getAdapterPosition(), target.getAdapterPosition());
+//                notifyItemMoved(viewHolder.getBindingAdapterPosition(), target
+//                .getBindingAdapterPosition());
                 return true;
             }
             @Override
@@ -171,7 +172,7 @@ public class ProfilesRecyclerViewAdapter
 
         holder.mEditButton.setOnClickListener(view -> {
             Profile p = listDiffer.getCurrentList()
-                                  .get(holder.getAdapterPosition());
+                                  .get(holder.getBindingAdapterPosition());
             ProfileDetailActivity.start(view.getContext(), p);
         });
 
@@ -253,7 +254,7 @@ public class ProfilesRecyclerViewAdapter
             if (editingProfiles())
                 return;
             Profile profile = listDiffer.getCurrentList()
-                                        .get(getAdapterPosition());
+                                        .get(getBindingAdapterPosition());
             if (Data.getProfile() != profile) {
                 debug("profiles", "Setting profile to " + profile.getName());
                 Data.drawerOpen.setValue(false);
index 1872ff2ff7d0ee5139219ed899aed529ffcf8783..fa76664ee7ae798fcf729a7cf00083729a598873 100644 (file)
@@ -138,7 +138,7 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
             public boolean canDropOver(@NonNull RecyclerView recyclerView,
                                        @NonNull RecyclerView.ViewHolder current,
                                        @NonNull RecyclerView.ViewHolder target) {
-                final int adapterPosition = target.getAdapterPosition();
+                final int adapterPosition = target.getBindingAdapterPosition();
 
                 // first item is immovable
                 if (adapterPosition == 0)
@@ -151,7 +151,7 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
                                         @NonNull RecyclerView.ViewHolder viewHolder) {
                 int flags = 0;
                 // the top item (transaction params) is always there
-                final int adapterPosition = viewHolder.getAdapterPosition();
+                final int adapterPosition = viewHolder.getBindingAdapterPosition();
                 if (adapterPosition > 0)
                     flags |= makeFlag(ItemTouchHelper.ACTION_STATE_DRAG,
                             ItemTouchHelper.UP | ItemTouchHelper.DOWN) |
@@ -165,8 +165,8 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
                                   @NonNull RecyclerView.ViewHolder viewHolder,
                                   @NonNull RecyclerView.ViewHolder target) {
 
-                final int fromPosition = viewHolder.getAdapterPosition();
-                final int toPosition = target.getAdapterPosition();
+                final int fromPosition = viewHolder.getBindingAdapterPosition();
+                final int toPosition = target.getBindingAdapterPosition();
                 if (fromPosition == toPosition) {
                     Logger.debug("drag", String.format(Locale.US,
                             "Ignoring request to move an account from position %d to %d",
@@ -183,7 +183,7 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
             }
             @Override
             public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
-                int pos = viewHolder.getAdapterPosition();
+                int pos = viewHolder.getBindingAdapterPosition();
                 mModel.removeItem(pos);
             }
         });
@@ -421,7 +421,7 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
         }
         @NotNull
         private TemplateDetailsItem.Header getItem() {
-            int pos = getAdapterPosition();
+            int pos = getBindingAdapterPosition();
             return differ.getCurrentList()
                          .get(pos)
                          .asHeaderItem();
@@ -476,7 +476,7 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
                     }
                 }
 
-                notifyItemChanged(getAdapterPosition());
+                notifyItemChanged(getBindingAdapterPosition());
             });
             final AppCompatActivity activity = (AppCompatActivity) v.getContext();
             sel.show(activity.getSupportFragmentManager(), "template-details-source-selector");
@@ -761,7 +761,7 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
                 String groupNoText = resources.getString(R.string.template_item_match_group_source);
 
                 Logger.debug("drag", String.format(Locale.US, "Binding account id %d, pos %d at %d",
-                        item.getId(), item.getPosition(), getAdapterPosition()));
+                        item.getId(), item.getPosition(), getBindingAdapterPosition()));
                 TemplateDetailsItem.AccountRow accRow = item.asAccountRowItem();
                 b.patternAccountLabel.setText(String.format(Locale.US,
                         resources.getString(R.string.template_details_account_row_label),
@@ -837,7 +837,7 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
         }
         private @NotNull TemplateDetailsItem.AccountRow getItem() {
             return differ.getCurrentList()
-                         .get(getAdapterPosition())
+                         .get(getBindingAdapterPosition())
                          .asAccountRowItem();
         }
         private void selectAccountRowDetailSource(View v, AccDetail detail) {
@@ -879,7 +879,7 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter<TemplateDetailsAdapter
                     }
                 }
 
-                notifyItemChanged(getAdapterPosition());
+                notifyItemChanged(getBindingAdapterPosition());
             });
             final AppCompatActivity activity = (AppCompatActivity) v.getContext();
             sel.show(activity.getSupportFragmentManager(), "template-details-source-selector");