fix update origin issue when switching to coordinate tab

This commit is contained in:
sonora 2014-12-30 23:42:16 +01:00
parent c5a8e30230
commit 072a12c285
2 changed files with 18 additions and 3 deletions

View file

@ -166,6 +166,24 @@ public class NavigatePointFragment extends SherlockFragment implements SearchAct
@Override
public void onResume() {
super.onResume();
private LatLon location;
Intent intent = getSherlockActivity().getIntent();
if (intent != null) {
if (intent.hasExtra(SearchActivity.SEARCH_LAT) && intent.hasExtra(SearchActivity.SEARCH_LON)) {
double lat = intent.getDoubleExtra(SearchActivity.SEARCH_LAT, 0);
double lon = intent.getDoubleExtra(SearchActivity.SEARCH_LON, 0);
if (lat != 0 || lon != 0) {
location = new LatLon(lat, lon);
}
}
}
if (location == null && getActivity() instanceof SearchActivity) {
location = ((SearchActivity) getActivity()).getSearchPoint();
}
if (location == null) {
location = settings.getLastKnownMapLocation();
}
locationUpdate(location);
}

View file

@ -347,9 +347,6 @@ public class SearchActivity extends SherlockFragmentActivity implements OsmAndLo
this.searchPoint = searchPoint;
for(WeakReference<Fragment> ref : fragList) {
Fragment f = ref.get();
//TODO: If we keep the tabbed search screen also: Looks like the following code does not update the searchPoint on search tabs other than on the last used tab (which will be shown again first).
// So if user starts the tabbed search screen, then changes the search origin, then changes the tab to e.g. the search coordinates or search history, the (changed) origin displayed in the headline will initially not be the one used by the new tab.
// (Changing the origin again on that tab will correct the situation)
if(f instanceof SearchActivityChild) {
if(!f.isDetached()) {
((SearchActivityChild) f).locationUpdate(searchPoint);