Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make imageView on card fullscreen when single tapped? #114

Open
ctoto93 opened this issue Oct 7, 2015 · 6 comments
Open

How to make imageView on card fullscreen when single tapped? #114

ctoto93 opened this issue Oct 7, 2015 · 6 comments

Comments

@ctoto93
Copy link

ctoto93 commented Oct 7, 2015

Here is my implementation to see imageView on card in fullscreen by double tapping. However, I need it to be single tap. My problem is, on MotionEvent.ACTION_DOWN, it need to be return false so that the card can be swiped, but ACTION_UP will be never called since it is not consumed in the event ACTION_DOWN.

    profilePicture.setOnTouchListener(new View.OnTouchListener() {
        long timestamp = 0;

        @Override
        public boolean onTouch(View v, MotionEvent event) {

            if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
                long now = System.currentTimeMillis();
                long diff = now - timestamp;
                if (diff < 500) {
                    Log.d("Gesture", "double tap");
                    Intent i = new Intent(context, FullPhotoActivity.class);
                    i.putExtra("deviceID", userToShow.getDeviceID());
                    context.startActivity(i);
                    return true;
                } else {
                    timestamp = now;
                }

            }
            return false;

        }


    });
@alexwalterbos
Copy link

Don't use the OnTouchListener but use the OnClickListener instead. Since the touch events are consumed in the listeners, that will disable the swipe in the current implementation of the library when the swipe is started on the picture.

@ctoto93
Copy link
Author

ctoto93 commented Oct 7, 2015

Previously, I used onClickListener. When image is pressed (not realesed yet), the card is not moved. When it is released, the onclicklistener invoked

@alexwalterbos
Copy link

That's indeed the limitation of using the OnClickListener, you'll have to delegate the touch events to the child views which will be quite a challenge.

@ctoto93
Copy link
Author

ctoto93 commented Oct 8, 2015

So what would you suggest? I need it to be singe rather than double tapped, just like Tinder does. Thanks before :'D

@alexwalterbos
Copy link

You can edit the FlingCardListener to handle the touch events as clicks if there is little to no movement between the UP and DOWN event. I've had this problem too though, I'm planning to write this myself somewhere in the future.

@startxlabsdev
Copy link

I have also same problem, please suggest solution for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants