PhotoViewAttacher
's boolean onFling(MotionEvent, MotionEvent, float, float)
prevents my OnSingleFlingListener
's onFling
method from being called unless the current scale is the minimun.
I implemented OnSingleFlingListener
from com.github.chrisbanes.photoview
. However, since the onFling
method is only package visible, PhotoViewAttacher
's onFling
method gets called first. PhotoViewAttacher.onFling
prevents my onFling
method from being called when scale > DEFAULT_MIN_SCALE
. I need mine called unless scale > getMediumScale()
. (scale == getMediumScale()
when my image's width matches the window's width.) How can I get around this? Do I need to make my own copy of the entire PhotoView
package and modify OnSingleFlingListener.onFling
to be public?
My code:
public class BasicViewActivity extends AppCompatActivity implements DownloadCallback, OnSingleFlingListener {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
. . .
return true;
}
OnSingleFlingListener:
package com.github.chrisbanes.photoview;
public interface OnSingleFlingListener {
boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY);
}
PhotoViewAttacher:
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
if (mSingleFlingListener != null) {
if (getScale() > DEFAULT_MIN_SCALE) {
return false;
}
. . .
return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
}
return false;
}
I want my onFling
called when getScale() <= getMediumScale()
. Instead, my onFling
method is called only when getScale() == DEFAULT_MIN_SCALE
.