react-native-google-maps-plus 1.10.0-dev.3 → 1.10.0-dev.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,7 +19,6 @@ import com.google.android.gms.location.LocationServices
19
19
  import com.google.android.gms.location.LocationSettingsRequest
20
20
  import com.google.android.gms.location.Priority
21
21
  import com.google.android.gms.maps.LocationSource
22
- import com.google.android.gms.tasks.OnSuccessListener
23
22
  import com.rngooglemapsplus.extensions.toLocationErrorCode
24
23
 
25
24
  private const val REQ_LOCATION_SETTINGS = 2001
@@ -144,13 +143,12 @@ class LocationHandler(
144
143
  }
145
144
  try {
146
145
  fusedLocationClientProviderClient.lastLocation
147
- .addOnSuccessListener(
148
- OnSuccessListener { location ->
149
- if (location != null) {
150
- onUpdate?.invoke(location)
151
- }
152
- },
153
- ).addOnFailureListener { e ->
146
+ .addOnSuccessListener { location ->
147
+ if (location != null) {
148
+ listener?.onLocationChanged(location)
149
+ onUpdate?.invoke(location)
150
+ }
151
+ }.addOnFailureListener { e ->
154
152
  val error = e.toLocationErrorCode(context)
155
153
  onError?.invoke(error)
156
154
  }
@@ -166,14 +164,14 @@ class LocationHandler(
166
164
  }
167
165
  }
168
166
  }
167
+
168
+ val req = locationRequest ?: return
169
+ val callback = locationCallback ?: return
170
+
169
171
  fusedLocationClientProviderClient
170
- .requestLocationUpdates(
171
- locationRequest!!,
172
- locationCallback!!,
173
- Looper.getMainLooper(),
174
- ).addOnFailureListener { e ->
175
- val error = e.toLocationErrorCode(context)
176
- onError?.invoke(error)
172
+ .requestLocationUpdates(req, callback, Looper.getMainLooper())
173
+ .addOnFailureListener { e ->
174
+ onError?.invoke(e.toLocationErrorCode(context))
177
175
  }
178
176
  } catch (_: SecurityException) {
179
177
  onError?.invoke(RNLocationErrorCode.PERMISSION_DENIED)
@@ -186,11 +184,10 @@ class LocationHandler(
186
184
  fun stop() {
187
185
  if (!isActive) return
188
186
  isActive = false
189
- if (locationCallback != null) {
190
- fusedLocationClientProviderClient.removeLocationUpdates(locationCallback!!)
191
- fusedLocationClientProviderClient.flushLocations()
192
- locationCallback = null
193
- }
187
+ val callback = locationCallback ?: return
188
+ fusedLocationClientProviderClient.removeLocationUpdates(callback)
189
+ fusedLocationClientProviderClient.flushLocations()
190
+ locationCallback = null
194
191
  }
195
192
 
196
193
  override fun activate(listener: LocationSource.OnLocationChangedListener) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-google-maps-plus",
3
- "version": "1.10.0-dev.3",
3
+ "version": "1.10.0-dev.4",
4
4
  "description": "React Native wrapper for Android & iOS Google Maps SDK",
5
5
  "main": "./lib/module/index.js",
6
6
  "module": "./lib/module/index.js",