Search in sources :

Example 1 with SearchActivity

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;
}
Also used : LatLon(net.osmand.data.LatLon) Intent(android.content.Intent) TextView(android.widget.TextView) SearchActivity(net.osmand.plus.activities.search.SearchActivity)

Example 2 with SearchActivity

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);
    }
}
Also used : LatLon(net.osmand.data.LatLon) OsmandApplication(net.osmand.plus.OsmandApplication) SearchActivity(net.osmand.plus.activities.search.SearchActivity)

Example 3 with SearchActivity

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);
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) SearchActivity(net.osmand.plus.activities.search.SearchActivity)

Example 4 with SearchActivity

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;
            }
        }
    }
}
Also used : FragmentActivity(android.support.v4.app.FragmentActivity) LatLon(net.osmand.data.LatLon) FavouritePoint(net.osmand.data.FavouritePoint) SearchActivity(net.osmand.plus.activities.search.SearchActivity) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) FavouritePoint(net.osmand.data.FavouritePoint)

Example 5 with SearchActivity

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;
        }
    });
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) OnMenuItemClickListener(android.view.MenuItem.OnMenuItemClickListener) MenuItem(android.view.MenuItem) Menu(android.view.Menu) SearchActivity(net.osmand.plus.activities.search.SearchActivity)

Aggregations

SearchActivity (net.osmand.plus.activities.search.SearchActivity)6 OsmandApplication (net.osmand.plus.OsmandApplication)4 LatLon (net.osmand.data.LatLon)3 TextView (android.widget.TextView)2 Intent (android.content.Intent)1 FragmentActivity (android.support.v4.app.FragmentActivity)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 OnMenuItemClickListener (android.view.MenuItem.OnMenuItemClickListener)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 FavouritePoint (net.osmand.data.FavouritePoint)1