// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/model/LinkTapEvent.java
// public class LinkTapEvent {
//     private float originalX;
//     private float originalY;
//     private float documentX;
//     private float documentY;
//     private RectF mappedLinkRect;
//     private PdfDocument.Link link;
// 
//     public LinkTapEvent(float originalX, float originalY, float documentX, float documentY, RectF mappedLinkRect, PdfDocument.Link link) {
//         this.originalX = originalX;
//         this.originalY = originalY;
//         this.documentX = documentX;
//         this.documentY = documentY;
//         this.mappedLinkRect = mappedLinkRect;
//         this.link = link;
//     }
// 
//     public float getOriginalX() {
//         return originalX;
//     }
// 
//     public float getOriginalY() {
//         return originalY;
//     }
// 
//     public float getDocumentX() {
//         return documentX;
//     }
// 
//     public float getDocumentY() {
//         return documentY;
//     }
// 
//     public RectF getMappedLinkRect() {
//         return mappedLinkRect;
//     }
// 
//     public PdfDocument.Link getLink() {
//         return link;
//     }
// }
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/SnapEdge.java
// public enum SnapEdge {
//     START, CENTER, END, NONE
// }
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/Constants.java
// public static float MAXIMUM_ZOOM = 10;
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/Constants.java
// public static float MINIMUM_ZOOM = 1;


import android.graphics.PointF;
import android.graphics.RectF;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import com.github.barteksc.pdfviewer.model.LinkTapEvent;
import com.github.barteksc.pdfviewer.scroll.ScrollHandle;
import com.github.barteksc.pdfviewer.util.SnapEdge;
import com.shockwave.pdfium.PdfDocument;
import com.shockwave.pdfium.util.SizeF;
import static com.github.barteksc.pdfviewer.util.Constants.Pinch.MAXIMUM_ZOOM;
import static com.github.barteksc.pdfviewer.util.Constants.Pinch.MINIMUM_ZOOM;

                    ps.hide();
                }
            }
        }
        pdfView.performClick();
        return true;
    }

    private boolean checkLinkTapped(float x, float y) {
        PdfFile pdfFile = pdfView.pdfFile;
        if (pdfFile == null) {
            return false;
        }
        float mappedX = -pdfView.getCurrentXOffset() + x;
        float mappedY = -pdfView.getCurrentYOffset() + y;
        int page = pdfFile.getPageAtOffset(pdfView.isSwipeVertical() ? mappedY : mappedX, pdfView.getZoom());
        SizeF pageSize = pdfFile.getScaledPageSize(page, pdfView.getZoom());
        int pageX, pageY;
        if (pdfView.isSwipeVertical()) {
            pageX = (int) pdfFile.getSecondaryPageOffset(page, pdfView.getZoom());
            pageY = (int) pdfFile.getPageOffset(page, pdfView.getZoom());
        } else {
            pageY = (int) pdfFile.getSecondaryPageOffset(page, pdfView.getZoom());
            pageX = (int) pdfFile.getPageOffset(page, pdfView.getZoom());
        }
        for (PdfDocument.Link link : pdfFile.getPageLinks(page)) {
            RectF mapped = pdfFile.mapRectToDevice(page, pageX, pageY, (int) pageSize.getWidth(),
                    (int) pageSize.getHeight(), link.getBounds());
            mapped.sort();
            if (mapped.contains(mappedX, mappedY)) {

// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/model/LinkTapEvent.java
// public class LinkTapEvent {
//     private float originalX;
//     private float originalY;
//     private float documentX;
//     private float documentY;
//     private RectF mappedLinkRect;
//     private PdfDocument.Link link;
// 
//     public LinkTapEvent(float originalX, float originalY, float documentX, float documentY, RectF mappedLinkRect, PdfDocument.Link link) {
//         this.originalX = originalX;
//         this.originalY = originalY;
//         this.documentX = documentX;
//         this.documentY = documentY;
//         this.mappedLinkRect = mappedLinkRect;
//         this.link = link;
//     }
// 
//     public float getOriginalX() {
//         return originalX;
//     }
// 
//     public float getOriginalY() {
//         return originalY;
//     }
// 
//     public float getDocumentX() {
//         return documentX;
//     }
// 
//     public float getDocumentY() {
//         return documentY;
//     }
// 
//     public RectF getMappedLinkRect() {
//         return mappedLinkRect;
//     }
// 
//     public PdfDocument.Link getLink() {
//         return link;
//     }
// }
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/SnapEdge.java
// public enum SnapEdge {
//     START, CENTER, END, NONE
// }
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/Constants.java
// public static float MAXIMUM_ZOOM = 10;
// 
// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/util/Constants.java
// public static float MINIMUM_ZOOM = 1;


// Path: android-pdf-viewer/src/main/java/com/github/barteksc/pdfviewer/DragPinchManager.java
import android.graphics.PointF;
import android.graphics.RectF;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import com.github.barteksc.pdfviewer.model.LinkTapEvent;
import com.github.barteksc.pdfviewer.scroll.ScrollHandle;
import com.github.barteksc.pdfviewer.util.SnapEdge;
import com.shockwave.pdfium.PdfDocument;
import com.shockwave.pdfium.util.SizeF;
import static com.github.barteksc.pdfviewer.util.Constants.Pinch.MAXIMUM_ZOOM;
import static com.github.barteksc.pdfviewer.util.Constants.Pinch.MINIMUM_ZOOM;

                    ps.hide();
                }
            }
        }
        pdfView.performClick();
        return true;
    }

    private boolean checkLinkTapped(float x, float y) {
        PdfFile pdfFile = pdfView.pdfFile;
        if (pdfFile == null) {
            return false;
        }
        float mappedX = -pdfView.getCurrentXOffset() + x;
        float mappedY = -pdfView.getCurrentYOffset() + y;
        int page = pdfFile.getPageAtOffset(pdfView.isSwipeVertical() ? mappedY : mappedX, pdfView.getZoom());
        SizeF pageSize = pdfFile.getScaledPageSize(page, pdfView.getZoom());
        int pageX, pageY;
        if (pdfView.isSwipeVertical()) {
            pageX = (int) pdfFile.getSecondaryPageOffset(page, pdfView.getZoom());
            pageY = (int) pdfFile.getPageOffset(page, pdfView.getZoom());
        } else {
            pageY = (int) pdfFile.getSecondaryPageOffset(page, pdfView.getZoom());
            pageX = (int) pdfFile.getPageOffset(page, pdfView.getZoom());
        }
        for (PdfDocument.Link link : pdfFile.getPageLinks(page)) {
            RectF mapped = pdfFile.mapRectToDevice(page, pageX, pageY, (int) pageSize.getWidth(),
                    (int) pageSize.getHeight(), link.getBounds());
            mapped.sort();
            if (mapped.contains(mappedX, mappedY)) {

                pdfView.callbacks.callLinkHandler(new LinkTapEvent(x, y, mappedX, mappedY, mapped, link));
