Skip to content

Commit 6b74eb9

Browse files
committed
Rebased
1 parent 2dda072 commit 6b74eb9

File tree

1 file changed

+9
-17
lines changed
  • mlkit/app/src/main/java/com/google/firebase/samples/apps/mlkit/kotlin/cloudlandmarkrecognition

1 file changed

+9
-17
lines changed

mlkit/app/src/main/java/com/google/firebase/samples/apps/mlkit/kotlin/cloudlandmarkrecognition/CloudLandmarkGraphic.kt

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,16 @@ import com.google.firebase.samples.apps.mlkit.common.GraphicOverlay
1010
/** Graphic instance for rendering detected landmark. */
1111
class CloudLandmarkGraphic(overlay: GraphicOverlay) : GraphicOverlay.Graphic(overlay) {
1212

13-
private val rectPaint: Paint
14-
private val landmarkPaint: Paint
15-
private lateinit var landmark: FirebaseVisionCloudLandmark
16-
17-
init {
18-
19-
rectPaint = Paint()
20-
rectPaint.color = TEXT_COLOR
21-
rectPaint.style = Paint.Style.STROKE
22-
rectPaint.strokeWidth = STROKE_WIDTH
23-
24-
landmarkPaint = Paint()
25-
landmarkPaint.color = TEXT_COLOR
26-
landmarkPaint.textSize = TEXT_SIZE
13+
private val rectPaint = Paint().apply {
14+
color = TEXT_COLOR
15+
style = Paint.Style.STROKE
16+
strokeWidth = STROKE_WIDTH
2717
}
18+
private val landmarkPaint = Paint().apply {
19+
color = TEXT_COLOR
20+
textSize = TEXT_SIZE
21+
}
22+
private lateinit var landmark: FirebaseVisionCloudLandmark
2823

2924
/**
3025
* Updates the landmark instance from the detection of the most recent frame. Invalidates the
@@ -39,9 +34,6 @@ class CloudLandmarkGraphic(overlay: GraphicOverlay) : GraphicOverlay.Graphic(ove
3934
* Draws the landmark block annotations for position, size, and raw value on the supplied canvas.
4035
*/
4136
override fun draw(canvas: Canvas) {
42-
if (landmark == null) {
43-
throw IllegalStateException("Attempting to draw a null landmark.")
44-
}
4537
if (landmark.landmark == null || landmark.boundingBox == null) {
4638
return
4739
}

0 commit comments

Comments
 (0)