Show address searching dialog while adding target point
This commit is contained in:
parent
4fc1b11058
commit
cf9809c946
3 changed files with 40 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.plus.mapcontextmenu;
|
package net.osmand.plus.mapcontextmenu;
|
||||||
|
|
||||||
|
import android.app.ProgressDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
@ -57,6 +58,8 @@ public class MapContextMenu extends MenuTitleController {
|
||||||
|
|
||||||
private int favActionIconId;
|
private int favActionIconId;
|
||||||
|
|
||||||
|
private MenuAction searchDoneAction;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MapActivity getMapActivity() {
|
public MapActivity getMapActivity() {
|
||||||
return mapActivity;
|
return mapActivity;
|
||||||
|
@ -333,10 +336,19 @@ public class MapContextMenu extends MenuTitleController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void refreshMenuTitle() {
|
public void onSearchAddressDone() {
|
||||||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||||
if (fragmentRef != null)
|
if (fragmentRef != null)
|
||||||
fragmentRef.get().refreshTitle();
|
fragmentRef.get().refreshTitle();
|
||||||
|
|
||||||
|
if (searchDoneAction != null) {
|
||||||
|
if (searchDoneAction.dlg != null) {
|
||||||
|
searchDoneAction.dlg.dismiss();
|
||||||
|
searchDoneAction.dlg = null;
|
||||||
|
}
|
||||||
|
searchDoneAction.run();
|
||||||
|
searchDoneAction = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public WeakReference<MapContextMenuFragment> findMenuFragment() {
|
public WeakReference<MapContextMenuFragment> findMenuFragment() {
|
||||||
|
@ -406,8 +418,22 @@ public class MapContextMenu extends MenuTitleController {
|
||||||
if (pointDescription.isDestination()) {
|
if (pointDescription.isDestination()) {
|
||||||
mapActivity.getMapActions().editWaypoints();
|
mapActivity.getMapActions().editWaypoints();
|
||||||
} else {
|
} else {
|
||||||
mapActivity.getMapActions().addAsTarget(latLon.getLatitude(), latLon.getLongitude(),
|
MenuAction addAsTargetAction = new MenuAction() {
|
||||||
pointDescription);
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mapActivity.getMapActions().addAsTarget(latLon.getLatitude(), latLon.getLongitude(),
|
||||||
|
pointDescription);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (searchingAddress) {
|
||||||
|
addAsTargetAction.dlg = ProgressDialog.show(mapActivity,
|
||||||
|
"",
|
||||||
|
addressNotKnownStr);
|
||||||
|
searchDoneAction = addAsTargetAction;
|
||||||
|
} else {
|
||||||
|
addAsTargetAction.run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
@ -668,4 +694,8 @@ public class MapContextMenu extends MenuTitleController {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private abstract class MenuAction implements Runnable {
|
||||||
|
protected ProgressDialog dlg;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -23,6 +23,7 @@ public abstract class MenuTitleController {
|
||||||
protected Drawable secondLineTypeIcon;
|
protected Drawable secondLineTypeIcon;
|
||||||
protected String streetStr = "";
|
protected String streetStr = "";
|
||||||
protected String addressNotKnownStr;
|
protected String addressNotKnownStr;
|
||||||
|
protected boolean searchingAddress;
|
||||||
|
|
||||||
public abstract MapActivity getMapActivity();
|
public abstract MapActivity getMapActivity();
|
||||||
|
|
||||||
|
@ -131,6 +132,7 @@ public abstract class MenuTitleController {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void acquireStreetName() {
|
protected void acquireStreetName() {
|
||||||
|
searchingAddress = true;
|
||||||
Location ll = new Location("");
|
Location ll = new Location("");
|
||||||
ll.setLatitude(getLatLon().getLatitude());
|
ll.setLatitude(getLatLon().getLatitude());
|
||||||
ll.setLongitude(getLatLon().getLongitude());
|
ll.setLongitude(getLatLon().getLongitude());
|
||||||
|
@ -183,9 +185,10 @@ public abstract class MenuTitleController {
|
||||||
nameStr = streetStr;
|
nameStr = streetStr;
|
||||||
getPointDescription().setName(nameStr);
|
getPointDescription().setName(nameStr);
|
||||||
}
|
}
|
||||||
|
searchingAddress = false;
|
||||||
getMapActivity().runOnUiThread(new Runnable() {
|
getMapActivity().runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
refreshMenuTitle();
|
onSearchAddressDone();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -195,12 +198,14 @@ public abstract class MenuTitleController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
|
searchingAddress = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void refreshMenuTitle();
|
protected void onSearchAddressDone() {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,10 +73,6 @@ public class MapMultiSelectionMenu extends BaseMenuController {
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void refreshMenuTitle() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean needStreetName() {
|
protected boolean needStreetName() {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue