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

detecting longpress #16

Open
ndubbaka opened this issue Apr 15, 2019 · 0 comments
Open

detecting longpress #16

ndubbaka opened this issue Apr 15, 2019 · 0 comments

Comments

@ndubbaka
Copy link

Is there a better way than below code? I am trying to find out the position(X, Y) of selected text on a zoomed image.

ImageMatrixTouchHandler imageMatrixTouchHandler = new ImageMatrixTouchHandler(layout.getContext()){
                @Override
                public boolean onTouch(View view, MotionEvent event) {
                    Log.d(TAG, "onTouch: ");
                    super.onTouch(view, event);
                    Log.d(TAG, "onTouch: super");
                    final GestureDetector gestureDetector = new GestureDetector(ViewImageActivity.this, new GestureDetector.SimpleOnGestureListener() {
                        public void onLongPress(MotionEvent e) {
                            Log.e(TAG, "Longpress detected event "+event.getAction()+" e "+e.getAction());
                            if(event.getAction() == 0){
                                Log.d(TAG, "onLongPress: real detected X: "+e.getX()+" Y: "+e.getY()+" event X: "+event.getX()+" Y: "+event.getY()+" raw Y"+event.getRawY());
                                Toast.makeText(getApplicationContext(), "Long Clicked " , Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
                    gestureDetector.onTouchEvent(event);
                    return true; // indicate event was handled
                }
            };
            ivImage.setOnTouchListener(imageMatrixTouchHandler);
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

1 participant