From 764ec8d0c172e69f16e7d5dbd4defcdb85f0c80e Mon Sep 17 00:00:00 2001 From: Bella Mangunsong Date: Thu, 15 Feb 2018 11:25:01 +1100 Subject: [PATCH] fix the Circle Demo --- .../main/java/com/example/kotlindemos/CircleDemoActivity.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ApiDemos/kotlin/app/src/main/java/com/example/kotlindemos/CircleDemoActivity.kt b/ApiDemos/kotlin/app/src/main/java/com/example/kotlindemos/CircleDemoActivity.kt index d89851e8..717f0b35 100644 --- a/ApiDemos/kotlin/app/src/main/java/com/example/kotlindemos/CircleDemoActivity.kt +++ b/ApiDemos/kotlin/app/src/main/java/com/example/kotlindemos/CircleDemoActivity.kt @@ -139,6 +139,7 @@ class CircleDemoActivity : } fun onStyleChange() { + // [circle] is treated as implicit this inside the with block with(circle) { strokeWidth = strokeWidthBar.progress.toFloat() strokeColor = strokeColorArgb @@ -208,7 +209,8 @@ class CircleDemoActivity : setContentDescription(getString(R.string.circle_demo_details)) setOnMapLongClickListener { point -> // We know the center, let's place the outline at a point 3/4 along the view. - val view: View = supportFragmentManager.findFragmentById(R.id.map).view as View + val view: View = supportFragmentManager.findFragmentById(R.id.map).view + ?: return@setOnMapLongClickListener val radiusLatLng = map.projection.fromScreenLocation( Point(view.height * 3 / 4, view.width * 3 / 4)) // Create the circle. @@ -292,6 +294,7 @@ class CircleDemoActivity : else -> strokeColorArgb } + // Apply the style change to all the circles. circles.map { it.onStyleChange() } }