Skip to content
This repository has been archived by the owner on Jul 22, 2019. It is now read-only.

added onclick and onlongclick to swipestacklistener #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

poovamraj
Copy link

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

Copy link

@FelipeRRM FelipeRRM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing this. Was really helpful and helped me. Too bad the repo owner seem's to be inactive and won't merge this.

/**
* Called when there is a click action.
*/
void onClick();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good idea to update the javadoc on the listener, adding mentions of these new methods.

float y2 = event.getY();
dx = x2 -x1;
dy = y2 -y1;
float MAX_CLICK_DISTANCE = 0.5f;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be better defined as a constant on the class (private static final) for better organization. I also find that a value a little above this works better.

@darvid7
Copy link

darvid7 commented May 28, 2017

+1 for this feature

@jaimeagudo
Copy link

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

@darvid7
Copy link

darvid7 commented Jun 11, 2017

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.
}

dmllr pushed a commit to dmllr/SwipeStack that referenced this pull request Nov 28, 2017
dmllr pushed a commit to dmllr/SwipeStack that referenced this pull request Nov 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants