hudomju / android-swipe-to-dismiss-undo

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

Touch feedback on list items #6

Open SimplicityApks opened 9 years ago

SimplicityApks commented 9 years ago

It looks like there is no touch feedback when selecting items in your sample, and when I try to add that by adding android:clickable="true" android:background="?android:selectableItemBackground" to either the content view or the parent view of the list item it breaks swiping. This is a real deal breaker for me...

Is there anything that I'm missing here?

raghunandankavi2010 commented 9 years ago

@SimplicityApks i guess this is because you cannot have touch and click at the same time. I saw this glitch in many others libraries for swipe to dismiss libraries. I am looking for a work around myself.

This needs to be fixed

mrtomrichy commented 9 years ago

I agree - a way around this would be great. The Gmail app seems to be able to handle touches and clicks, would be nice to see that kind of behaviour.

silva96 commented 9 years ago

This is a real problem, breaks the material design proposed standards (design guideline)

I added an UGLY fix in order to give a small feedback on click. (Doesn't work onDown, only with onSingleTapUp)

mRecyclerView.addOnItemTouchListener(new SwipeableItemClickListener(mContext,
                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 {
                            final View view_aux= view;
                            final int position_aux = position;
                            Runnable handleTheClick = new Runnable() {
                                @Override
                                public void run() {
                                    //DO YOUR LOGIC HERE
                                }
                            };
                            view.setClickable(true);
                            view.setPressed(true);
                            view.postOnAnimationDelayed(handleTheClick, 250);
                        }

                    }

                }) {
            @Override
            public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
            }
        });