File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
indicator-fast-scroll/src/main/java/com/reddit/indicatorfastscroll Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -353,14 +353,22 @@ class FastScrollerView @JvmOverloads constructor(
353353 }
354354 is TextView -> {
355355 @Suppress(" UNCHECKED_CAST" )
356- val possibleTouchedIndicators = view.tag as List <FastScrollItemIndicator .Text >
356+ val possibleTouchedIndicators = view.tag as List <FastScrollItemIndicator .Text >
357+ if (possibleTouchedIndicators.isEmpty() || heightForCalculations == 0 ) {
358+ return false
359+ }
360+
357361 val textIndicatorsTouchY = touchY - view.top
358362
359363 val textLineHeight = heightForCalculations / possibleTouchedIndicators.size
360- val touchedIndicatorIndex = min(
361- textIndicatorsTouchY / textLineHeight,
362- possibleTouchedIndicators.lastIndex
363- )
364+ val touchedIndicatorIndex = if (textLineHeight > 0 ) {
365+ min(
366+ textIndicatorsTouchY / textLineHeight,
367+ possibleTouchedIndicators.lastIndex
368+ )
369+ } else {
370+ 0
371+ }
364372
365373 val touchedIndicator = possibleTouchedIndicators[touchedIndicatorIndex]
366374 val centerY = view.y.toInt() + (textLineHeight / 2 ) + (touchedIndicatorIndex * textLineHeight)
You can’t perform that action at this time.
0 commit comments