Skip to content

Commit 764ec8d

Browse files
committed
fix the Circle Demo
1 parent bc62c42 commit 764ec8d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ApiDemos/kotlin/app/src/main/java/com/example/kotlindemos/CircleDemoActivity.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class CircleDemoActivity :
139139
}
140140

141141
fun onStyleChange() {
142+
// [circle] is treated as implicit this inside the with block
142143
with(circle) {
143144
strokeWidth = strokeWidthBar.progress.toFloat()
144145
strokeColor = strokeColorArgb
@@ -208,7 +209,8 @@ class CircleDemoActivity :
208209
setContentDescription(getString(R.string.circle_demo_details))
209210
setOnMapLongClickListener { point ->
210211
// We know the center, let's place the outline at a point 3/4 along the view.
211-
val view: View = supportFragmentManager.findFragmentById(R.id.map).view as View
212+
val view: View = supportFragmentManager.findFragmentById(R.id.map).view
213+
?: return@setOnMapLongClickListener
212214
val radiusLatLng = map.projection.fromScreenLocation(
213215
Point(view.height * 3 / 4, view.width * 3 / 4))
214216
// Create the circle.
@@ -292,6 +294,7 @@ class CircleDemoActivity :
292294
else -> strokeColorArgb
293295
}
294296

297+
// Apply the style change to all the circles.
295298
circles.map { it.onStyleChange() }
296299
}
297300

0 commit comments

Comments
 (0)