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

Crash(NullPointerException) if padding is added to SwipeListView #7

Open
mateusgrb opened this issue Sep 15, 2015 · 1 comment
Open

Comments

@mateusgrb
Copy link

If I add padding to the SwipeListView in XML, I get a crash.

Example:

<com.fortysevendeg.swipelistview.SwipeListView
    android:id="@+id/fragment_contacts_list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="30dp"
    android:paddingTop="30dp"
    swipe:swipeBackView="@+id/list_item_contacts_back"
    swipe:swipeFrontView="@+id/list_item_contacts_front"
    swipe:swipeOpenOnLongPress="false" />

Steps to reproduce:
1-Add some padding to your SwipeListView
2-Scroll your list, swipe an item and scroll again. Keep playing around with that and the app quickly crashes.

Stack Trace:

java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.ViewPropertyAnimator android.view.View.animate()' on a null object reference
at com.nineoldandroids.view.ViewPropertyAnimatorICS.(ViewPropertyAnimatorICS.java:22)
at com.nineoldandroids.view.ViewPropertyAnimator.animate(ViewPropertyAnimator.java:62)
at com.fortysevendeg.swipelistview.SwipeListViewTouchListener.generateRevealAnimate(SwipeListViewTouchListener.java:644)
at com.fortysevendeg.swipelistview.SwipeListViewTouchListener.closeAnimate(SwipeListViewTouchListener.java:527)
at com.fortysevendeg.swipelistview.SwipeListViewTouchListener.closeOpenedItems(SwipeListViewTouchListener.java:783)
at com.fortysevendeg.swipelistview.SwipeListViewTouchListener$7.onScrollStateChanged(SwipeListViewTouchListener.java:723)
at android.support.v7.widget.RecyclerView.dispatchOnScrollStateChanged(RecyclerView.java:3841)
at android.support.v7.widget.RecyclerView.setScrollState(RecyclerView.java:1141)
at android.support.v7.widget.RecyclerView.onTouchEvent(RecyclerView.java:2339)
at android.view.View.dispatchTouchEvent(View.java:8471)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2399)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2092)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2369)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1719)
at android.app.Activity.dispatchTouchEvent(Activity.java:2742)
at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2330)
at android.view.View.dispatchPointerEvent(View.java:8666)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4123)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3989)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3680

@mateusgrb
Copy link
Author

I found out the crash happens because I'm using different item view types in the list and one of them(not supposed to be swiped) doesn't have a view called R.id.list_item_contacts_front.

Anyway, the root of the crash is that the padding added to the recyclerview tricks it into thinking that some items are not visible anymore when they are technically still on the screen(hidden by the padding). So the getChildAt inside closeOpenedItems gets the wrong element to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant