Skip to content

Commit

Permalink
Update cancelLocationUpdates to check for googleApiClient connection …
Browse files Browse the repository at this point in the history
…instead of try/catch
  • Loading branch information
jennantilla committed Dec 14, 2023
1 parent ebc7ea2 commit 6e23387
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,22 @@ internal class GmsLocationController(
}

internal object FusedLocationApiWrapper {
fun cancelLocationUpdates(
googleApiClient: GoogleApiClient,
locationListener: LocationListener,
) {
try {
// fun cancelLocationUpdates(
// googleApiClient: GoogleApiClient,
// locationListener: LocationListener,
// ) {
// try {
// LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, locationListener)
// } catch (e: IllegalStateException) {
// Logging.warn("Caught IllegalStateException in cancelLocationUpdates", e)
// }
// }

fun cancelLocationUpdates(googleApiClient: GoogleApiClient, locationListener: LocationListener) {
if (googleApiClient.isConnected) {
LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, locationListener)
} catch (e: IllegalStateException) {
Logging.warn("Caught IllegalStateException in cancelLocationUpdates", e)
} else {
Logging.warn("GoogleApiClient is not connected. Unable to cancel location updates.")
}
}

Expand Down

0 comments on commit 6e23387

Please sign in to comment.