blob: 8efc9549068a48631bbb559872b9f948910b3a40 [file] [log] [blame]
Selim Cinekf418bb02020-05-04 17:16:58 -07001package com.android.systemui.media
2
3import android.content.Context
4import android.util.AttributeSet
5import 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 */
11class 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}