commit
4df472c67d
4 changed files with 46 additions and 11 deletions
|
@ -13,9 +13,11 @@ import android.webkit.WebView;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.plus.mapillary.MapillaryPlugin;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
public class ContextMenuCardDialogFragment extends Fragment {
|
||||
|
@ -115,6 +117,14 @@ public class ContextMenuCardDialogFragment extends Fragment {
|
|||
public void dismiss() {
|
||||
MapActivity activity = dialog.getMapActivity();
|
||||
if (activity != null) {
|
||||
if (dialog.getType() == ContextMenuCardDialog.CardDialogType.MAPILLARY) {
|
||||
if (!activity.getMyApplication().getSettings().SHOW_MAPILLARY.get()) {
|
||||
MapillaryPlugin mapillaryPlugin = OsmandPlugin.getPlugin(MapillaryPlugin.class);
|
||||
if (mapillaryPlugin != null) {
|
||||
mapillaryPlugin.updateLayers(activity.getMapView(), activity);
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
activity.getSupportFragmentManager().popBackStack(TAG,
|
||||
FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.mapillary;
|
|||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard;
|
||||
|
@ -21,9 +22,15 @@ public class MapillaryImageCard extends ImageCard {
|
|||
OnClickListener onClickListener = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (!getMyApplication().getSettings().SHOW_MAPILLARY.get()) {
|
||||
MapillaryPlugin mapillaryPlugin = OsmandPlugin.getPlugin(MapillaryPlugin.class);
|
||||
if (mapillaryPlugin != null) {
|
||||
mapillaryPlugin.updateLayers(getMapActivity().getMapView(), getMapActivity(), true);
|
||||
}
|
||||
}
|
||||
getMapActivity().getContextMenu().hideMenues();
|
||||
MapillaryImageDialog.show(getMapActivity(), getKey(), getImageHiresUrl(), getUrl(), getLocation(),
|
||||
getCa(), getMyApplication().getString(R.string.mapillary), null);
|
||||
getCa(), getMyApplication().getString(R.string.mapillary), null, true);
|
||||
}
|
||||
};
|
||||
if (!Algorithms.isEmpty(buttonText)) {
|
||||
|
|
|
@ -80,6 +80,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
|
|||
private String viewerUrl;
|
||||
private LatLon latLon;
|
||||
private double ca = Double.NaN;
|
||||
private boolean sync;
|
||||
|
||||
private View staticImageView;
|
||||
private View noInternetView;
|
||||
|
@ -97,7 +98,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
|
|||
}
|
||||
|
||||
public MapillaryImageDialog(MapActivity mapActivity, String key, String sKey, String imageUrl,
|
||||
String viewerUrl, LatLon latLon, double ca, String title, String description) {
|
||||
String viewerUrl, LatLon latLon, double ca, String title, String description, boolean sync) {
|
||||
super(mapActivity, CardDialogType.MAPILLARY);
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
|
@ -108,6 +109,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
|
|||
this.latLon = latLon;
|
||||
this.ca = ca;
|
||||
this.ic = mapActivity.getMyApplication().getIconsCache();
|
||||
this.sync = sync;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
|
@ -475,7 +477,12 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
|
|||
// asking tile image async
|
||||
boolean imgExist = mgr.tileExistOnFileSystem(tileId, map, tileX, tileY, TILE_ZOOM);
|
||||
if (imgExist) {
|
||||
tile = mgr.getGeometryTilesCache().getTileForMapAsync(tileId, map, tileX, tileY, TILE_ZOOM, false);
|
||||
if (sync) {
|
||||
tile = mgr.getGeometryTilesCache().getTileForMapSync(tileId, map, tileX, tileY, TILE_ZOOM, false);
|
||||
sync = false;
|
||||
} else {
|
||||
tile = mgr.getGeometryTilesCache().getTileForMapAsync(tileId, map, tileX, tileY, TILE_ZOOM, false);
|
||||
}
|
||||
}
|
||||
if (tile != null) {
|
||||
tiles.put(tileId, new Pair<>(new QuadPointDouble(tileX, tileY), tile));
|
||||
|
@ -492,7 +499,16 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
|
|||
String viewerUrl, LatLon latLon, double ca,
|
||||
String title, String description) {
|
||||
MapillaryImageDialog dialog = new MapillaryImageDialog(mapActivity, key, null, imageUrl,
|
||||
viewerUrl, latLon, ca, title, description);
|
||||
viewerUrl, latLon, ca, title, description, false);
|
||||
ContextMenuCardDialogFragment.showInstance(dialog);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public static MapillaryImageDialog show(MapActivity mapActivity, String key, String imageUrl,
|
||||
String viewerUrl, LatLon latLon, double ca,
|
||||
String title, String description, boolean sync) {
|
||||
MapillaryImageDialog dialog = new MapillaryImageDialog(mapActivity, key, null, imageUrl,
|
||||
viewerUrl, latLon, ca, title, description, sync);
|
||||
ContextMenuCardDialogFragment.showInstance(dialog);
|
||||
return dialog;
|
||||
}
|
||||
|
@ -503,7 +519,7 @@ public class MapillaryImageDialog extends ContextMenuCardDialog {
|
|||
String viewerUrl = MAPILLARY_VIEWER_URL_TEMPLATE + key;
|
||||
LatLon latLon = new LatLon(latitude, longitude);
|
||||
MapillaryImageDialog dialog = new MapillaryImageDialog(mapActivity, key, sKey, imageUrl, viewerUrl,
|
||||
latLon, ca, title, description);
|
||||
latLon, ca, title, description, false);
|
||||
ContextMenuCardDialogFragment.showInstance(dialog);
|
||||
return dialog;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.osmand.plus.mapillary;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
@ -36,7 +35,6 @@ import net.osmand.plus.views.mapwidgets.MapWidgetRegistry.MapWidgetRegInfo;
|
|||
import net.osmand.plus.views.mapwidgets.TextInfoWidget;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -96,17 +94,21 @@ public class MapillaryPlugin extends OsmandPlugin {
|
|||
|
||||
@Override
|
||||
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||
updateMapLayers(mapView, activity.getMapLayers());
|
||||
updateMapLayers(mapView, activity.getMapLayers(), false);
|
||||
}
|
||||
|
||||
private void updateMapLayers(OsmandMapTileView mapView, final MapActivityLayers layers) {
|
||||
public void updateLayers(OsmandMapTileView mapView, MapActivity activity, boolean force) {
|
||||
updateMapLayers(mapView, activity.getMapLayers(), force);
|
||||
}
|
||||
|
||||
private void updateMapLayers(OsmandMapTileView mapView, final MapActivityLayers layers, boolean force) {
|
||||
if (rasterLayer == null || vectorLayer == null) {
|
||||
createLayers();
|
||||
}
|
||||
if (isActive()) {
|
||||
ITileSource rasterSource = null;
|
||||
ITileSource vectorSource = null;
|
||||
if (settings.SHOW_MAPILLARY.get()) {
|
||||
if (settings.SHOW_MAPILLARY.get() || force) {
|
||||
rasterSource = settings.getTileSourceByName(TileSourceManager.getMapillaryRasterSource().getName(), false);
|
||||
vectorSource = settings.getTileSourceByName(TileSourceManager.getMapillaryVectorSource().getName(), false);
|
||||
}
|
||||
|
@ -156,7 +158,7 @@ public class MapillaryPlugin extends OsmandPlugin {
|
|||
OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
MapActivityLayers mapLayers = mapActivity.getMapLayers();
|
||||
settings.SHOW_MAPILLARY.set(!settings.SHOW_MAPILLARY.get());
|
||||
updateMapLayers(mapView, mapLayers);
|
||||
updateMapLayers(mapView, mapLayers, false);
|
||||
ContextMenuItem item = adapter.getItem(pos);
|
||||
if (item != null) {
|
||||
item.setSelected(settings.SHOW_MAPILLARY.get());
|
||||
|
|
Loading…
Reference in a new issue