RadaeePDF.com :: Topic: Detect when User starts to zoom (1/1)
Welcome, Guest
Username: Password: Remember me

Signin/Signup with:

Questions about Android development and PDF

TOPIC: Detect when User starts to zoom

Detect when User starts to zoom 2 years 10 months ago #7205

  • custompdf
  • custompdf's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
  • Karma: 0
Is there any callback we can use to detect when the user starts to zoom a pdf?
The administrator has disabled public write access.

Detect when User starts to zoom 2 years 10 months ago #7208

  • radaee
  • radaee's Avatar
  • OFFLINE
  • Moderator
  • Posts: 825
  • Thank you received: 10
  • Karma: 43
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.
The administrator has disabled public write access.

Detect when User starts to zoom 2 years 9 months ago #7324

  • custompdf
  • custompdf's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
  • Karma: 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
    }
The administrator has disabled public write access.
Powered by Kunena Forum