[android] Minor location refactoring

This commit is contained in:
Alex Zolotarev 2013-06-07 00:24:44 +03:00 committed by Alex Zolotarev
parent 8f0cc7ac0d
commit c0bfefafc9
5 changed files with 14 additions and 11 deletions

View file

@ -4,6 +4,7 @@ import android.content.ActivityNotFoundException;
import android.content.ContentResolver;
import android.content.Intent;
import android.graphics.Color;
import android.location.Location;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
@ -538,10 +539,12 @@ public class DownloadResourcesActivity extends MapsWithMeBaseActivity
}
@Override
public void onLocationUpdated(long time, double lat, double lon, float accuracy)
public void onLocationUpdated(final Location l)
{
if (mCountryIndex == null)
{
final double lat = l.getLatitude();
final double lon = l.getLongitude();
Log.i(TAG, "Searching for country name at location lat=" + lat + ", lon=" + lon);
mCountryIndex = findIndexByPos(lat, lon);

View file

@ -726,7 +726,7 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
}
@Override
public void onLocationUpdated(long time, double lat, double lon, float accuracy)
public void onLocationUpdated(final Location l)
{
if (getLocationState().isFirstPosition())
{
@ -735,7 +735,7 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
mMyPositionButton.setSelected(true);
}
nativeLocationUpdated(time, lat, lon, accuracy);
nativeLocationUpdated(l.getTime(), l.getLatitude(), l.getLongitude(), l.getAccuracy());
}
@Override

View file

@ -587,12 +587,12 @@ public class SearchActivity extends MapsWithMeBaseListActivity implements Locati
}
@Override
public void onLocationUpdated(long time, double lat, double lon, float accuracy)
public void onLocationUpdated(final Location l)
{
m_flags |= HAS_POSITION;
m_lat = lat;
m_lon = lon;
m_lat = l.getLatitude();
m_lon = l.getLongitude();
if (runSearch() == SEARCH_SKIPPED)
updateDistance();

View file

@ -110,7 +110,7 @@ public class BookmarkListAdapter extends BaseAdapter implements LocationService.
}
@Override
public void onLocationUpdated(long time, double lat, double lon, float accuracy)
public void onLocationUpdated(final Location l)
{
notifyDataSetChanged();
}

View file

@ -41,7 +41,7 @@ public class LocationService implements LocationListener, SensorEventListener, W
public interface Listener
{
public void onLocationUpdated(long time, double lat, double lon, float accuracy);
public void onLocationUpdated(final Location l);
public void onCompassUpdated(long time, double magneticNorth, double trueNorth, double accuracy);
public void onLocationError(int errorCode);
};
@ -93,11 +93,11 @@ public class LocationService implements LocationListener, SensorEventListener, W
}
*/
private void notifyLocationUpdated(long time, double lat, double lon, float accuracy)
private void notifyLocationUpdated(final Location l)
{
Iterator<Listener> it = m_observers.iterator();
while (it.hasNext())
it.next().onLocationUpdated(time, lat, lon, accuracy);
it.next().onLocationUpdated(l);
}
private void notifyCompassUpdated(long time, double magneticNorth, double trueNorth, double accuracy)
@ -285,7 +285,7 @@ public class LocationService implements LocationListener, SensorEventListener, W
private void emitLocation(Location l)
{
m_lastLocation = l;
notifyLocationUpdated(l.getTime(), l.getLatitude(), l.getLongitude(), l.getAccuracy());
notifyLocationUpdated(l);
}
/// Delta distance when we need to recreate GeomagneticField (to calculate declination).