From fcdd10b21d0e4af59f70804c63d145512b2cb918 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 18 Apr 2021 13:43:24 +0300 Subject: [PATCH] bump library dependencies RecycleView 1.2.0 deprecated getAdapterPosition, replace with getBindingAdapterPosition -- no concat adapters are used --- app/build.gradle | 4 ++-- .../AccountSummaryAdapter.java | 2 +- .../NewTransactionAccountRowItemHolder.java | 9 +++++---- .../NewTransactionHeaderItemHolder.java | 7 ++++--- .../NewTransactionItemViewHolder.java | 4 ++-- .../NewTransactionItemsAdapter.java | 9 +++++---- .../profiles/ProfilesRecyclerViewAdapter.java | 11 +++++----- .../ui/templates/TemplateDetailsAdapter.java | 20 +++++++++---------- 8 files changed, 35 insertions(+), 31 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6cbd93bc..4bae3dbf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryAdapter.java b/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryAdapter.java index 350c470d..3a613075 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryAdapter.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryAdapter.java @@ -259,7 +259,7 @@ public class AccountSummaryAdapter extends RecyclerView.Adapter 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; diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionHeaderItemHolder.java b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionHeaderItemHolder.java index feaf7459..37c55ce8 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionHeaderItemHolder.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionHeaderItemHolder.java @@ -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; diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemViewHolder.java b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemViewHolder.java index f78fdbe8..56daf91f 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemViewHolder.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemViewHolder.java @@ -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); } diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemsAdapter.java b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemsAdapter.java index 73ddc8fe..b6b17bea 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemsAdapter.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionItemsAdapter.java @@ -81,7 +81,7 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter 0) { flags |= makeFlag(ItemTouchHelper.ACTION_STATE_DRAG, ItemTouchHelper.UP | ItemTouchHelper.DOWN) | @@ -109,12 +109,13 @@ class NewTransactionItemsAdapter extends RecyclerView.Adapter 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); diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/templates/TemplateDetailsAdapter.java b/app/src/main/java/net/ktnx/mobileledger/ui/templates/TemplateDetailsAdapter.java index 1872ff2f..fa76664e 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/templates/TemplateDetailsAdapter.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/templates/TemplateDetailsAdapter.java @@ -138,7 +138,7 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter 0) flags |= makeFlag(ItemTouchHelper.ACTION_STATE_DRAG, ItemTouchHelper.UP | ItemTouchHelper.DOWN) | @@ -165,8 +165,8 @@ class TemplateDetailsAdapter extends RecyclerView.Adapter