Search in sources :

Example 1 with StartGPSStatus

use of net.osmand.plus.activities.actions.StartGPSStatus in project Osmand by osmandapp.

the class MapInfoWidgetsFactory method createGPSInfoControl.

public TextInfoWidget createGPSInfoControl(final MapActivity map) {
    final OsmandApplication app = map.getMyApplication();
    final OsmAndLocationProvider loc = app.getLocationProvider();
    final TextInfoWidget gpsInfoControl = new TextInfoWidget(map) {

        private int u = -1;

        private int f = -1;

        @Override
        public boolean updateInfo(DrawSettings d) {
            GPSInfo gpsInfo = loc.getGPSInfo();
            if (gpsInfo.usedSatellites != u || gpsInfo.foundSatellites != f) {
                u = gpsInfo.usedSatellites;
                f = gpsInfo.foundSatellites;
                setText(gpsInfo.usedSatellites + "/" + gpsInfo.foundSatellites, "");
                return true;
            }
            return false;
        }
    };
    gpsInfoControl.setIcons(R.drawable.widget_gps_info_day, R.drawable.widget_gps_info_night);
    gpsInfoControl.setText(null, null);
    gpsInfoControl.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            new StartGPSStatus(map).run();
        }
    });
    return gpsInfoControl;
}
Also used : OsmAndLocationProvider(net.osmand.plus.OsmAndLocationProvider) OsmandApplication(net.osmand.plus.OsmandApplication) OnClickListener(android.view.View.OnClickListener) GPSInfo(net.osmand.plus.OsmAndLocationProvider.GPSInfo) StartGPSStatus(net.osmand.plus.activities.actions.StartGPSStatus) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) DrawSettings(net.osmand.plus.views.OsmandMapLayer.DrawSettings)

Aggregations

View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 OsmAndLocationProvider (net.osmand.plus.OsmAndLocationProvider)1 GPSInfo (net.osmand.plus.OsmAndLocationProvider.GPSInfo)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 StartGPSStatus (net.osmand.plus.activities.actions.StartGPSStatus)1 DrawSettings (net.osmand.plus.views.OsmandMapLayer.DrawSettings)1 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)1