Revert "calculator window"

This reverts commit ff31a17921.
This commit is contained in:
Sergey Solovyev 2012-11-26 23:42:27 +04:00
parent ff31a17921
commit 668e987ae0

View File

@ -338,8 +338,9 @@ public class CalculatorOnscreenView {
********************************************************************** **********************************************************************
*/ */
private static final float DIST_MIN = 0.5f; private static final float DIST_EPS = 0f;
private static final float DIST_MAX = 100f; private static final float DIST_MAX = 100000f;
private static final long TIME_EPS = 0L;
/* /*
********************************************************************** **********************************************************************
@ -356,6 +357,8 @@ public class CalculatorOnscreenView {
private float y0; private float y0;
private long time = 0;
@NotNull @NotNull
private final View view; private final View view;
@ -389,43 +392,57 @@ public class CalculatorOnscreenView {
return true; return true;
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
final long currentTime = System.currentTimeMillis();
if ( currentTime - time >= TIME_EPS ) {
time = currentTime;
for (int i = 0; i < event.getHistorySize(); i++) { for (int i = 0; i < event.getHistorySize(); i++) {
final float xi = event.getHistoricalX(i); final float xi = event.getHistoricalX(i);
final float yi = event.getHistoricalY(i); final float yi = event.getHistoricalY(i);
processMove(xi, yi);
processMove(xi, yi, event.getHistoricalEventTime(i)); }
processMove(x1, y1);
} }
processMove(x1, y1, event.getEventTime());
return true; return true;
} }
return false; return false;
} }
private void processMove(float x1, float y1, long eventTime) { private void processMove(float x1, float y1) {
final float Δx = x1 - x0; final float Δx = x1 - x0;
final float Δy = y1 - y0; final float Δy = y1 - y0;
final WindowManager.LayoutParams params = (WindowManager.LayoutParams) view.getLayoutParams(); final WindowManager.LayoutParams params = (WindowManager.LayoutParams) view.getLayoutParams();
Log.d(TAG, "0:" + toString(x0, y0) + ", 1: " + toString(x1, y1) + ", Δ: " + toString(Δx, Δy) + ", params: " + toString(params.x, params.y) + ", time: " + eventTime); Log.d(TAG, "0:" + toString(x0, y0) + ", 1: " + toString(x1, y1) + ", Δ: " + toString(Δx, Δy) + ", params: " + toString(params.x, params.y));
boolean xInBounds = isΔInBounds(Δx); boolean xInBounds = isDistanceInBounds(Δx);
boolean yInBounds = isΔInBounds(Δy); boolean yInBounds = isDistanceInBounds(Δy);
if (xInBounds && yInBounds) { if (xInBounds || yInBounds) {
if (xInBounds) {
params.x = (int) (params.x + Δx); params.x = (int) (params.x + Δx);
}
if (yInBounds) {
params.y = (int) (params.y + Δy); params.y = (int) (params.y + Δy);
}
wm.updateViewLayout(view, params); wm.updateViewLayout(view, params);
if (xInBounds) {
x0 = x1; x0 = x1;
}
if (yInBounds) {
y0 = y1; y0 = y1;
} }
} }
}
private boolean isΔInBounds(float δx) { private boolean isDistanceInBounds(float δx) {
δx = Math.abs(δx); δx = Math.abs(δx);
return δx >= DIST_MIN && δx < DIST_MAX; return δx >= DIST_EPS && δx < DIST_MAX;
} }
@NotNull @NotNull