Delete zero writing in the multiTouchEndTime field

This commit is contained in:
Alexander Sytnyk 2017-06-29 12:03:50 +03:00
parent 84a8086a36
commit 143297bee9
2 changed files with 13 additions and 10 deletions

View file

@ -167,6 +167,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
private float secondTouchPointY; private float secondTouchPointY;
private boolean multiTouch; private boolean multiTouch;
private long multiTouchEndTime; private long multiTouchEndTime;
private boolean wasZoomInMultiTouch;
public OsmandMapTileView(MapActivity activity, int w, int h) { public OsmandMapTileView(MapActivity activity, int w, int h) {
this.activity = activity; this.activity = activity;
@ -336,8 +337,12 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
return multiTouchEndTime; return multiTouchEndTime;
} }
public void setMultiTouchEndTime(long multiTouchEndTime) { public boolean isWasZoomInMultiTouch() {
this.multiTouchEndTime = multiTouchEndTime; return wasZoomInMultiTouch;
}
public void setWasZoomInMultiTouch(boolean wasZoomInMultiTouch) {
this.wasZoomInMultiTouch = wasZoomInMultiTouch;
} }
public void setIntZoom(int zoom) { public void setIntZoom(int zoom) {
@ -1048,6 +1053,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
secondTouchPointX = x2; secondTouchPointX = x2;
secondTouchPointY = y2; secondTouchPointY = y2;
multiTouch = true; multiTouch = true;
wasZoomInMultiTouch = false;
} }
} }
@ -1064,9 +1070,10 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
public void onActionPointerUp() { public void onActionPointerUp() {
multiTouch = false; multiTouch = false;
if (isZooming()) { if (isZooming()) {
multiTouchEndTime = 0; wasZoomInMultiTouch = true;
} else { } else {
multiTouchEndTime = System.currentTimeMillis(); multiTouchEndTime = System.currentTimeMillis();
wasZoomInMultiTouch = false;
} }
} }

View file

@ -44,7 +44,6 @@ public class RulerControlLayer extends OsmandMapLayer {
private QuadPoint cacheCenter; private QuadPoint cacheCenter;
private int cacheIntZoom; private int cacheIntZoom;
private double cacheFractionalZoom;
private double cacheTileX; private double cacheTileX;
private double cacheTileY; private double cacheTileY;
private long cacheMultiTouchEndTime; private long cacheMultiTouchEndTime;
@ -118,16 +117,13 @@ public class RulerControlLayer extends OsmandMapLayer {
final QuadPoint center = tb.getCenterPixelPoint(); final QuadPoint center = tb.getCenterPixelPoint();
final RulerMode mode = app.getSettings().RULER_MODE.get(); final RulerMode mode = app.getSettings().RULER_MODE.get();
if (cacheIntZoom != view.getZoom() || cacheFractionalZoom != view.getZoomFractionalPart()) { if (view.isMultiTouch() && view.isZooming()) {
cacheIntZoom = view.getZoom(); view.setWasZoomInMultiTouch(true);
cacheFractionalZoom = view.getZoomFractionalPart();
view.setMultiTouchEndTime(0);
cacheMultiTouchEndTime = 0;
} else if (cacheMultiTouchEndTime != view.getMultiTouchEndTime()) { } else if (cacheMultiTouchEndTime != view.getMultiTouchEndTime()) {
cacheMultiTouchEndTime = view.getMultiTouchEndTime(); cacheMultiTouchEndTime = view.getMultiTouchEndTime();
refreshMapDelayed(); refreshMapDelayed();
} }
showTwoFingersDistance = !view.isZooming() && view.isMultiTouch() || System.currentTimeMillis() - cacheMultiTouchEndTime < DELAY; showTwoFingersDistance = !view.isWasZoomInMultiTouch() && !view.isZooming() && (view.isMultiTouch() || System.currentTimeMillis() - cacheMultiTouchEndTime < DELAY);
if (showTwoFingersDistance) { if (showTwoFingersDistance) {
float x1 = view.getFirstTouchPointX(); float x1 = view.getFirstTouchPointX();
float y1 = view.getFirstTouchPointY(); float y1 = view.getFirstTouchPointY();