mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-26 01:30:51 +00:00
(Android location) onConnected/onDisconnected reimplemented - still don't seem
to get to onLocationChanged though
This commit is contained in:
parent
1a20317cef
commit
0d94dd03f7
@ -49,12 +49,16 @@ LocationListener
|
||||
{
|
||||
// Display the connection status
|
||||
Toast.makeText(this, "Connected", Toast.LENGTH_SHORT).show();
|
||||
location_service_running = true;
|
||||
// If already requested, start periodic updates
|
||||
if (mUpdatesRequested)
|
||||
{
|
||||
mLocationClient.requestLocationUpdates(mLocationRequest,
|
||||
(com.google.android.gms.location.LocationListener) this);
|
||||
}
|
||||
else
|
||||
// Get last known location
|
||||
mCurrentLocation = mLocationClient.getLastLocation();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -67,6 +71,19 @@ LocationListener
|
||||
// Display the connection status
|
||||
Toast.makeText(this, "Disconnected. Please re-connect.",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
||||
// If the client is connected
|
||||
if (mLocationClient.isConnected())
|
||||
{
|
||||
/*
|
||||
* Remove location updates for a listener.
|
||||
* The current Activity is the listener, so
|
||||
* the argument is "this".
|
||||
*/
|
||||
mLocationClient.removeLocationUpdates((com.google.android.gms.location.LocationListener) this);
|
||||
}
|
||||
|
||||
location_service_running = false;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -160,10 +177,6 @@ LocationListener
|
||||
|
||||
// Connect the client.
|
||||
mLocationClient.connect();
|
||||
|
||||
// Get last known location
|
||||
mCurrentLocation = mLocationClient.getLastLocation();
|
||||
location_service_running = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -183,24 +196,8 @@ LocationListener
|
||||
if (!location_service_running)
|
||||
return;
|
||||
|
||||
// If the client is connected
|
||||
if (mLocationClient.isConnected())
|
||||
{
|
||||
/*
|
||||
* Remove location updates for a listener.
|
||||
* The current Activity is the listener, so
|
||||
* the argument is "this".
|
||||
*/
|
||||
mLocationClient.removeLocationUpdates((com.google.android.gms.location.LocationListener) this);
|
||||
}
|
||||
|
||||
if (location_service_running)
|
||||
{
|
||||
// Disconnecting the client invalidates it.
|
||||
mLocationClient.disconnect();
|
||||
}
|
||||
|
||||
location_service_running = false;
|
||||
// Disconnecting the client invalidates it.
|
||||
mLocationClient.disconnect();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -252,6 +249,9 @@ LocationListener
|
||||
@Override
|
||||
public void onLocationChanged(Location location)
|
||||
{
|
||||
if (!location_service_running)
|
||||
return;
|
||||
|
||||
locationChanged = true;
|
||||
mCurrentLocation = location;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user