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

Commit b683e1b

Browse files
move const to companion object
1 parent 7066c93 commit b683e1b

File tree

1 file changed

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

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ 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"
5047

5148

5249
companion object {
5350
private const val LOCATION_PERMISSION_REQUEST_CODE = 1
51+
private const val ZOOM_VALUE = 14f
52+
private const val PADDING_RATIO = 1.5
53+
private const val FRAGMENT_TAG = "Mapfragment"
5454
}
5555

5656
override fun onRequestPermissionsResult(requestCode: Int,
@@ -98,7 +98,7 @@ class MapsFragment : Fragment() {
9898

9999
// Add and adjust the position of MyLocation button.
100100
map.isMyLocationEnabled = true
101-
map.setPadding(0, (paddingRatio * autocompleteLayout.height).toInt(),0,0)
101+
map.setPadding(0, (PADDING_RATIO * autocompleteLayout.height).toInt(),0,0)
102102

103103
fusedLocationClient.lastLocation.addOnSuccessListener(this.activity as Activity) { location ->
104104
// Got last known location. In some rare situations this can be null.
@@ -107,14 +107,14 @@ class MapsFragment : Fragment() {
107107
currentLatLng = LatLng(location.latitude, location.longitude)
108108
map.animateCamera(CameraUpdateFactory.newLatLngZoom(
109109
currentLatLng,
110-
zoomValue
110+
ZOOM_VALUE
111111
))
112112
map.addMarker(MarkerOptions()
113113
.position(currentLatLng!!)
114114
.title(getString(R.string.my_location_title)))
115115
map.moveCamera(CameraUpdateFactory.newLatLngZoom(
116116
currentLatLng,
117-
zoomValue
117+
ZOOM_VALUE
118118
))
119119
setPlacesSearchBias()
120120
} ?: run{
@@ -133,7 +133,7 @@ class MapsFragment : Fragment() {
133133
}
134134

135135
override fun onError(status: Status) {
136-
Log.e(fragmentTag, "An error occurred: $status")
136+
Log.e(FRAGMENT_TAG, "An error occurred: $status")
137137
}
138138
})
139139
}
@@ -158,7 +158,7 @@ class MapsFragment : Fragment() {
158158
targetMarker?.remove()
159159
map.moveCamera(CameraUpdateFactory.newLatLngZoom(
160160
targetLatLng,
161-
zoomValue
161+
ZOOM_VALUE
162162
))
163163
targetMarker = map.addMarker(MarkerOptions()
164164
.position(targetLatLng)

0 commit comments

Comments
 (0)