hudomju / android-swipe-to-dismiss-undo

Android swipe-to-dismiss-undo library and sample code
MIT License
240 stars 82 forks source link

Crash on Swipe #18

Open Nimade42 opened 8 years ago

Nimade42 commented 8 years ago

I have a crash i don't understand. Reading the crash, I think the error comes from the library. Here is my code:

    mAdapter = new ReservationRecyclerViewAdapter(mFinalData);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
    mRecyclerView.setAdapter(mAdapter);
    mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);

    final SwipeToDismissTouchListener<RecyclerViewAdapter> touchListener =
            new SwipeToDismissTouchListener<>(
                    new RecyclerViewAdapter(mRecyclerView),
                    new SwipeToDismissTouchListener.DismissCallbacks<RecyclerViewAdapter>() {
        @Override
        public boolean canDismiss(int position) {
            return true;
        }

        @Override
        public void onDismiss(RecyclerViewAdapter recyclerView, int position) {
            mFinalData.remove(position);
            mAdapter.notifyDataSetChanged();
        }
    });
    mRecyclerView.setOnTouchListener(touchListener);
    mRecyclerView.setOnScrollListener((RecyclerView.OnScrollListener) touchListener.makeScrollListener());
    mRecyclerView.addOnItemTouchListener(new SwipeableItemClickListener(getActivity(), new OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            if (view.getId() == R.id.txt_delete) {
                touchListener.processPendingDismisses();
            } else if (view.getId() == R.id.txt_undo) {
                touchListener.undoPendingDismiss();
            } else {
                Log.e("onItemClick", ": " + position);
            }
        }
    }));

And here is the crash log:

01-14 13:48:24.929 22540-22540/com.open.openresa E/AndroidRuntime: FATAL EXCEPTION: main Process: com.open.openresa, PID: 22540 java.lang.AbstractMethodError: abstract method not implemented at com.hudomju.swipe.SwipeableItemClickListener.onRequestDisallowInterceptTouchEvent(SwipeableItemClickListener.java) at android.support.v7.widget.RecyclerView.requestDisallowInterceptTouchEvent(RecyclerView.java:2309) at com.hudomju.swipe.adapter.RecyclerViewAdapter.requestDisallowInterceptTouchEvent(RecyclerViewAdapter.java:49) at com.hudomju.swipe.SwipeToDismissTouchListener.onTouch(SwipeToDismissTouchListener.java:329) at android.view.View.dispatchTouchEvent(View.java:7772) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2316) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2013) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2027) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2027) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2027) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2027) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2027) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2027) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2027) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2027) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2322) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2027) at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2109) at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1541) at android.app.Activity.dispatchTouchEvent(Activity.java:2491) at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60) at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60) at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2057) at android.view.View.dispatchPointerEvent(View.java:7973) at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4392) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4263) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3809) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3859) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3828) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3935) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3836) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3992) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3809) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3859) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3828) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3836) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3809) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6124) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6104) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6058) at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6254) at android.view.InputEventReceiver.dispatchInputEvent(

yuvalken commented 8 years ago

Same here...

fabiofalavinha commented 8 years ago

I had the same problem and I found the bug. The library with the new version "1.1" was not publish no maven central or jcenter. So, I just put the library into my android app and resolve the dependency locally. After that, my code had some issues about a new method on "SwipeToDismissTouchListener.DismissCallbacks". I just implements the method, like the sample app from the library and everything works again.

@hudomju I hope you publish the new version, because I don't to reference your code to my code. Tks a lot man! :P

valeriachub commented 8 years ago

@fabiofalavinha where did u find the new version "1.1" ? I see only 1.0 in the https://oss.sonatype.org/content/repositories/releases/com/hudomju/swipe-to-dismiss-undo/ :) And in 1.0 the same problem..