Selim Cinek | f418bb0 | 2020-05-04 17:16:58 -0700 | [diff] [blame] | 1 | package com.android.systemui.media |
| 2 | |
| 3 | import android.content.Context |
| 4 | import android.util.AttributeSet |
| 5 | import android.widget.HorizontalScrollView |
| 6 | |
| 7 | /** |
| 8 | * A Horizontal scrollview that doesn't limit itself to the childs bounds. This is useful |
| 9 | * when only measuring children but not the parent, when trying to apply a new scroll position |
| 10 | */ |
| 11 | class UnboundHorizontalScrollView @JvmOverloads constructor( |
| 12 | context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) |
| 13 | : HorizontalScrollView(context, attrs, defStyleAttr) { |
| 14 | |
| 15 | /** |
| 16 | * Allow all scrolls to go through, use base implementation |
| 17 | */ |
| 18 | override fun scrollTo(x: Int, y: Int) { |
| 19 | if (mScrollX != x || mScrollY != y) { |
| 20 | val oldX: Int = mScrollX |
| 21 | val oldY: Int = mScrollY |
| 22 | mScrollX = x |
| 23 | mScrollY = y |
| 24 | invalidateParentCaches() |
| 25 | onScrollChanged(mScrollX, mScrollY, oldX, oldY) |
| 26 | if (!awakenScrollBars()) { |
| 27 | postInvalidateOnAnimation() |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | } |