@Override public void updateGeoData(final IGeoData data) { if (data.getGpsEnabled() == gpsEnabled && data.getSatellitesFixed() == satellitesFixed && data.getSatellitesVisible() == satellitesVisible) { return; } gpsEnabled = data.getGpsEnabled(); satellitesFixed = data.getSatellitesFixed(); satellitesVisible = data.getSatellitesVisible(); if (gpsEnabled) { if (satellitesFixed > 0) { navSatellites.setText( res.getString(R.string.loc_sat) + ": " + satellitesFixed + '/' + satellitesVisible); } else if (satellitesVisible >= 0) { navSatellites.setText(res.getString(R.string.loc_sat) + ": 0/" + satellitesVisible); } } else { navSatellites.setText(res.getString(R.string.loc_gps_disabled)); } }
@Override public void updateGeoData(final IGeoData geo) { if (!nearestView.isClickable()) { nearestView.setFocusable(true); nearestView.setClickable(true); nearestView.setOnClickListener( new OnClickListener() { @Override public void onClick(final View v) { cgeoFindNearest(v); } }); nearestView.setBackgroundResource(R.drawable.main_nearby); } navType.setText(res.getString(geo.getLocationProvider().resourceId)); if (geo.getAccuracy() >= 0) { final int speed = Math.round(geo.getSpeed()) * 60 * 60 / 1000; navAccuracy.setText( "±" + Units.getDistanceFromMeters(geo.getAccuracy()) + Formatter.SEPARATOR + Units.getSpeed(speed)); } else { navAccuracy.setText(null); } if (Settings.isShowAddress()) { if (addCoords == null) { navLocation.setText(R.string.loc_no_addr); } if (addCoords == null || (geo.getCoords().distanceTo(addCoords) > 0.5)) { final Observable<String> address = Observable.create( new OnSubscribe<String>() { @Override public void call(final Subscriber<? super String> subscriber) { try { addCoords = geo.getCoords(); final Geocoder geocoder = new Geocoder(MainActivity.this, Locale.getDefault()); final Geopoint coords = app.currentGeo().getCoords(); final List<Address> addresses = geocoder.getFromLocation( coords.getLatitude(), coords.getLongitude(), 1); if (!addresses.isEmpty()) { subscriber.onNext(formatAddress(addresses.get(0))); } subscriber.onCompleted(); } catch (final Exception e) { subscriber.onError(e); } } }); AndroidObservable.bindActivity( MainActivity.this, address.onErrorResumeNext(Observable.from(geo.getCoords().toString()))) .subscribeOn(Schedulers.io()) .subscribe( new Action1<String>() { @Override public void call(final String address) { navLocation.setText(address); } }); } } else { navLocation.setText(geo.getCoords().toString()); } }