Detect when User starts to zoom - RadaeePDF.com
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
13 Jul 2017
Microsoft has ended support for Windows Phone 8.1
Read More...
Questions about Android development and PDF
  • Page:
  • 1

TOPIC: Detect when User starts to zoom

Detect when User starts to zoom 3 years 5 months ago #7205

  • custompdf
  • custompdf's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 14
  • Thank you received: 0
Is there any callback we can use to detect when the user starts to zoom a pdf?

Please Log in or Create an account to join the conversation.

Detect when User starts to zoom 3 years 5 months ago #7208

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 830
  • Karma: 43
  • Thank you received: 10
no callback for this, but you can add codes in PDFView.motionNormal()
switch case ACTION_POINTER_DOWN, for ZoomStart.
and add codes in PDFView.motionZoom() switch case ACTION_UP for ZoomEnd

this need source codes of PDFView class, which professional or premium license can get this file.

Please Log in or Create an account to join the conversation.

Detect when User starts to zoom 3 years 4 months ago #7324

  • custompdf
  • custompdf's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 14
  • Thank you received: 0
Found a solution myself, maybe someone else could need it:

I created a SimpleOnScaleGestureListener:
    public class PDFSimpleOnScaleGestureListener extends
    SimpleOnScaleGestureListener {

       @Override
       public boolean onScale(ScaleGestureDetector detector) {
        return true;
       }
    
       @Override
       public boolean onScaleBegin(ScaleGestureDetector detector) {
           mActivityViewScaleCallback.onPDFViewScaleCallback();
        return false;
       }
    
       @Override
       public void onScaleEnd(ScaleGestureDetector detector) {
       }

    }

//With an Interface for callback:

    /**
     * Callback for PDFViewerActivity
     */
    public interface OnPDFViewScaleCallback {
        /**
         * Callback when user starts to zoom pdf view
         */
        public void onPDFViewScaleCallback();
    }

//i use pdfview in a fragment so my activty implements the interface and to set the callback

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        mActivityViewScaleCallback = (OnPDFViewScaleCallback) activity;
        scaleGestureDetector = new ScaleGestureDetector(activity, new PDFSimpleOnScaleGestureListener());
    }

//and then i set the scaleGestureDetector to readercontroller (when view is drawn)

            mPdfView.setOnTouchListener(new OnTouchListener() {
                
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    scaleGestureDetector.onTouchEvent(event);
                    return false;
                }
            });
        }


//and in my activity I implement the interface and every time the user starts to scale the callback method is called
    @Override
    public void onPDFViewScaleCallback() {
       //TODO -> Your stuff
    }

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum