Skip to content

Commit

Permalink
Important bug fixes to layout manager
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasMata committed Oct 15, 2020
1 parent 4dd5d76 commit c7df288
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,13 @@ open class SpotlightView @JvmOverloads constructor(

override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
super.onLayout(changed, left, top, right, bottom)
if (changed) {
_thisRect.set(
left,
top,
right,
bottom
)
layoutViews()
}
_thisRect.set(
left,
top,
right,
bottom
)
layoutViews()
}

override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class DefaultLayoutManager : SpotlightLayoutManager {
messageGravity: SpotlightMessageGravity
): Int {
val availableArea = availableRect(view, parent, rect, messageGravity)
return when(messageGravity) {
return when (messageGravity) {
SpotlightMessageGravity.right, SpotlightMessageGravity.left -> availableArea.width
SpotlightMessageGravity.top, SpotlightMessageGravity.bottom -> availableArea.height
}
Expand Down Expand Up @@ -135,7 +135,7 @@ class DefaultLayoutManager : SpotlightLayoutManager {
parentRect.bottom - root.insetBottom
)

if (rootRect.width() == 0 && rootRect.height() == 0) return
if (rootRect.width() <= 0 && rootRect.height() <= 0) return

val density = root.context.resources.displayMetrics.density
val totalDistanceAvailable = distanceBetween(root, rootRect, targetRect, messageGravity)
Expand Down Expand Up @@ -165,8 +165,7 @@ class DefaultLayoutManager : SpotlightLayoutManager {
}
}
val widthMeasureSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST)
val heightMeasureSpec =
MeasureSpec.makeMeasureSpec(totalAreaAvailable.height, MeasureSpec.AT_MOST)
val heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST)
message.measure(widthMeasureSpec, heightMeasureSpec)
messageWidth = message.measuredWidth
messageHeight = message.measuredHeight
Expand All @@ -175,6 +174,7 @@ class DefaultLayoutManager : SpotlightLayoutManager {
layoutParams.width = messageWidth
layoutParams.height = messageHeight
message.layoutParams = layoutParams
return
}
} else {
messageHeight = originalMessageHeight
Expand Down

0 comments on commit c7df288

Please sign in to comment.