DImuthuUpe / AndroidPdfViewer

Android view for displaying PDFs rendered with PdfiumAndroid
Apache License 2.0
8.05k stars 1.85k forks source link

LongClick doesn't work #1160

Open Bernhardino opened 10 months ago

Bernhardino commented 10 months ago

Although I set pdfView.setLongClickable(true), the OnLongClickListener does not respond to a long Click. Click and OnClickListener work fine.

Bernhardino commented 10 months ago

I also set in the .xml
<com.github.barteksc.pdfviewer.PDFView android:longClickable="true" ...

Bernhardino commented 10 months ago

I imported the library into my project and observed the following: In DragPinchManager.java, the method onLongPress (line 198) is executed exactly on a LongClick. But somehow the event is passed incorrectly to pdfView.onLongClickListener. I passed the event according to https://guides.codepath.com/android/Creating-Custom-Listeners and voila, everything works fine now... _:)

Bernhardino commented 9 months ago

My last post: I must confess, I was wrong. LongClick (which is called LongPress here) works fine. I used the wrong syntax: pdfView.setOnLongPressListener((OnLongPressListener) e -> {..., which worked with a few tweaks (see last post). Only by chance I saw that the correct syntax is pdfView.fromFile(new File(file)).onLongPress(onLongPressListener).load();. Well, the instructions on the site https://github.com/barteksc/AndroidPdfViewer are a bit poor...