android - How to implement double tap zooming in Mupdf? -


i'm researching mupdf library on android. compiled , ran sample successfully. it's great library. have problem zooming page when firing "double tap" event.

first, implemented view 'listen' double tap event :

public class mupdfreaderview extends readerview implements gesturedetector.ondoubletaplistener 

then, overrode ondoubletap() method :

@override public boolean ondoubletap(motionevent e) {     // todo auto-generated method stub     mupdfview pageview = (mupdfview) getdisplayedview();     pageview.setscale(1.5f);     log.e("double tap", "" + e.getdowntime());     return false; } 

when double tap on page, can see "double tap" log in logcat, page not zoomed. wrong here?

i'm not sure why attempt didn't worked, here's way it:

instead of implementing gesturedetector.ondoubletaplistener on view, implement directly on readerview extended

public class readerview extends adapterview<adapter> implements      gesturedetector.ongesturelistener,     gesturedetector.ondoubletaplistener,     scalegesturedetector.onscalegesturelistener,     runnable { ... } 

and override ondoubletap method this

@override public boolean ondoubletap(motionevent e) {      float previousscale = mscale;     mscale += (mscale == 1f) ? 2f : -2f;     float factor = mscale/previousscale;      view v = mchildviews.get(mcurrent);     if (v != null) {         // work out focus point relative view top left         int viewfocusx = (int)e.getx() - (v.getleft() + mxscroll);         int viewfocusy = (int)e.gety() - (v.gettop() + myscroll);         // scroll maintain focus point         mxscroll += viewfocusx - viewfocusx * factor;         myscroll += viewfocusy - viewfocusy * factor;         requestlayout();     }      return true; } 

also have override these 2 other methods

@override public boolean ondoubletapevent(motionevent e) {     return false; }  @override public boolean onsingletapconfirmed(motionevent e) {     return false; } 

got code librelio android example

https://github.com/libreliodev/android


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -