I have work to some extent, but I have a series of text views and videos that are on the screen, and it seems that if I don’t scroll directly through any of them and go through a little of two of them, this will not happen So good. In general, I don’t think that he picks up napkins as well as what happens on the iPhone, and I was wondering if anyone could criticize my code and help me optimize it.
I initialize GesureDectector and GestureListener. Here is the GestureListener class:
public class GestureListener : Java.Lang.Object, GestureDetector.IOnGestureListener
{
private static int SWIPE_MAX_OFF_PATH = 250;
private static int SWIPE_MIN_DISTANCE = 50;
private static int SWIPE_THRESHOLD_VELOCITY = 200;
private View view;
private Activity act;
public GestureListener(View _view, Activity _act)
{
view = _view;
act = _act;
}
public bool OnDown( MotionEvent e )
{
return true;
}
public bool OnFling( MotionEvent e1, MotionEvent e2, float velocityX, float velocityY )
{
if ( Math.Abs( e1.GetY() - e2.GetY() ) > SWIPE_MAX_OFF_PATH ){
return false;
}
if ( e1.GetX() - e2.GetX() > SWIPE_MIN_DISTANCE && Math.Abs( velocityX ) > SWIPE_THRESHOLD_VELOCITY ){
HandleLeft();
}else if ( e2.GetX() - e1.GetX() > SWIPE_MIN_DISTANCE && Math.Abs( velocityX ) > SWIPE_THRESHOLD_VELOCITY ){
HandleRight();
}
return false;
}
public void OnLongPress( MotionEvent e )
{
}
public bool OnScroll( MotionEvent e1, MotionEvent e2, float distanceX, float distanceY )
{
return true;
}
public void OnShowPress( MotionEvent e )
{
}
public bool OnSingleTapUp( MotionEvent e )
{
return true;
}
private void HandleLeft(){
Male currActivity = (Male)act;
currActivity.GetStrings("Female");
}
private void HandleRight(){
Male currActivity = (Male)act;
currActivity.GetStrings("Results");
}
}
I use this for my OnTouch event:
public bool OnTouch(View v, MotionEvent e){
bool handled = false;
if(flingDetector != null){
handled = flingDetector.OnTouchEvent(e);
}
if(v.GetType() == typeof(Spinner)){
return !handled;
}else{
return handled;
}
}
Any help would be greatly appreciated.
source
share