Fixing bugs.

This commit is contained in:
GaidamakUA 2016-05-05 17:56:12 +03:00
parent cf697098c5
commit d5394a8425
3 changed files with 35 additions and 16 deletions

View file

@ -386,7 +386,14 @@ public class RotatedTileBox {
return new QuadPointDouble((tileRB.x * MapUtils.getPowZoom(zoom - this.zoom)),
(tileRB.y * MapUtils.getPowZoom(zoom - this.zoom)));
}
public float getRatioX() {
return pixWidth / cx;
}
public float getRatioY() {
return pixHeight / cy;
}
private void checkTileRectangleCalculated() {
if(tileBounds == null){

View file

@ -10,6 +10,7 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Vibrator;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresPermission;
import android.support.v4.content.ContextCompat;
import android.view.GestureDetector;
@ -59,6 +60,8 @@ public class ContextMenuLayer extends OsmandMapLayer {
private final MoveMarkerBottomSheetHelper mMoveMarkerBottomSheetHelper;
private boolean mInChangeMarkerPositionMode;
@Nullable
private LatLon mMarkerLocation;
public ContextMenuLayer(MapActivity activity) {
this.activity = activity;
@ -107,6 +110,18 @@ public class ContextMenuLayer extends OsmandMapLayer {
canvas.drawBitmap(pressedBitmap, x - pressedBitmap.getWidth() / 2, y - pressedBitmap.getHeight() / 2, paint);
}
if (mMarkerLocation != null
&& mMarkerLocation.equals(menu.getLatLon())
&& mMarkerLocation.equals(box.getCenterLatLon())) {
mInChangeMarkerPositionMode = true;
double latitude = mMarkerLocation.getLatitude();
double longitude = mMarkerLocation.getLongitude();
mMoveMarkerBottomSheetHelper.show(latitude, longitude);
activity.getContextMenu().hide();
mMarkerLocation = null;
box.getPixHeight();
}
if (mInChangeMarkerPositionMode) {
int x = box.getCenterPixelX();
int y = box.getCenterPixelY();
@ -154,10 +169,13 @@ public class ContextMenuLayer extends OsmandMapLayer {
Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(VIBRATE_SHORT);
mInChangeMarkerPositionMode = true;
activity.getContextMenu().hide();
LatLon latLon = tileBox.getCenterLatLon();
mMoveMarkerBottomSheetHelper.show(latLon.getLatitude(), latLon.getLongitude());
AnimateDraggingMapThread thread = activity.getMapView().getAnimatedDraggingThread();
mMarkerLocation = menu.getLatLon();
double lat = mMarkerLocation.getLatitude();
double lon = mMarkerLocation.getLongitude();
int zoom = activity.getMapView().getZoom();
thread.startMoving(lat, lon, zoom, true);
return true;
}
@ -170,8 +188,8 @@ public class ContextMenuLayer extends OsmandMapLayer {
if (!mInChangeMarkerPositionMode) {
throw new IllegalStateException("Not in change marker position mode");
}
mInChangeMarkerPositionMode = false;
RotatedTileBox tileBox = activity.getMapView().getCurrentRotatedTileBox();
mInChangeMarkerPositionMode = false;
int newMarkerX = tileBox.getCenterPixelX();
int newMarkerY = tileBox.getCenterPixelY();
PointF newMarkerPosition = new PointF(newMarkerX, newMarkerY);

View file

@ -389,14 +389,14 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
return currentViewport.isZoomAnimated();
}
/**
* Adds listener to control when map is dragging
*/
public void setMapLocationListener(IMapLocationListener l) {
locationListener = l;
}
/**
* Adds listener to control when map is dragging
*/
public IMapLocationListener setMapLocationListener() {
public IMapLocationListener getMapLocationListener() {
return locationListener;
}
@ -450,12 +450,6 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
final float x2 = calc.getPixXFromTile(rb.x, rb.y, cz);
final float y1 = calc.getPixYFromTile(lt.x, lt.y, cz);
final float y2 = calc.getPixYFromTile(rb.x, rb.y, cz);
// LatLon lt = bufferImgLoc.getLeftTopLatLon();
// LatLon rb = bufferImgLoc.getRightBottomLatLon();
// final float x1 = calc.getPixXFromLatLon(lt.getLatitude(), lt.getLongitude());
// final float x2 = calc.getPixXFromLatLon(rb.getLatitude(), rb.getLongitude());
// final float y1 = calc.getPixYFromLatLon(lt.getLatitude(), lt.getLongitude());
// final float y2 = calc.getPixYFromLatLon(rb.getLatitude(), rb.getLongitude());
if (!bufferBitmap.isRecycled()) {
RectF rct = new RectF(x1, y1, x2, y2);
canvas.drawBitmap(bufferBitmap, null, rct, paintImg);