summaryrefslogtreecommitdiff
path: root/src/com/android/dreams/phototable/PhotoTouchListener.java
diff options
context:
space:
mode:
authorChris Wren <cwren@android.com>2013-04-04 09:17:26 -0400
committerChris Wren <cwren@android.com>2013-04-09 01:54:16 -0400
commit88d80f4471c900628e2cb6eef23029b99af48e09 (patch)
tree6829842f0dff21db530936037cd242853f43b416 /src/com/android/dreams/phototable/PhotoTouchListener.java
parent1dc94b55d59f5c4dbf86788d0c32b7ac4449909a (diff)
downloadPhotoTable-88d80f4471c900628e2cb6eef23029b99af48e09.tar.gz
story mode for PhotoTable.
also some cleanup and refactoring also fix stuck alphas Bug: 8399588 Change-Id: Id236b29701ede3696c8f1f0ccc6522eb8256ff25
Diffstat (limited to 'src/com/android/dreams/phototable/PhotoTouchListener.java')
-rw-r--r--src/com/android/dreams/phototable/PhotoTouchListener.java33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/com/android/dreams/phototable/PhotoTouchListener.java b/src/com/android/dreams/phototable/PhotoTouchListener.java
index 190dc3d..8bcec6b 100644
--- a/src/com/android/dreams/phototable/PhotoTouchListener.java
+++ b/src/com/android/dreams/phototable/PhotoTouchListener.java
@@ -34,7 +34,6 @@ public class PhotoTouchListener implements View.OnTouchListener {
private final int mTapTimeout;
private final PhotoTable mTable;
private final float mBeta;
- private final float mTableRatio;
private final boolean mEnableFling;
private final boolean mManualImageRotation;
private long mLastEventTime;
@@ -52,16 +51,14 @@ public class PhotoTouchListener implements View.OnTouchListener {
private int mA = INVALID_POINTER;
private int mB = INVALID_POINTER;
private float[] pts = new float[MAX_POINTER_COUNT];
- private float[] tmp = new float[MAX_POINTER_COUNT];
public PhotoTouchListener(Context context, PhotoTable table) {
mTable = table;
final ViewConfiguration configuration = ViewConfiguration.get(context);
mTouchSlop = configuration.getScaledTouchSlop();
- mTapTimeout = configuration.getTapTimeout();
+ mTapTimeout = ViewConfiguration.getTapTimeout();
final Resources resources = context.getResources();
mBeta = resources.getInteger(R.integer.table_damping) / 1000000f;
- mTableRatio = resources.getInteger(R.integer.table_ratio) / 1000000f;
mEnableFling = resources.getBoolean(R.bool.enable_fling);
mManualImageRotation = resources.getBoolean(R.bool.enable_manual_image_rotation);
}
@@ -184,16 +181,16 @@ public class PhotoTouchListener implements View.OnTouchListener {
mLastTouchY = y;
}
- if (mTable.getSelected() != target) {
- target.animate().cancel();
-
- target.setX((int) (mInitialTargetX + x - mInitialTouchX));
- target.setY((int) (mInitialTargetY + y - mInitialTouchY));
+ if (!mTable.hasSelection()) {
+ float rotation = target.getRotation();
if (mManualImageRotation && mB != INVALID_POINTER) {
float a = getAngle(target, ev);
- target.setRotation(
- (int) (mInitialTargetA + a - mInitialTouchA));
+ rotation = mInitialTargetA + a - mInitialTouchA;
}
+ mTable.move(target,
+ mInitialTargetX + x - mInitialTouchX,
+ mInitialTargetY + y - mInitialTouchY,
+ rotation);
}
}
}
@@ -210,13 +207,19 @@ public class PhotoTouchListener implements View.OnTouchListener {
}
double distance = Math.hypot(x0 - mInitialTouchX,
y0 - mInitialTouchY);
- if (mTable.getSelected() == target) {
- mTable.dropOnTable(target);
- mTable.clearSelection();
+ if (mTable.hasSelection()) {
+ if (distance < mTouchSlop) {
+ mTable.clearSelection();
+ } else {
+ if ((x0 - mInitialTouchX) > 0f) {
+ mTable.selectPrevious();
+ } else {
+ mTable.selectNext();
+ }
+ }
} else if ((ev.getEventTime() - mInitialTouchTime) < mTapTimeout &&
distance < mTouchSlop) {
// tap
- target.animate().cancel();
mTable.setSelection(target);
} else {
onFling(target, mDX, mDY);