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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
172
|
-
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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