Meetic / Shuffle

An easy to use swiping-view for Android
886 stars 83 forks source link

Swiping cards using buttons causes erratic behavior #19

Open JorisPotier opened 7 years ago

JorisPotier commented 7 years ago

Hi guys,

I'm having several problems when using the library and swiping card by using a Button. Here is my fork to illustrate this (see Horizontal section) : https://github.com/JorisPotier/Shuffle. I have just changed the implementation of the HorizontalActivity by adding a ShuffleListener, which goal is to finish the activity when all the 20 cards have been swiped, and to do some business logic for each swiped card (actually in the provided sample I'm just logging the position of the current swiped card).

My use case is the following : the user is swiping card very fast by using the "Right" button on the HorizontalActivity.

Problem 1 : capture du 2017-01-23 16 14 47 Some cards are randomly oriented.

Problem 2 : logs.txt It seems that the business logic is not triggered for all cards, and for some it has been made twice (see the log traces).

Problem 3 : The listener calls the onViewExited method for some non existing positions (see the log traces, we are logging a currentAdapterPosition equal to 21, which is not possible since I should have only 20 cards).

Problem 4 : The app is randomly crashing when we returned to the MainActivity after all cards have been swiped. Since the HorizontalActivity is finished, it seems that we have a non destroyed ShuffleViewAnimator which leaks a NullPointerException (see the same logs).

In my real production application we have implemented a workaround by disabling the buttons during the time a card is animating (and so the user cannot swipe fastly), but it is not very user friendly.

Can you help me on this ?

Regards.