added onclick and onlongclick to swipestacklistener#33
added onclick and onlongclick to swipestacklistener#33poovamraj wants to merge 1 commit intoflschweiger:masterfrom
Conversation
FelipeRRM
left a comment
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
|
+1 for this feature |
|
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 |
|
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.
} |
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