Add scroll and fling gesture recognition
Not yet passed on down. Also fix a misleading comment. Change-Id: I1e6f79c84b1e13f48e4b2620e44b326fb6fc4ee9
This commit is contained in:
@@ -22,6 +22,7 @@ import android.graphics.Rect;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.GestureDetector;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.ScaleGestureDetector;
|
import android.view.ScaleGestureDetector;
|
||||||
@@ -163,7 +164,8 @@ public class Desktop
|
|||||||
Bitmap mBitmap;
|
Bitmap mBitmap;
|
||||||
boolean renderedOnce;
|
boolean renderedOnce;
|
||||||
boolean scalingInProgress;
|
boolean scalingInProgress;
|
||||||
ScaleGestureDetector gestureDetector;
|
GestureDetector gestureDetector;
|
||||||
|
ScaleGestureDetector scaleDetector;
|
||||||
float scale = 1;
|
float scale = 1;
|
||||||
|
|
||||||
public BitmapView()
|
public BitmapView()
|
||||||
@@ -171,6 +173,22 @@ public class Desktop
|
|||||||
super(Desktop.this);
|
super(Desktop.this);
|
||||||
setFocusableInTouchMode(true);
|
setFocusableInTouchMode(true);
|
||||||
|
|
||||||
|
gestureDetector =
|
||||||
|
new GestureDetector(Desktop.this,
|
||||||
|
new GestureDetector.SimpleOnGestureListener() {
|
||||||
|
@Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
|
||||||
|
{
|
||||||
|
Log.i(TAG, "onFling: events:" + e1 + ", " + e2 + ", velocity: (" + velocityX + ", " + velocityY + ")");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
|
||||||
|
{
|
||||||
|
Log.i(TAG, "onScroll: events:" + e1 + ", " + e2 + ", velocity: (" + velocityX + ", " + velocityY + ")");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Is this sane? It is rather slow to ask LO to zoom
|
// Is this sane? It is rather slow to ask LO to zoom
|
||||||
// continuously while the scaling gesture is in progress.
|
// continuously while the scaling gesture is in progress.
|
||||||
|
|
||||||
@@ -178,7 +196,7 @@ public class Desktop
|
|||||||
// progress to just scale the bitmap view (UI elements
|
// progress to just scale the bitmap view (UI elements
|
||||||
// too, which of course was a bit silly).
|
// too, which of course was a bit silly).
|
||||||
|
|
||||||
gestureDetector =
|
scaleDetector =
|
||||||
new ScaleGestureDetector(Desktop.this,
|
new ScaleGestureDetector(Desktop.this,
|
||||||
new ScaleGestureDetector.SimpleOnScaleGestureListener() {
|
new ScaleGestureDetector.SimpleOnScaleGestureListener() {
|
||||||
@Override public boolean onScaleBegin(ScaleGestureDetector detector)
|
@Override public boolean onScaleBegin(ScaleGestureDetector detector)
|
||||||
@@ -255,12 +273,12 @@ public class Desktop
|
|||||||
|
|
||||||
@Override public boolean onTouchEvent(MotionEvent event)
|
@Override public boolean onTouchEvent(MotionEvent event)
|
||||||
{
|
{
|
||||||
Log.i(TAG, "onTouchEvent, scalingInProgress=" + scalingInProgress);
|
if (gestureDetector.onTouchEvent(event))
|
||||||
|
return true;
|
||||||
|
|
||||||
// For now, when during scaling we just scale the bitmap
|
// If a scaling gesture is in progress no other touch
|
||||||
// view, if a scaling gesture is in progress no other
|
// processing should be done.
|
||||||
// touch processing should be done.
|
if (scaleDetector.onTouchEvent(event) && scalingInProgress)
|
||||||
if (gestureDetector.onTouchEvent(event) && scalingInProgress)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!renderedOnce)
|
if (!renderedOnce)
|
||||||
|
Reference in New Issue
Block a user