Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
Fix update visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
acolombo11 committed Jul 3, 2019
1 parent 01bd652 commit 4f752af
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions minimap-view/src/main/java/eu/acolombo/minimap/MinimapView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class MinimapView @JvmOverloads constructor(context: Context, attrs: AttributeSe
scrollWidth = rv.computeHorizontalScrollRange().toFloat()
scrollHeight = rv.computeVerticalScrollRange().toFloat()

if (updateVisibility()) {
if (rv.updateVisibility()) {

// Scrollable height might be < than the scrollable width while scrollable width being < than total height of the RecyclerView
val biggerWidth = maxOf(scrollWidth, rv.width.toFloat()) // + rv.paddingRight + rv.paddingLeft
Expand Down Expand Up @@ -106,11 +106,11 @@ class MinimapView @JvmOverloads constructor(context: Context, attrs: AttributeSe
}

private fun View.updateVisibility(): Boolean {
if (!shouldBeVisible()) visibility = GONE
if (!shouldShow()) this@MinimapView.visibility = GONE
return visibility == VISIBLE
}

private fun View?.shouldBeVisible() = this != null && (scrollWidth > this.width || scrollHeight > this.height)
private fun View?.shouldShow() = this != null && (scrollWidth > this.width || scrollHeight > this.height)

private fun moveIndicator(dx: Int, dy: Int) = if (scaleFactor != 0f) {
indicatorX += dx / scaleFactor
Expand Down

0 comments on commit 4f752af

Please sign in to comment.