Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling a click on the viewpager object. #12

Closed
ghost opened this issue Jun 22, 2016 · 6 comments
Closed

Handling a click on the viewpager object. #12

ghost opened this issue Jun 22, 2016 · 6 comments

Comments

@ghost
Copy link

ghost commented Jun 22, 2016

First of all, really cool widget. Easy to implement and not too complicated.
What I would like to know is can you set a click listener (A single regular click/tap) to the pdfviewpager. Current page position/number doesn't matter.

I attempted attaching a regular onClickListener and an onTouchListener (with MotionEvents). But both didn't work.

Some help would be great!
Thanks a lot!

@voghDev
Copy link
Owner

voghDev commented Jun 26, 2016

Hi,

I haven't tried to implement this feature. Maybe I can think about a mechanism such as a Listener that can be fired on each page's tap, but this pattern (single tap on a PDF) sounds a bit strange.

Can you describe a little bit what you're trying to do? Maybe you can add a button somewhere else for this feature you want, and it's even clearer for the user. Clicking on the PdfViewPager doesn't sound very intuitive. Let me know your opinion.

@ghost
Copy link
Author

ghost commented Jul 1, 2016

My app opens the PDF in full screen view by default. I want the Navbar and the bottom control panel to toggle whenever the user just taps on the document.

Right now I use a button between the lower edge of the screen and the lower edge of the ViewPager to accomplish this. I just wanted to know if it's possible to do it with a tap to the document, 'cause this looks awkward.

@voghDev
Copy link
Owner

voghDev commented Jul 4, 2016

I see,

let me think a clean solution and i'll add some listener that you can override for a single tap at least.

@voghDev
Copy link
Owner

voghDev commented Jul 17, 2016

Hi,

I'm working on this issue. Feature will be included in version 1.0.1 of the lib. You will have PDFPagerAdapter.Builder class where you can define an OnClickListener for every page of the Pdf. I'll let you know when it's released.

You can see sample code here

pdfViewPager.setAdapter(new PDFPagerAdapter.Builder(this)
            .setPdfPath("moby.pdf")
            .setScale(getPdfScale())
            .setOnPageClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Toast.makeText(PDFWithScaleActivity.this, R.string.page_was_clicked, Toast.LENGTH_LONG).show();
                }
            })
            .create()
    );

@ghost
Copy link
Author

ghost commented Jul 22, 2016

Nice! Thank you very much!

@voghDev
Copy link
Owner

voghDev commented Jul 29, 2016

Hi,

version 1.0.1 released. You can now instantiate a PDFPagerAdapter with the code shown on the previous comment and capture the OnPageClick event.

Have a look at the samples for example code

and you're welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant