Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about Android development and PDF

center and reset scale on page change

More
IP: 192.168.0.71 11 years 8 months ago #8313 by rockycamacho
Hello,

I would like detect when a page has changed via flinging (not when the user has selected a thumbnail) and then reset the scale if it was zoomed.

Here is the code I tried:
Code on my fragment implementing PDFReaderListener
@Override
public void OnPageChanged(int pageno) {
pdfReader.resetScaleAndCenter(pageno);
}


Code on my custom pdfreader
public void resetScaleAndCenter(int pageno) {
m_view.vSetScale(m_view.vGetMinScale(), 0, 0);
m_view.vCenterPage(pageno);
}


This had a problem because it also triggered when the user selected a page from the thumb view.
Also sometimes it would jump to a different page. Ex. I would fling from page 2 to 3 but it would jump to page 24 instead.


Is there a better way to detect a page change caused by flinging? How do I solve the page jumping?

Thanks,
Rocky
More
IP: 192.168.0.71 11 years 8 months ago #8325 by rockycamacho
Hello,

I have managed to detect the flinging to a page by modifying PDFView.java motionNormal method to store the current page on MotionEvent.ACTION_DOWN and then compare it to the page after MotionEvent.ACTION_UP.
I am able to perform scale and center but it still glitches sometimes by moving to a different page(often the last page). When I comment out the scale, it stops glitching. I think vSetScale is sometimes done after the center page.
Code:
//inside MotionEvent.ACTION_UP of motionNormal method.. final PDFPos pdfPos = vGetPos(m_w / 2, m_h / 2); if(holdPos != null && pdfPos != null && holdPos.pageno != pdfPos.pageno) { m_view.vSetScale(m_view.vGetMinScale(), 0, 0); m_view.vCenterPage(pdfPos.pageno); holdPos = null; }

My question is, how do I make it so that the code only does vSetScale AFTER vCenterPage?


Thanks,
Rocky
More
IP: 192.168.0.71 11 years 8 months ago #8327 by rockycamacho
Hello,

I found a workaround. I used a timer to schedule m_view.vCenterPage(pageno); so that it gets called after vSetScale. It still moves to a random page but it now goes back to the correct page.

Thanks,
Rocky
Time to create page: 0.392 seconds
Powered by Kunena Forum