onFling gesture in WebView

by me tun » Tue, 12 May 2009 08:57:25 GMT


Sponsored Links
 Hello all,

Is there a way to detect the onFling gesture in a WebView?  It doesn't
seem to get recognised, for example:

I'll add all the code because it's a pretty good example of how to
listen to gesture...

        gestureDetector = new GestureDetector(new mGestureDetector());
        gestureListener = new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                if (gestureDetector.onTouchEvent(event)) {
                    return true;
                }
                return false;
            }
        };


...

    class mGestureDetector extends SimpleOnGestureListener {
        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float
velocityX, float velocityY) {
            try {
                if (Math.abs(e1.getY() - e2.getY()) >
SWIPE_MAX_OFF_PATH)
                    return false;
                // Right to left fling
                if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE &&
Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {

                        Log.d(TAG, "Right to left fling");

                }  else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE
&& Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {

                        Log.d(TAG, "Left to right fling");

                }
            } catch (Exception e) {
                // Nothing
            }
            return false;
        }
    }

...

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (gestureDetector.onTouchEvent(event))
                return true;
            else
                return false;
    }

This works for a FrameLayout, TextView, etc  I just can't seem to get
it to work in a WebView, is there some flag I need to enable to allow
the gestures to get through?
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Honeycomb surprising result for WallpaperManager.getDesiredMinimumHeight()

Hi,

In the new Android 3.0 Honeycomb Preview emulator
WallpaperManager.getDesiredMinimumHeight()  returns 1408.

getDesiredMinimumHeight=1408
getDesiredMinimumWidth=1920

The 1408 result is a bit surprising, is this planned ? is there any
special reason the desired Height is 1408 and not just 1400 ?

Thanks,
Shai Levy

-- 

2. Absolute path for an asset file

Hello,

I have been trying to get the absolute path for an asset file but i
havent found an answer.

the file which is directly within my asset folder is mydemo.txt
 and i call the function given below to test the validity of the path
(tried the below options)
                testURI("//android_asset/mydemo.txt");
                testURI("//assets/mydemo.txt");

        public void testURI(String filepath) {
                try {
                        Log.e(TAG, "Testing " + filepath);
                        File f = new File(filepath);
                        if (f.exists() == true) {
                                Log.e(TAG, "Valid :" + filepath);
                        } else {
                                Log.e(TAG, "InValid :" + filepath);
                        }
                } catch (Exception e) {
                        Log.e(TAG, "File not found" + filepath);
                        e.printStackTrace();
                }
        }

Can someone let me know whats the absolute path i can use to get an
asset file. i don't need the file descriptors but i want the file path
to construct an URI.

-- 

3. app doesn't install anymore!

4. How to Read Device Properties

5. Motorola Camera issue

6. gldfish kernel and goldfish kernel

7. What's new in honeycomb?