Skip to content
This repository was archived by the owner on Jul 2, 2025. It is now read-only.

Commit 4ec5ab3

Browse files
resolve conflict
1 parent 49337b0 commit 4ec5ab3

File tree

1 file changed

+23
-27
lines changed
  • android/canonical/app/src/main/java/com/google/samples/quickstart/canonical

1 file changed

+23
-27
lines changed

android/canonical/app/src/main/java/com/google/samples/quickstart/canonical/MapsFragment.kt

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class MapsFragment : Fragment() {
4949
private const val LOCATION_PERMISSION_REQUEST_CODE = 1
5050
private const val ZOOM_VALUE = 14f
5151
private const val PADDING_RATIO = 1.5
52-
private const val MAP_FRAGMENT_TAG = "Mapfragment"
52+
private const val FRAGMENT_TAG = "Mapfragment"
5353
}
5454

5555
override fun onRequestPermissionsResult(requestCode: Int,
@@ -99,33 +99,29 @@ class MapsFragment : Fragment() {
9999
map.isMyLocationEnabled = true
100100
map.setPadding(0, (PADDING_RATIO * autocompleteLayout.height).toInt(),0,0)
101101

102-
fusedLocationClient.lastLocation
103-
.addOnSuccessListener { location ->
102+
fusedLocationClient.lastLocation.addOnSuccessListener { location ->
104103
// Got last known location. In some rare situations this can be null.
105-
location?.let {
106-
Log.d(MAP_FRAGMENT_TAG, "Locating Success ${location.latitude}, ${location.longitude}")
107-
lastLocation = location
108-
currentLatLng = LatLng(location.latitude, location.longitude)
109-
map.animateCamera(CameraUpdateFactory.newLatLngZoom(
110-
currentLatLng,
111-
ZOOM_VALUE
112-
))
113-
map.addMarker(MarkerOptions()
114-
.position(currentLatLng!!)
115-
.title(getString(R.string.my_location_title)))
116-
map.moveCamera(CameraUpdateFactory.newLatLngZoom(
117-
currentLatLng,
118-
ZOOM_VALUE
119-
))
120-
setPlacesSearchBias()
121-
} ?: run{
122-
Log.d(MAP_FRAGMENT_TAG, "Locating Failed")
123-
Toast.makeText(context, getString(R.string.cannot_access_location), Toast.LENGTH_SHORT)
124-
}
125-
}
126-
.addOnFailureListener {
127-
Log.d(MAP_FRAGMENT_TAG, "fusedLocationClient.lastLocation Failed")
104+
location?.let {
105+
Log.d(FRAGMENT_TAG, "Locating Success ${location.latitude}, ${location.longitude}")
106+
lastLocation = location
107+
currentLatLng = LatLng(location.latitude, location.longitude)
108+
map.animateCamera(CameraUpdateFactory.newLatLngZoom(
109+
currentLatLng,
110+
ZOOM_VALUE
111+
))
112+
map.addMarker(MarkerOptions()
113+
.position(currentLatLng!!)
114+
.title(getString(R.string.my_location_title)))
115+
map.moveCamera(CameraUpdateFactory.newLatLngZoom(
116+
currentLatLng,
117+
ZOOM_VALUE
118+
))
119+
setPlacesSearchBias()
120+
} ?: run{
121+
Log.d(FRAGMENT_TAG, "Locating Failed")
122+
Toast.makeText(context, getString(R.string.cannot_access_location), Toast.LENGTH_SHORT)
128123
}
124+
}
129125
}
130126

131127
private fun setUpAutocomplete(autocompleteFragment : AutocompleteSupportFragment, mapFragment : SupportMapFragment) {
@@ -138,7 +134,7 @@ class MapsFragment : Fragment() {
138134
}
139135

140136
override fun onError(status: Status) {
141-
Log.e(MAP_FRAGMENT_TAG, "An error occurred: $status")
137+
Log.e(FRAGMENT_TAG, "An error occurred: $status")
142138
}
143139
})
144140
}

0 commit comments

Comments
 (0)