Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove toggleSelected() in PaymentMethodsAdapter #1462

Merged
merged 1 commit into from
Aug 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ internal class PaymentMethodsAdapter : RecyclerView.Adapter<PaymentMethodsAdapte
val currentPosition = holder.adapterPosition
if (currentPosition != selectedIndex) {
val prevSelectedIndex = selectedIndex
holder.toggleSelected()
setSelectedIndex(currentPosition)

notifyItemChanged(prevSelectedIndex)
Expand Down Expand Up @@ -132,10 +131,6 @@ internal class PaymentMethodsAdapter : RecyclerView.Adapter<PaymentMethodsAdapte
fun setSelected(selected: Boolean) {
cardView.isSelected = selected
}

fun toggleSelected() {
cardView.toggleSelected()
}
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,6 @@ public void setSelected_changesCheckMarkVisibility() {
assertEquals(View.VISIBLE, mSelectedImageView.getVisibility());
}

@Test
public void toggleSelected_switchesState() {
final PaymentMethod paymentMethod =
PaymentMethod.fromString(PaymentMethodTest.PM_CARD_JSON);
assertNotNull(paymentMethod);
mMaskedCardView.setPaymentMethod(paymentMethod);
assertFalse(mMaskedCardView.isSelected());

mMaskedCardView.toggleSelected();
assertTrue(mMaskedCardView.isSelected());
assertEquals(View.VISIBLE, mSelectedImageView.getVisibility());

mMaskedCardView.toggleSelected();
assertFalse(mMaskedCardView.isSelected());
assertEquals(View.INVISIBLE, mSelectedImageView.getVisibility());
}

@Test
public void whenSourceNotCard_doesNotCrash() {
final PaymentMethod paymentMethod = new PaymentMethod.Builder().build();
Expand Down