Skip to content

Commit

Permalink
limit bounds calculation loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ank27 committed Dec 1, 2022
1 parent f16074a commit 42691b7
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,11 @@ internal class ViewAnnotationManagerImpl(
var west: Pair<ViewAnnotationOptions, Rect?>? = null
var south: Pair<ViewAnnotationOptions, Rect?>? = null

while (!isCorrectBound) {
// we run the loop twice to adjust bounds correctly to fit all the annotations.
var boundsCounter = 1
while (!isCorrectBound && boundsCounter <= MAX_ADJUST_BOUNDS_COUNTER) {
val zoom = cameraOptionForCoordinates.zoom
boundsCounter++
isCorrectBound = true
viewAnnotationOptions.forEach { options ->
val frame = getViewAnnotationOptionsFrame(options) ?: Rect(0, 0, 0, 0)
Expand Down Expand Up @@ -662,6 +665,7 @@ internal class ViewAnnotationManagerImpl(
internal const val EXCEPTION_TEXT_ASSOCIATED_FEATURE_ID_ALREADY_EXISTS =
"View annotation with associatedFeatureId=%s already exists!"
private const val TAG = "ViewAnnotationImpl"
private const val MAX_ADJUST_BOUNDS_COUNTER = 2

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal fun needToReorderZ(
Expand Down

0 comments on commit 42691b7

Please sign in to comment.