From d740f717306f46cb8a0284cbb1688ddc7bafd957 Mon Sep 17 00:00:00 2001 From: Michael Shafrir Date: Fri, 30 Aug 2019 17:13:25 -0400 Subject: [PATCH] Remove toggleSelected() in PaymentMethodsAdapter This call is unnecessary - we handle updating the UI by calling `setSelectedIndex()` and `notifyItemChanged()` on the impacted items. Also re-enable item animation now that this is fixed. --- .../com/stripe/android/view/MaskedCardView.kt | 7 ------- .../android/view/PaymentMethodsActivity.java | 3 ++- .../android/view/PaymentMethodsAdapter.kt | 5 ----- .../stripe/android/view/MaskedCardViewTest.java | 17 ----------------- 4 files changed, 2 insertions(+), 30 deletions(-) diff --git a/stripe/src/main/java/com/stripe/android/view/MaskedCardView.kt b/stripe/src/main/java/com/stripe/android/view/MaskedCardView.kt index e4168cc1a83..2682a088b88 100644 --- a/stripe/src/main/java/com/stripe/android/view/MaskedCardView.kt +++ b/stripe/src/main/java/com/stripe/android/view/MaskedCardView.kt @@ -90,13 +90,6 @@ internal class MaskedCardView @JvmOverloads constructor( cardInformationTextView.text = createDisplayString() } - /** - * Toggle the view from selected to unselected or vice-versa. - */ - fun toggleSelected() { - setSelected(!isSelected) - } - private fun initializeCheckMark() { updateDrawable(R.drawable.ic_checkmark, checkMarkImageView, true) } diff --git a/stripe/src/main/java/com/stripe/android/view/PaymentMethodsActivity.java b/stripe/src/main/java/com/stripe/android/view/PaymentMethodsActivity.java index 9cd2691199d..018a6366d8f 100644 --- a/stripe/src/main/java/com/stripe/android/view/PaymentMethodsActivity.java +++ b/stripe/src/main/java/com/stripe/android/view/PaymentMethodsActivity.java @@ -9,6 +9,7 @@ import android.support.annotation.Nullable; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; @@ -78,7 +79,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { recyclerView.setHasFixedSize(false); recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.setAdapter(mAdapter); - recyclerView.setItemAnimator(null); + recyclerView.setItemAnimator(new DefaultItemAnimator()); mCustomerSession = CustomerSession.getInstance(); mStartedFromPaymentSession = args.isPaymentSessionActive; diff --git a/stripe/src/main/java/com/stripe/android/view/PaymentMethodsAdapter.kt b/stripe/src/main/java/com/stripe/android/view/PaymentMethodsAdapter.kt index 0760b8eb6c3..c635e3247e4 100644 --- a/stripe/src/main/java/com/stripe/android/view/PaymentMethodsAdapter.kt +++ b/stripe/src/main/java/com/stripe/android/view/PaymentMethodsAdapter.kt @@ -81,7 +81,6 @@ internal class PaymentMethodsAdapter : RecyclerView.Adapter