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