Closed pragneshghoda closed 3 years ago
@pragneshghoda I tested the code in a sample project having TabLayout with ViewPager and FragmentStatePagerAdapter, but it's working fine in my case.
I have been facing crash on swipe cards while i cancel swipe of cards.
Can you tell me, how you are cancelling the swipe?
@janishar Thanks for your quick response.
I have updated library from 0.6.1 to 0.6.2. There is lower crash ratio than before.
I have one fragment and in that fragment I used 2 tabs with fragment. Both have swipeholderview.
So when I loaded both fragments in tab and swipe cards. When I leave swiping it goes to swipeCancelState and then this exception occurs. It is random crash. doesn't happen on regular basis.
@pragneshghoda Can you share the code where you are adding the card object in addView of the swipeholderview;
I have assign swipeview as below :
mSwipeView.getBuilder()
.setDisplayViewCount(3)
.setSwipeDecor(new SwipeDecor()
.setRelativeScale(0.01f));
and added views as below.
if (listMatchUsers.size() > 0) {
swipeIndex = 0;
swipeMaxIndex = listMatchUsers.size();
mSwipeView.removeAllViews();
for (Matchuser user : listMatchUsers) {
TinderCard cardItem = new TinderCard(mContext, user, mSwipeView);
cardItem.setOnItemClickListener(this);
mSwipeView.addView(cardItem);
}
} else {
flirt_empty_stack.setVisibility(View.VISIBLE);
}
@pragneshghoda
Try adding this line to the ViewPager containing the tab fragment.
mViewPager.setOffscreenPageLimit(mTabLayout.getTabCount());
@janishar
I am not using ViewPager. I have FrameLayout for both Fragments. Tabs are not swipable.
What do you mean by tabs?
I have one fragment and in that fragment I used 2 tabs with fragment
Can you provide your view hierarchy?
I have one Activity with FrameLayout > Loading 5 Fragments in FrameLayout > One of the fragment have TabView with Framelayout and loading 2 Fragments with ChildFragmentManager() in both tab i have swipeview enabled.
Hello @janishar , I have been facing crash on swipe cards while i cancel swipe of cards. It is a random crash but happning too many times.
It happens while I have loaded cards on fragment and change the tab. When i came back and try to swiping a card. But when i cancel swiping card, app got crashed.
Please look on this bug. Thanks.
## Stack Trace :
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference at com.mindorks.placeholderview.SwipeViewBinder.bindSwipeCancelState(SwipeViewBinder.java:196) at com.mindorks.placeholderview.SwipePlaceHolderView.onResetView(SwipePlaceHolderView.java:593) at com.mindorks.placeholderview.SwipeViewBinder$2.onAnimationEnd(SwipeViewBinder.java:256) at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd(ViewPropertyAnimator.java:1116) at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1171) at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:722) at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:738) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) at android.view.Choreographer.doCallbacks(Choreographer.java:580) at android.view.Choreographer.doFrame(Choreographer.java:549) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5343) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)