DImuthuUpe / AndroidPdfViewer

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

LongClick doesn't work #1160

Open Bernhardino opened 1 year ago

Bernhardino commented 1 year ago

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

Bernhardino commented 1 year ago

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

Bernhardino commented 1 year 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 1 year 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...