Meetic / Shuffle

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

Variable number of cards to shuffle #20

Closed jandorete closed 5 years ago

jandorete commented 7 years ago

I am having trouble using this library with a variable number of cards. I want an infinite shuffle, but if I have less than 3 elements I get an IllegalStatementException.

Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. at android.view.ViewGroup.addViewInner(ViewGroup.java:4656) at android.view.ViewGroup.addView(ViewGroup.java:4497) at android.view.ViewGroup.addView(ViewGroup.java:4437) at android.view.ViewGroup.addView(ViewGroup.java:4410) at com.meetic.shuffle.Shuffle.updateAdapter(Shuffle.java:317) at com.meetic.shuffle.Shuffle.notifyDataSetChanged(Shuffle.java:215) at com.meetic.shuffle.Shuffle.setShuffleAdapter(Shuffle.java:68) at xprodevelopers.com.appclinicas.MainActivity$override.onCreate(MainActivity.java:53) at xprodevelopers.com.appclinicas.MainActivity$override.access$dispatch(MainActivity.java) at xprodevelopers.com.appclinicas.MainActivity.onCreate(MainActivity.java:0) at android.app.Activity.performCreate(Activity.java:6912) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2900) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3008)  at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4974)  at android.app.ActivityThread.-wrap21(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6688)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358) 

Is there any way to change the number of cards displayed through code?

Thanks.