Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1

TOPIC:

Detect when User starts to zoom 9 years 6 months ago #7205

  • custompdf
  • custompdf's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • 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 9 years 6 months ago #7208

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
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 9 years 6 months ago #7324

  • custompdf
  • custompdf's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • 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