use of net.osmand.plus.activities.search.SearchActivity in project Osmand by osmandapp.
the class NavigatePointFragment method onCreateView.
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.search_point, container, false);
setHasOptionsMenu(true);
location = null;
app = (OsmandApplication) getActivity().getApplication();
Intent intent = getActivity().getIntent();
if (intent != null) {
double lat = intent.getDoubleExtra(SEARCH_LAT, 0);
double lon = intent.getDoubleExtra(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 = app.getSettings().getLastKnownMapLocation();
}
currentFormat = app.getSettings().COORDINATES_FORMAT.get();
initUI(location.getLatitude(), location.getLongitude());
if (savedInstanceState != null && savedInstanceState.containsKey(SEARCH_LAT) && savedInstanceState.containsKey(SEARCH_LON) && currentFormat != PointDescription.UTM_FORMAT) {
String lat = savedInstanceState.getString(SEARCH_LAT);
String lon = savedInstanceState.getString(SEARCH_LON);
if (lat != null && lon != null && lat.length() > 0 && lon.length() > 0) {
((TextView) view.findViewById(R.id.LatitudeEdit)).setText(lat);
((TextView) view.findViewById(R.id.LongitudeEdit)).setText(lon);
}
}
return view;
}
use of net.osmand.plus.activities.search.SearchActivity in project Osmand by osmandapp.
the class NavigatePointFragment method onResume.
@Override
public void onResume() {
super.onResume();
OsmandApplication app = (OsmandApplication) getActivity().getApplication();
LatLon loc = null;
if (getActivity() instanceof SearchActivity) {
loc = ((SearchActivity) getActivity()).getSearchPoint();
}
if (loc == null) {
loc = app.getSettings().getLastKnownMapLocation();
}
if (!Algorithms.objectEquals(loc, location)) {
location = loc;
locationUpdate(location);
}
}
use of net.osmand.plus.activities.search.SearchActivity in project Osmand by osmandapp.
the class FavoritesListFragment method locationUpdate.
@Override
public void locationUpdate(LatLon l) {
if (getActivity() instanceof SearchActivity) {
if (((SearchActivity) getActivity()).isSearchAroundCurrentLocation() && l != null) {
if (!compassRegistered) {
OsmandApplication app = getMyApplication();
app.getLocationProvider().removeCompassListener(app.getLocationProvider().getNavigationInfo());
app.getLocationProvider().addCompassListener(this);
compassRegistered = true;
}
favouritesAdapter.searchAroundLocation = true;
} else {
favouritesAdapter.searchAroundLocation = false;
}
}
if (favouritesAdapter != null) {
favouritesAdapter.updateLocation(l);
}
}
use of net.osmand.plus.activities.search.SearchActivity in project Osmand by osmandapp.
the class FavoritesListFragment method updateCompassValue.
@Override
public void updateCompassValue(float value) {
// 99 in next line used to one-time initialize arrows (with reference vs. fixed-north direction) on non-compass
// devices
FragmentActivity activity = getActivity();
float lastHeading = favouritesAdapter.heading != null ? favouritesAdapter.heading : 99;
favouritesAdapter.heading = value;
if (Math.abs(MapUtils.degreesDiff(lastHeading, favouritesAdapter.heading)) > 5) {
if (activity instanceof SearchActivity) {
((SearchActivity) activity).getAccessibilityAssistant().lockEvents();
favouritesAdapter.notifyDataSetChanged();
((SearchActivity) activity).getAccessibilityAssistant().unlockEvents();
} else {
favouritesAdapter.notifyDataSetChanged();
}
} else {
favouritesAdapter.heading = lastHeading;
}
if (activity instanceof SearchActivity) {
final View selected = ((SearchActivity) activity).getAccessibilityAssistant().getFocusedView();
if (selected != null) {
try {
int position = getListView().getPositionForView(selected);
if ((position != AdapterView.INVALID_POSITION) && (position >= getListView().getHeaderViewsCount())) {
FavouritePoint point = favouritesAdapter.getItem(position - getListView().getHeaderViewsCount());
LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
((SearchActivity) activity).getNavigationInfo().updateTargetDirection(location, favouritesAdapter.heading.floatValue());
}
} catch (Exception e) {
return;
}
}
}
}
use of net.osmand.plus.activities.search.SearchActivity in project Osmand by osmandapp.
the class NavigatePointFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) {
OsmandApplication app = (OsmandApplication) getActivity().getApplication();
boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
boolean light = app.getSettings().isLightActionBar();
Menu menu = onCreate;
if (getActivity() instanceof SearchActivity) {
((SearchActivity) getActivity()).getClearToolbar(false);
light = false;
}
MenuItem menuItem = menu.add(0, SHOW_ON_MAP, 0, R.string.shared_string_show_on_map);
MenuItemCompat.setShowAsAction(menuItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
menuItem = menuItem.setIcon(app.getIconsCache().getIcon(R.drawable.ic_action_marker_dark, light));
menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
select(SHOW_ON_MAP);
return true;
}
});
}
Aggregations