Support

Knowledge Base - Avoid page change during navigation while zoomed (Android)

This article illustrates how to prevent the page navigation (horizontal scroll) while the page is zoomed with the rendering mode set as single/double page.
Here you can find a class that extends
PDFLayoutDual class:

 

/**
* Block page navigation while zoomed.
*
* @author Nermeen created on 12/05/2017.
*/
public class ExtendedDualLayout extends PDFLayoutDual {

private boolean mZooming;
private Context mContext;

public ExtendedDualLayout(Context context) {
super(context);
mContext = context;
}

@Override
public void vZoomStart() {
mZooming = true;
super.vZoomStart();
}

@Override
public boolean vZoomEnd() {
boolean result = super.vZoomEnd();
if(result)
mZooming = false;
return result;
}

@Override
protected void do_scroll(int x, int y, int dx, int dy) {
if(vGetScale() > vGetMinScale()) {
int index = m_pageno;
if ((Global.def_view == 6 || Global.def_view == 4) && m_w > m_h)
index = (m_pageno + 1) / 2;
if (index > -1 && index < m_cells.length) {
int minX = m_cells[index].left;
int endX = m_cells[index].right - m_w;
boolean showToast = false;
if (x + dx > endX) { dx = endX - x; showToast = true;}
if (x + dx < minX) { dx = minX - x; showToast = true;}
if(showToast)
Toast.makeText(mContext, "You cannot change page while page is zoomed, Zoom out first!", Toast.LENGTH_SHORT).show();
}
}
super.do_scroll(x, y, dx, dy);
}

@Override
public void vSetX(int x) {
if(vGetScale() > vGetMinScale() && !mZooming) {
int index = m_pageno;
if ((Global.def_view == 6 || Global.def_view == 4) && m_w > m_h)
index = (m_pageno + 1) / 2;
if (x + vGetWidth() > m_cells[index].right)
x = m_cells[index].right - vGetWidth();
if (x <= m_cells[index].left)
x = m_cells[index].left;
}
super.vSetX(x);
}
}
Applies To

RadaeePDF SDK for Android

Related Articles

Limit horizontal page change when a page is zoomed

How to avoid page change during navigation if page is zoomed? (Deprecated)

Details

Created : 2017-05-12 09:39:08, Last Modified : 2017-05-12 09:41:02

Order history

Login to handle your order history.