SwipeStack icon indicating copy to clipboard operation
SwipeStack copied to clipboard

added onclick and onlongclick to swipestacklistener

Open poovamraj opened this issue 9 years ago • 3 comments

Added one of the core functionality the library has been missing. Since we couldn't click on any items inside the card I have added a code snippet that would act as an onClick and onLongClick listeners. I changed the build files by mistake the code change is made in the SwipeHelper.java file

poovamraj avatar Dec 14 '16 22:12 poovamraj

+1 for this feature

darvid7 avatar May 28 '17 10:05 darvid7

Another implementation with less to be learned by newcomers, just using allow the regular clickListener on your view to work https://github.com/flschweiger/SwipeStack/pull/47/files.

Btw if reviews usually take this long I will not contribute further, sorry

jaimeagudo avatar Jun 09 '17 20:06 jaimeagudo

I found a workaround that doesn't require you to modfiy the source.

SwipeStack.SwipeProgressListener swipeProgressListener = new SwipeStack.SwipeProgressListener() {

    // Called when user starts interacting with the repository card.
    @Override
    public void onSwipeStart(int position) { mSwipeIsTouch = true; }

    // Called when user moves the repository card.
    @Override
    public void onSwipeProgress(int position, float progress) { mSwipeIsTouch = false; }

    // Called when user stops interacting with the repository card.
    @Override
    public void onSwipeEnd(int position) {
        if (mSwipeIsTouch) {
            onTouch(position);
        }
    }
};

Pretty much check if the swipe card is moved at all, if not just treat is as an onTouch() and call your own method.

public void onTouch(int position) {
        // Do work here.
}

darvid7 avatar Jun 11 '17 01:06 darvid7