Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-03-11 21:07:55 +01:00
commit 25512240e0

View file

@ -287,33 +287,6 @@ public class TrackSegmentFragment extends OsmAndListFragment {
updateColorView(colorView); updateColorView(colorView);
} }
}); });
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), vis.isChecked(), false);
if (vis.isChecked() && sf.getGpxFile() != null) {
final List<GpxDisplayGroup> groups = getOriginalGroups();
if (groups.size() > 0 && groups.get(0).getModifiableList().size() > 0) {
GpxDisplayItem item = groups.get(0).getModifiableList().get(0);
app.getSettings().setMapLocationToShow(item.locationStart.lat, item.locationStart.lon,
15,
new PointDescription(PointDescription.POINT_TYPE_GPX_ITEM, item.group.getGpxName()),
false,
item);
} else {
WptPt wpt = sf.getGpxFile().findPointToShow();
if (wpt != null) {
app.getSettings().setMapLocationToShow(wpt.getLatitude(), wpt.getLongitude(),
15,
new PointDescription(PointDescription.POINT_TYPE_WPT, wpt.name),
false,
wpt);
}
}
MapActivity.launchMapActivityMoveToTop(getMyActivity());
}
}
});
updateColorView(colorView); updateColorView(colorView);
colorView.setOnClickListener(new View.OnClickListener() { colorView.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -397,60 +370,62 @@ public class TrackSegmentFragment extends OsmAndListFragment {
divider.setVisibility(View.GONE); divider.setVisibility(View.GONE);
} }
QuadRect rect = getRect(); if (rotatedTileBox == null || mapBitmap == null) {
if (rect.left != 0 && rect.top != 0) { QuadRect rect = getRect();
double clat = rect.bottom / 2 + rect.top / 2; if (rect.left != 0 && rect.top != 0) {
double clon = rect.left / 2 + rect.right / 2; double clat = rect.bottom / 2 + rect.top / 2;
WindowManager mgr = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE); double clon = rect.left / 2 + rect.right / 2;
DisplayMetrics dm = new DisplayMetrics(); WindowManager mgr = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
mgr.getDefaultDisplay().getMetrics(dm); DisplayMetrics dm = new DisplayMetrics();
RotatedTileBoxBuilder boxBuilder = new RotatedTileBoxBuilder() mgr.getDefaultDisplay().getMetrics(dm);
.setLocation(clat, clon) RotatedTileBoxBuilder boxBuilder = new RotatedTileBoxBuilder()
.setZoom(15) .setLocation(clat, clon)
.density(dm.density) .setZoom(15)
.setPixelDimensions(containerWidthPx, AndroidUtils.dpToPx(app, 152f), 0.5f, 0.5f); .density(dm.density)
.setPixelDimensions(containerWidthPx, AndroidUtils.dpToPx(app, 152f), 0.5f, 0.5f);
rotatedTileBox = boxBuilder.build(); rotatedTileBox = boxBuilder.build();
while (rotatedTileBox.getZoom() < 17 && rotatedTileBox.containsLatLon(rect.top, rect.left) && rotatedTileBox.containsLatLon(rect.bottom, rect.right)) { while (rotatedTileBox.getZoom() < 17 && rotatedTileBox.containsLatLon(rect.top, rect.left) && rotatedTileBox.containsLatLon(rect.bottom, rect.right)) {
rotatedTileBox.setZoom(rotatedTileBox.getZoom() + 1); rotatedTileBox.setZoom(rotatedTileBox.getZoom() + 1);
} }
while (rotatedTileBox.getZoom() >= 7 && (!rotatedTileBox.containsLatLon(rect.top, rect.left) || !rotatedTileBox.containsLatLon(rect.bottom, rect.right))) { while (rotatedTileBox.getZoom() >= 7 && (!rotatedTileBox.containsLatLon(rect.top, rect.left) || !rotatedTileBox.containsLatLon(rect.bottom, rect.right))) {
rotatedTileBox.setZoom(rotatedTileBox.getZoom() - 1); rotatedTileBox.setZoom(rotatedTileBox.getZoom() - 1);
} }
DrawSettings drawSettings = new DrawSettings(!app.getSettings().isLightContent(), true); DrawSettings drawSettings = new DrawSettings(!app.getSettings().isLightContent(), true);
ResourceManager resourceManager = app.getResourceManager(); ResourceManager resourceManager = app.getResourceManager();
MapRenderRepositories renderer = resourceManager.getRenderer(); MapRenderRepositories renderer = resourceManager.getRenderer();
if (resourceManager.updateRenderedMapNeeded(rotatedTileBox, drawSettings)) { if (resourceManager.updateRenderedMapNeeded(rotatedTileBox, drawSettings)) {
resourceManager.updateRendererMap(rotatedTileBox); resourceManager.updateRendererMap(rotatedTileBox);
while (renderer.getBitmapLocation() != rotatedTileBox) { while (renderer.getBitmapLocation() != rotatedTileBox) {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// ignore
}
}
}
mapBitmap = renderer.getBitmap();
while (mapBitmap == null) {
try { try {
Thread.sleep(50); Thread.sleep(50);
} catch (InterruptedException e) { } catch (InterruptedException e) {
// ignore // ignore
} }
mapBitmap = renderer.getBitmap();
} }
}
mapBitmap = renderer.getBitmap();
while (mapBitmap == null) {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
// ignore
}
mapBitmap = renderer.getBitmap();
}
SelectedGpxFile sf = new SelectedGpxFile(); SelectedGpxFile sf = new SelectedGpxFile();
sf.setGpxFile(getGpx()); sf.setGpxFile(getGpx());
Canvas canvas = new Canvas(mapBitmap); Canvas canvas = new Canvas(mapBitmap);
drawTrack(canvas, rotatedTileBox, sf, drawSettings); drawTrack(canvas, rotatedTileBox, sf, drawSettings);
drawPoints(canvas, rotatedTileBox, sf); drawPoints(canvas, rotatedTileBox, sf);
imageView.setImageDrawable(new BitmapDrawable(app.getResources(), mapBitmap)); imageView.setImageDrawable(new BitmapDrawable(app.getResources(), mapBitmap));
imageView.setVisibility(View.VISIBLE); imageView.setVisibility(View.VISIBLE);
} else { } else {
imageView.setVisibility(View.GONE); imageView.setVisibility(View.GONE);
}
} }
} }