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

Commit 7066c93

Browse files
remove getFloat
1 parent 94000b1 commit 7066c93

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class MapsFragment : Fragment() {
4444
private lateinit var autocompleteFragment : AutocompleteSupportFragment
4545
private var currentLatLng : LatLng? = null
4646
private var targetMarker : Marker? = null
47+
private val zoomValue = 14f
48+
private val paddingRatio = 1.5
49+
private val fragmentTag = "Mapfragment"
4750

4851

4952
companion object {
@@ -95,23 +98,23 @@ class MapsFragment : Fragment() {
9598

9699
// Add and adjust the position of MyLocation button.
97100
map.isMyLocationEnabled = true
98-
map.setPadding(0, (resources.getFloat(R.dimen.padding_ratio) * autocompleteLayout.height).toInt(),0,0)
99-
101+
map.setPadding(0, (paddingRatio * autocompleteLayout.height).toInt(),0,0)
102+
100103
fusedLocationClient.lastLocation.addOnSuccessListener(this.activity as Activity) { location ->
101104
// Got last known location. In some rare situations this can be null.
102105
location?.let {
103106
lastLocation = location
104107
currentLatLng = LatLng(location.latitude, location.longitude)
105108
map.animateCamera(CameraUpdateFactory.newLatLngZoom(
106109
currentLatLng,
107-
resources.getFloat(R.dimen.zoom_value)
110+
zoomValue
108111
))
109112
map.addMarker(MarkerOptions()
110113
.position(currentLatLng!!)
111114
.title(getString(R.string.my_location_title)))
112115
map.moveCamera(CameraUpdateFactory.newLatLngZoom(
113116
currentLatLng,
114-
resources.getFloat(R.dimen.zoom_value)
117+
zoomValue
115118
))
116119
setPlacesSearchBias()
117120
} ?: run{
@@ -130,7 +133,7 @@ class MapsFragment : Fragment() {
130133
}
131134

132135
override fun onError(status: Status) {
133-
Log.e("Mapfragment", "An error occurred: $status")
136+
Log.e(fragmentTag, "An error occurred: $status")
134137
}
135138
})
136139
}
@@ -149,14 +152,13 @@ class MapsFragment : Fragment() {
149152
map = googleMap
150153
map.uiSettings.isZoomControlsEnabled = true
151154
setUpMap()
152-
153155
}
154156

155157
private val searchPlacesCallback = OnMapReadyCallback { map ->
156158
targetMarker?.remove()
157159
map.moveCamera(CameraUpdateFactory.newLatLngZoom(
158160
targetLatLng,
159-
resources.getFloat(R.dimen.zoom_value)
161+
zoomValue
160162
))
161163
targetMarker = map.addMarker(MarkerOptions()
162164
.position(targetLatLng)

android/canonical/app/src/main/res/values/parameters.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)